cmake/Source/cmGlobalVisualStudioGenerator.h

204 lines
5.9 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#ifndef cmGlobalVisualStudioGenerator_h
#define cmGlobalVisualStudioGenerator_h
2018-01-26 17:06:56 +01:00
#include "cmConfigure.h" // IWYU pragma: keep
2017-04-14 19:02:05 +02:00
#include <iosfwd>
#include <map>
#include <set>
#include <string>
#include <vector>
#include "cmGlobalGenerator.h"
2017-04-14 19:02:05 +02:00
#include "cmTargetDepend.h"
class cmCustomCommand;
class cmGeneratorTarget;
class cmLocalGenerator;
class cmMakefile;
class cmake;
/** \class cmGlobalVisualStudioGenerator
* \brief Base class for global Visual Studio generators.
*
* cmGlobalVisualStudioGenerator provides functionality common to all
* global Visual Studio generators.
*/
class cmGlobalVisualStudioGenerator : public cmGlobalGenerator
{
public:
2015-08-17 11:37:30 +02:00
/** Known versions of Visual Studio. */
enum VSVersion
{
VS8 = 80,
VS9 = 90,
VS10 = 100,
VS11 = 110,
VS12 = 120,
/* VS13 = 130 was skipped */
2016-10-30 18:24:19 +01:00
VS14 = 140,
VS15 = 150
2015-08-17 11:37:30 +02:00
};
cmGlobalVisualStudioGenerator(cmake* cm);
virtual ~cmGlobalVisualStudioGenerator();
2015-08-17 11:37:30 +02:00
VSVersion GetVersion() const;
void SetVersion(VSVersion v);
/**
* Configure CMake's Visual Studio macros file into the user's Visual
* Studio macros directory.
*/
virtual void ConfigureCMakeVisualStudioMacros();
/**
* Where does this version of Visual Studio look for macros for the
* current user? Returns the empty string if this version of Visual
* Studio does not implement support for VB macros.
*/
virtual std::string GetUserMacrosDirectory();
/**
* What is the reg key path to "vsmacros" for this version of Visual
* Studio?
*/
virtual std::string GetUserMacrosRegKeyBase();
2016-07-09 11:21:54 +02:00
enum MacroName
{
MacroReload,
MacroStop
};
/**
* Call the ReloadProjects macro if necessary based on
* GetFilesReplacedDuringGenerate results.
*/
2016-07-09 11:21:54 +02:00
void CallVisualStudioMacro(MacroName m, const char* vsSolutionFile = 0);
2013-03-16 19:13:01 +02:00
// return true if target is fortran only
2016-07-09 11:21:54 +02:00
bool TargetIsFortranOnly(const cmGeneratorTarget* gt);
2017-04-14 19:02:05 +02:00
// return true if target is C# only
static bool TargetIsCSharpOnly(cmGeneratorTarget const* gt);
2017-09-21 19:03:52 +02:00
// return true if target can be referenced by C# targets
bool TargetCanBeReferenced(cmGeneratorTarget const* gt);
2009-10-04 10:30:41 +03:00
/** Get the top-level registry key for this VS version. */
std::string GetRegistryBase();
2010-03-17 14:00:29 +02:00
2013-03-16 19:13:01 +02:00
/** Get the top-level registry key for the given VS version. */
static std::string GetRegistryBase(const char* version);
2010-03-17 14:00:29 +02:00
/** Return true if the generated build tree may contain multiple builds.
i.e. "Can I build Debug and Release in the same tree?" */
2018-04-23 21:13:27 +02:00
bool IsMultiConfig() const override { return true; }
2010-03-17 14:00:29 +02:00
2013-03-16 19:13:01 +02:00
/** Return true if building for Windows CE */
virtual bool TargetsWindowsCE() const { return false; }
2018-04-23 21:13:27 +02:00
bool IsIncludeExternalMSProjectSupported() const override { return true; }
2016-07-09 11:21:54 +02:00
class TargetSet : public std::set<cmGeneratorTarget const*>
{
};
2015-11-17 17:22:37 +01:00
class TargetCompare
2009-10-04 10:30:41 +03:00
{
2015-11-17 17:22:37 +01:00
std::string First;
2016-07-09 11:21:54 +02:00
2015-11-17 17:22:37 +01:00
public:
2016-07-09 11:21:54 +02:00
TargetCompare(std::string const& first)
: First(first)
{
}
2015-11-17 17:22:37 +01:00
bool operator()(cmGeneratorTarget const* l,
cmGeneratorTarget const* r) const;
2009-10-04 10:30:41 +03:00
};
2011-01-16 11:35:12 +01:00
class OrderedTargetDependSet;
2009-10-04 10:30:41 +03:00
2018-01-26 17:06:56 +01:00
bool FindMakeProgram(cmMakefile*) override;
2014-08-03 19:52:23 +02:00
2018-04-23 21:13:27 +02:00
std::string ExpandCFGIntDir(const std::string& str,
const std::string& config) const override;
2014-08-03 19:52:23 +02:00
2015-04-27 22:25:09 +02:00
void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
2015-11-17 17:22:37 +01:00
2016-07-09 11:21:54 +02:00
std::string GetStartupProjectName(cmLocalGenerator const* root) const;
void AddSymbolExportCommand(cmGeneratorTarget*,
std::vector<cmCustomCommand>& commands,
std::string const& configName);
2018-04-23 21:13:27 +02:00
bool Open(const std::string& bindir, const std::string& projectName,
bool dryRun) override;
2010-11-13 01:00:53 +02:00
protected:
2018-04-23 21:13:27 +02:00
void AddExtraIDETargets() override;
2015-04-27 22:25:09 +02:00
2010-11-13 01:00:53 +02:00
// Does this VS version link targets to each other if there are
// dependencies in the SLN file? This was done for VS versions
// below 8.
virtual bool VSLinksDependencies() const { return true; }
virtual const char* GetIDEVersion() = 0;
2018-04-23 21:13:27 +02:00
bool ComputeTargetDepends() override;
2016-07-09 11:21:54 +02:00
class VSDependSet : public std::set<std::string>
{
};
class VSDependMap : public std::map<cmGeneratorTarget const*, VSDependSet>
{
};
2010-11-13 01:00:53 +02:00
VSDependMap VSTargetDepends;
2016-07-09 11:21:54 +02:00
void ComputeVSTargetDepends(cmGeneratorTarget*);
2016-03-13 13:35:51 +01:00
bool CheckTargetLinks(cmGeneratorTarget& target, const std::string& name);
std::string GetUtilityForTarget(cmGeneratorTarget& target,
const std::string&);
virtual std::string WriteUtilityDepend(cmGeneratorTarget const*) = 0;
2016-07-09 11:21:54 +02:00
std::string GetUtilityDepend(const cmGeneratorTarget* target);
2016-03-13 13:35:51 +01:00
typedef std::map<cmGeneratorTarget const*, std::string> UtilityDependsMap;
2010-11-13 01:00:53 +02:00
UtilityDependsMap UtilityDepends;
2013-03-16 19:13:01 +02:00
2015-08-17 11:37:30 +02:00
protected:
VSVersion Version;
2011-01-16 11:35:12 +01:00
private:
2014-08-03 19:52:23 +02:00
virtual std::string GetVSMakeProgram() = 0;
2015-04-27 22:25:09 +02:00
void PrintCompilerAdvice(std::ostream&, std::string const&,
2016-07-09 11:21:54 +02:00
const char*) const
{
}
2012-04-19 19:04:21 +03:00
2016-03-13 13:35:51 +01:00
void FollowLinkDepends(cmGeneratorTarget const* target,
std::set<cmGeneratorTarget const*>& linked);
2011-01-16 11:35:12 +01:00
2016-07-09 11:21:54 +02:00
class TargetSetMap : public std::map<cmGeneratorTarget*, TargetSet>
{
};
2011-01-16 11:35:12 +01:00
TargetSetMap TargetLinkClosure;
2016-07-09 11:21:54 +02:00
void FillLinkClosure(const cmGeneratorTarget* target, TargetSet& linked);
2016-03-13 13:35:51 +01:00
TargetSet const& GetTargetLinkClosure(cmGeneratorTarget* target);
2011-01-16 11:35:12 +01:00
};
2016-07-09 11:21:54 +02:00
class cmGlobalVisualStudioGenerator::OrderedTargetDependSet
: public std::multiset<cmTargetDepend,
cmGlobalVisualStudioGenerator::TargetCompare>
2011-01-16 11:35:12 +01:00
{
2015-11-17 17:22:37 +01:00
typedef std::multiset<cmTargetDepend,
cmGlobalVisualStudioGenerator::TargetCompare>
derived;
2016-07-09 11:21:54 +02:00
2011-01-16 11:35:12 +01:00
public:
typedef cmGlobalGenerator::TargetDependSet TargetDependSet;
typedef cmGlobalVisualStudioGenerator::TargetSet TargetSet;
2015-11-17 17:22:37 +01:00
OrderedTargetDependSet(TargetDependSet const&, std::string const& first);
OrderedTargetDependSet(TargetSet const&, std::string const& first);
};
#endif