VS: Cleanup AddPlatformDefinitions() of Visual Studio generators

Move adding of definitions into cmGlobalVisualStudioGenerator to
share code and avoid duplicate architecture string literals.
This commit is contained in:
Patrick Gansterer 2012-07-21 15:37:46 +02:00 committed by Brad King
parent addefc2ae3
commit 2c7a451de0
21 changed files with 43 additions and 78 deletions

View File

@ -19,6 +19,7 @@
cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator() cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator()
{ {
this->VersionId = "MSVC10";
this->FindMakeProgramFile = "CMakeVS10FindMake.cmake"; this->FindMakeProgramFile = "CMakeVS10FindMake.cmake";
std::string vc10Express; std::string vc10Express;
this->ExpressEdition = cmSystemTools::ReadRegistryValue( this->ExpressEdition = cmSystemTools::ReadRegistryValue(
@ -26,14 +27,6 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator()
"ProductDir", vc10Express, cmSystemTools::KeyWOW64_32); "ProductDir", vc10Express, cmSystemTools::KeyWOW64_32);
} }
//----------------------------------------------------------------------------
void cmGlobalVisualStudio10Generator::AddPlatformDefinitions(cmMakefile* mf)
{
mf->AddDefinition("MSVC10", "1");
mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "X86");
mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "X86");
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout) void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout)
{ {

View File

@ -38,7 +38,6 @@ public:
virtual const char* GetName() const { virtual const char* GetName() const {
return cmGlobalVisualStudio10Generator::GetActualName();} return cmGlobalVisualStudio10Generator::GetActualName();}
static const char* GetActualName() {return "Visual Studio 10";} static const char* GetActualName() {return "Visual Studio 10";}
virtual void AddPlatformDefinitions(cmMakefile* mf);
/** Get the documentation entry for this generator. */ /** Get the documentation entry for this generator. */
virtual void GetDocumentation(cmDocumentationEntry& entry) const; virtual void GetDocumentation(cmDocumentationEntry& entry) const;

View File

@ -16,6 +16,7 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmGlobalVisualStudio10IA64Generator::cmGlobalVisualStudio10IA64Generator() cmGlobalVisualStudio10IA64Generator::cmGlobalVisualStudio10IA64Generator()
{ {
this->ArchitectureId = "x64";
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -33,8 +34,6 @@ void cmGlobalVisualStudio10IA64Generator
{ {
this->cmGlobalVisualStudio10Generator::AddPlatformDefinitions(mf); this->cmGlobalVisualStudio10Generator::AddPlatformDefinitions(mf);
mf->AddDefinition("CMAKE_FORCE_IA64", "TRUE"); mf->AddDefinition("CMAKE_FORCE_IA64", "TRUE");
mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "x64");
mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "x64");
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -16,6 +16,7 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmGlobalVisualStudio10Win64Generator::cmGlobalVisualStudio10Win64Generator() cmGlobalVisualStudio10Win64Generator::cmGlobalVisualStudio10Win64Generator()
{ {
this->ArchitectureId = "x64";
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -33,8 +34,6 @@ void cmGlobalVisualStudio10Win64Generator
{ {
this->cmGlobalVisualStudio10Generator::AddPlatformDefinitions(mf); this->cmGlobalVisualStudio10Generator::AddPlatformDefinitions(mf);
mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE"); mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE");
mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "x64");
mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "x64");
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -13,6 +13,12 @@
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmake.h" #include "cmake.h"
//----------------------------------------------------------------------------
cmGlobalVisualStudio11ARMGenerator::cmGlobalVisualStudio11ARMGenerator()
{
this->ArchitectureId = "ARM";
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalVisualStudio11ARMGenerator void cmGlobalVisualStudio11ARMGenerator
::GetDocumentation(cmDocumentationEntry& entry) const ::GetDocumentation(cmDocumentationEntry& entry) const
@ -21,12 +27,3 @@ void cmGlobalVisualStudio11ARMGenerator
entry.Brief = "Generates Visual Studio 11 ARM project files."; entry.Brief = "Generates Visual Studio 11 ARM project files.";
entry.Full = ""; entry.Full = "";
} }
//----------------------------------------------------------------------------
void cmGlobalVisualStudio11ARMGenerator
::AddPlatformDefinitions(cmMakefile* mf)
{
this->cmGlobalVisualStudio11Generator::AddPlatformDefinitions(mf);
mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "ARM");
mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "ARM");
}

View File

@ -18,7 +18,7 @@ class cmGlobalVisualStudio11ARMGenerator :
public cmGlobalVisualStudio11Generator public cmGlobalVisualStudio11Generator
{ {
public: public:
cmGlobalVisualStudio11ARMGenerator() {} cmGlobalVisualStudio11ARMGenerator();
static cmGlobalGenerator* New() { static cmGlobalGenerator* New() {
return new cmGlobalVisualStudio11ARMGenerator; } return new cmGlobalVisualStudio11ARMGenerator; }
@ -31,7 +31,5 @@ public:
/** Get the documentation entry for this generator. */ /** Get the documentation entry for this generator. */
virtual void GetDocumentation(cmDocumentationEntry& entry) const; virtual void GetDocumentation(cmDocumentationEntry& entry) const;
virtual void AddPlatformDefinitions(cmMakefile* mf);
}; };
#endif #endif

View File

@ -16,19 +16,12 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator() cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator()
{ {
this->VersionId = "MSVC11";
this->FindMakeProgramFile = "CMakeVS11FindMake.cmake"; this->FindMakeProgramFile = "CMakeVS11FindMake.cmake";
this->ExpressEdition = false; // TODO: VS 11 Express support this->ExpressEdition = false; // TODO: VS 11 Express support
this->PlatformToolset = "v110"; this->PlatformToolset = "v110";
} }
//----------------------------------------------------------------------------
void cmGlobalVisualStudio11Generator::AddPlatformDefinitions(cmMakefile* mf)
{
mf->AddDefinition("MSVC11", "1");
mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "X86");
mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "X86");
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout) void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout)
{ {

View File

@ -28,7 +28,6 @@ public:
virtual const char* GetName() const { virtual const char* GetName() const {
return cmGlobalVisualStudio11Generator::GetActualName();} return cmGlobalVisualStudio11Generator::GetActualName();}
static const char* GetActualName() {return "Visual Studio 11";} static const char* GetActualName() {return "Visual Studio 11";}
virtual void AddPlatformDefinitions(cmMakefile* mf);
virtual void WriteSLNHeader(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout);

View File

@ -13,6 +13,12 @@
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmake.h" #include "cmake.h"
//----------------------------------------------------------------------------
cmGlobalVisualStudio11Win64Generator::cmGlobalVisualStudio11Win64Generator()
{
this->ArchitectureId = "x64";
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalVisualStudio11Win64Generator void cmGlobalVisualStudio11Win64Generator
::GetDocumentation(cmDocumentationEntry& entry) const ::GetDocumentation(cmDocumentationEntry& entry) const
@ -28,6 +34,4 @@ void cmGlobalVisualStudio11Win64Generator
{ {
this->cmGlobalVisualStudio11Generator::AddPlatformDefinitions(mf); this->cmGlobalVisualStudio11Generator::AddPlatformDefinitions(mf);
mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE"); mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE");
mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "x64");
mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "x64");
} }

View File

@ -18,7 +18,7 @@ class cmGlobalVisualStudio11Win64Generator :
public cmGlobalVisualStudio11Generator public cmGlobalVisualStudio11Generator
{ {
public: public:
cmGlobalVisualStudio11Win64Generator() {} cmGlobalVisualStudio11Win64Generator();
static cmGlobalGenerator* New() { static cmGlobalGenerator* New() {
return new cmGlobalVisualStudio11Win64Generator; } return new cmGlobalVisualStudio11Win64Generator; }

View File

@ -32,6 +32,7 @@ std::string GetVS6TargetName(const std::string& targetName)
cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator() cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator()
{ {
this->VersionId = "MSVC60";
this->FindMakeProgramFile = "CMakeVS6FindMake.cmake"; this->FindMakeProgramFile = "CMakeVS6FindMake.cmake";
} }
@ -40,14 +41,12 @@ void cmGlobalVisualStudio6Generator
cmMakefile *mf, cmMakefile *mf,
bool optional) bool optional)
{ {
cmGlobalVisualStudioGenerator::AddPlatformDefinitions(mf);
mf->AddDefinition("CMAKE_GENERATOR_CC", "cl"); mf->AddDefinition("CMAKE_GENERATOR_CC", "cl");
mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl");
mf->AddDefinition("CMAKE_GENERATOR_RC", "rc"); mf->AddDefinition("CMAKE_GENERATOR_RC", "rc");
mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1");
mf->AddDefinition("CMAKE_GENERATOR_Fortran", "ifort"); mf->AddDefinition("CMAKE_GENERATOR_Fortran", "ifort");
mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "X86");
mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "X86");
mf->AddDefinition("MSVC60", "1");
this->GenerateConfigurations(mf); this->GenerateConfigurations(mf);
this->cmGlobalGenerator::EnableLanguage(lang, mf, optional); this->cmGlobalGenerator::EnableLanguage(lang, mf, optional);
} }

View File

@ -18,6 +18,7 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator() cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator()
{ {
this->VersionId = "MSVC71";
this->FindMakeProgramFile = "CMakeVS71FindMake.cmake"; this->FindMakeProgramFile = "CMakeVS71FindMake.cmake";
this->ProjectConfigurationSectionName = "ProjectConfiguration"; this->ProjectConfigurationSectionName = "ProjectConfiguration";
} }
@ -33,14 +34,6 @@ cmLocalGenerator *cmGlobalVisualStudio71Generator::CreateLocalGenerator()
return lg; return lg;
} }
//----------------------------------------------------------------------------
void cmGlobalVisualStudio71Generator::AddPlatformDefinitions(cmMakefile* mf)
{
this->cmGlobalVisualStudio7Generator::AddPlatformDefinitions(mf);
mf->RemoveDefinition("MSVC70");
mf->AddDefinition("MSVC71", "1");
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string cmGlobalVisualStudio71Generator::GetUserMacrosDirectory() std::string cmGlobalVisualStudio71Generator::GetUserMacrosDirectory()
{ {

View File

@ -53,7 +53,6 @@ public:
protected: protected:
virtual const char* GetIDEVersion() { return "7.1"; } virtual const char* GetIDEVersion() { return "7.1"; }
virtual void AddPlatformDefinitions(cmMakefile* mf);
virtual void WriteSLNFile(std::ostream& fout, virtual void WriteSLNFile(std::ostream& fout,
cmLocalGenerator* root, cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators); std::vector<cmLocalGenerator*>& generators);

View File

@ -18,6 +18,7 @@
cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator() cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator()
{ {
this->VersionId = "MSVC70";
this->FindMakeProgramFile = "CMakeVS7FindMake.cmake"; this->FindMakeProgramFile = "CMakeVS7FindMake.cmake";
} }
@ -55,13 +56,6 @@ void cmGlobalVisualStudio7Generator
} }
void cmGlobalVisualStudio7Generator::AddPlatformDefinitions(cmMakefile* mf)
{
mf->AddDefinition("MSVC70", "1");
mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "X86");
mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "X86");
}
std::string cmGlobalVisualStudio7Generator std::string cmGlobalVisualStudio7Generator
::GenerateBuildCommand(const char* makeProgram, ::GenerateBuildCommand(const char* makeProgram,
const char *projectName, const char *projectName,

View File

@ -112,7 +112,6 @@ protected:
virtual void WriteSLNFooter(std::ostream& fout); virtual void WriteSLNFooter(std::ostream& fout);
virtual void WriteSLNHeader(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout);
virtual std::string WriteUtilityDepend(cmTarget* target); virtual std::string WriteUtilityDepend(cmTarget* target);
virtual void AddPlatformDefinitions(cmMakefile* mf);
virtual void WriteTargetsToSolution( virtual void WriteTargetsToSolution(
std::ostream& fout, std::ostream& fout,

View File

@ -19,9 +19,9 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator() cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator()
{ {
this->VersionId = "MSVC80";
this->FindMakeProgramFile = "CMakeVS8FindMake.cmake"; this->FindMakeProgramFile = "CMakeVS8FindMake.cmake";
this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms"; this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms";
this->ArchitectureId = "X86";
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -53,14 +53,6 @@ void cmGlobalVisualStudio8Generator
entry.Full = ""; entry.Full = "";
} }
//----------------------------------------------------------------------------
void cmGlobalVisualStudio8Generator::AddPlatformDefinitions(cmMakefile* mf)
{
mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", this->ArchitectureId);
mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", this->ArchitectureId);
mf->AddDefinition("MSVC80", "1");
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalVisualStudio8Generator::Configure() void cmGlobalVisualStudio8Generator::Configure()
{ {

View File

@ -72,7 +72,6 @@ protected:
void AddCheckTarget(); void AddCheckTarget();
static cmIDEFlagTable const* GetExtraFlagTableVS8(); static cmIDEFlagTable const* GetExtraFlagTableVS8();
virtual void AddPlatformDefinitions(cmMakefile* mf);
virtual void WriteSLNHeader(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout);
virtual void WriteSolutionConfigurations(std::ostream& fout); virtual void WriteSolutionConfigurations(std::ostream& fout);
virtual void WriteProjectConfigurations(std::ostream& fout, virtual void WriteProjectConfigurations(std::ostream& fout,
@ -82,7 +81,5 @@ protected:
virtual bool ComputeTargetDepends(); virtual bool ComputeTargetDepends();
virtual void WriteProjectDepends(std::ostream& fout, const char* name, virtual void WriteProjectDepends(std::ostream& fout, const char* name,
const char* path, cmTarget &t); const char* path, cmTarget &t);
const char* ArchitectureId;
}; };
#endif #endif

View File

@ -19,17 +19,10 @@
cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator() cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator()
{ {
this->VersionId = "MSVC90";
this->FindMakeProgramFile = "CMakeVS9FindMake.cmake"; this->FindMakeProgramFile = "CMakeVS9FindMake.cmake";
} }
//----------------------------------------------------------------------------
void cmGlobalVisualStudio9Generator::AddPlatformDefinitions(cmMakefile* mf)
{
mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", this->ArchitectureId);
mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", this->ArchitectureId);
mf->AddDefinition("MSVC90", "1");
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalVisualStudio9Generator::WriteSLNHeader(std::ostream& fout) void cmGlobalVisualStudio9Generator::WriteSLNHeader(std::ostream& fout)
{ {

View File

@ -32,7 +32,6 @@ public:
virtual const char* GetName() const { virtual const char* GetName() const {
return cmGlobalVisualStudio9Generator::GetActualName();} return cmGlobalVisualStudio9Generator::GetActualName();}
static const char* GetActualName() {return "Visual Studio 9 2008";} static const char* GetActualName() {return "Visual Studio 9 2008";}
virtual void AddPlatformDefinitions(cmMakefile* mf);
/** Get the documentation entry for this generator. */ /** Get the documentation entry for this generator. */
virtual void GetDocumentation(cmDocumentationEntry& entry) const; virtual void GetDocumentation(cmDocumentationEntry& entry) const;

View File

@ -21,6 +21,8 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator() cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator()
{ {
this->ArchitectureId = "X86";
this->VersionId = 0;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -488,6 +490,18 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target)
} }
} }
//----------------------------------------------------------------------------
void cmGlobalVisualStudioGenerator::AddPlatformDefinitions(cmMakefile* mf)
{
mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", this->ArchitectureId);
mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", this->ArchitectureId);
if (this->VersionId)
{
mf->AddDefinition(this->VersionId, "1");
}
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string cmGlobalVisualStudioGenerator::GetUtilityDepend(cmTarget* target) std::string cmGlobalVisualStudioGenerator::GetUtilityDepend(cmTarget* target)
{ {

View File

@ -84,6 +84,8 @@ protected:
virtual const char* GetIDEVersion() = 0; virtual const char* GetIDEVersion() = 0;
virtual void AddPlatformDefinitions(cmMakefile* mf);
virtual bool ComputeTargetDepends(); virtual bool ComputeTargetDepends();
class VSDependSet: public std::set<cmStdString> {}; class VSDependSet: public std::set<cmStdString> {};
class VSDependMap: public std::map<cmTarget*, VSDependSet> {}; class VSDependMap: public std::map<cmTarget*, VSDependSet> {};
@ -96,6 +98,9 @@ protected:
std::string GetUtilityDepend(cmTarget* target); std::string GetUtilityDepend(cmTarget* target);
typedef std::map<cmTarget*, cmStdString> UtilityDependsMap; typedef std::map<cmTarget*, cmStdString> UtilityDependsMap;
UtilityDependsMap UtilityDepends; UtilityDependsMap UtilityDepends;
const char* ArchitectureId;
const char* VersionId;
private: private:
void ComputeTargetObjects(cmGeneratorTarget* gt) const; void ComputeTargetObjects(cmGeneratorTarget* gt) const;