From 2c7a451de003782b1ba5e47ab377f33f1fa5c4e5 Mon Sep 17 00:00:00 2001 From: Patrick Gansterer Date: Sat, 21 Jul 2012 15:37:46 +0200 Subject: VS: Cleanup AddPlatformDefinitions() of Visual Studio generators Move adding of definitions into cmGlobalVisualStudioGenerator to share code and avoid duplicate architecture string literals. --- Source/cmGlobalVisualStudio10Generator.cxx | 9 +-------- Source/cmGlobalVisualStudio10Generator.h | 1 - Source/cmGlobalVisualStudio10IA64Generator.cxx | 3 +-- Source/cmGlobalVisualStudio10Win64Generator.cxx | 3 +-- Source/cmGlobalVisualStudio11ARMGenerator.cxx | 15 ++++++--------- Source/cmGlobalVisualStudio11ARMGenerator.h | 4 +--- Source/cmGlobalVisualStudio11Generator.cxx | 9 +-------- Source/cmGlobalVisualStudio11Generator.h | 1 - Source/cmGlobalVisualStudio11Win64Generator.cxx | 8 ++++++-- Source/cmGlobalVisualStudio11Win64Generator.h | 2 +- Source/cmGlobalVisualStudio6Generator.cxx | 5 ++--- Source/cmGlobalVisualStudio71Generator.cxx | 9 +-------- Source/cmGlobalVisualStudio71Generator.h | 1 - Source/cmGlobalVisualStudio7Generator.cxx | 8 +------- Source/cmGlobalVisualStudio7Generator.h | 1 - Source/cmGlobalVisualStudio8Generator.cxx | 10 +--------- Source/cmGlobalVisualStudio8Generator.h | 3 --- Source/cmGlobalVisualStudio9Generator.cxx | 9 +-------- Source/cmGlobalVisualStudio9Generator.h | 1 - Source/cmGlobalVisualStudioGenerator.cxx | 14 ++++++++++++++ Source/cmGlobalVisualStudioGenerator.h | 5 +++++ 21 files changed, 43 insertions(+), 78 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 48ead25..b44b780 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -19,6 +19,7 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator() { + this->VersionId = "MSVC10"; this->FindMakeProgramFile = "CMakeVS10FindMake.cmake"; std::string vc10Express; this->ExpressEdition = cmSystemTools::ReadRegistryValue( @@ -27,14 +28,6 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator() } //---------------------------------------------------------------------------- -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) { fout << "Microsoft Visual Studio Solution File, Format Version 11.00\n"; diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 47ce790..a4a9d40 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -38,7 +38,6 @@ public: virtual const char* GetName() const { return cmGlobalVisualStudio10Generator::GetActualName();} static const char* GetActualName() {return "Visual Studio 10";} - virtual void AddPlatformDefinitions(cmMakefile* mf); /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry) const; diff --git a/Source/cmGlobalVisualStudio10IA64Generator.cxx b/Source/cmGlobalVisualStudio10IA64Generator.cxx index 5f70f6b..25dd88f 100644 --- a/Source/cmGlobalVisualStudio10IA64Generator.cxx +++ b/Source/cmGlobalVisualStudio10IA64Generator.cxx @@ -16,6 +16,7 @@ //---------------------------------------------------------------------------- cmGlobalVisualStudio10IA64Generator::cmGlobalVisualStudio10IA64Generator() { + this->ArchitectureId = "x64"; } //---------------------------------------------------------------------------- @@ -33,8 +34,6 @@ void cmGlobalVisualStudio10IA64Generator { this->cmGlobalVisualStudio10Generator::AddPlatformDefinitions(mf); mf->AddDefinition("CMAKE_FORCE_IA64", "TRUE"); - mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "x64"); - mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "x64"); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudio10Win64Generator.cxx b/Source/cmGlobalVisualStudio10Win64Generator.cxx index 49dc473..d0a0c49 100644 --- a/Source/cmGlobalVisualStudio10Win64Generator.cxx +++ b/Source/cmGlobalVisualStudio10Win64Generator.cxx @@ -16,6 +16,7 @@ //---------------------------------------------------------------------------- cmGlobalVisualStudio10Win64Generator::cmGlobalVisualStudio10Win64Generator() { + this->ArchitectureId = "x64"; } //---------------------------------------------------------------------------- @@ -33,8 +34,6 @@ void cmGlobalVisualStudio10Win64Generator { this->cmGlobalVisualStudio10Generator::AddPlatformDefinitions(mf); mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE"); - mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "x64"); - mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "x64"); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudio11ARMGenerator.cxx b/Source/cmGlobalVisualStudio11ARMGenerator.cxx index fef1aba..efd71c6 100644 --- a/Source/cmGlobalVisualStudio11ARMGenerator.cxx +++ b/Source/cmGlobalVisualStudio11ARMGenerator.cxx @@ -14,19 +14,16 @@ #include "cmake.h" //---------------------------------------------------------------------------- -void cmGlobalVisualStudio11ARMGenerator -::GetDocumentation(cmDocumentationEntry& entry) const +cmGlobalVisualStudio11ARMGenerator::cmGlobalVisualStudio11ARMGenerator() { - entry.Name = this->GetName(); - entry.Brief = "Generates Visual Studio 11 ARM project files."; - entry.Full = ""; + this->ArchitectureId = "ARM"; } //---------------------------------------------------------------------------- void cmGlobalVisualStudio11ARMGenerator -::AddPlatformDefinitions(cmMakefile* mf) +::GetDocumentation(cmDocumentationEntry& entry) const { - this->cmGlobalVisualStudio11Generator::AddPlatformDefinitions(mf); - mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "ARM"); - mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "ARM"); + entry.Name = this->GetName(); + entry.Brief = "Generates Visual Studio 11 ARM project files."; + entry.Full = ""; } diff --git a/Source/cmGlobalVisualStudio11ARMGenerator.h b/Source/cmGlobalVisualStudio11ARMGenerator.h index 77e1429..71dbf2e 100644 --- a/Source/cmGlobalVisualStudio11ARMGenerator.h +++ b/Source/cmGlobalVisualStudio11ARMGenerator.h @@ -18,7 +18,7 @@ class cmGlobalVisualStudio11ARMGenerator : public cmGlobalVisualStudio11Generator { public: - cmGlobalVisualStudio11ARMGenerator() {} + cmGlobalVisualStudio11ARMGenerator(); static cmGlobalGenerator* New() { return new cmGlobalVisualStudio11ARMGenerator; } @@ -31,7 +31,5 @@ public: /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry) const; - - virtual void AddPlatformDefinitions(cmMakefile* mf); }; #endif diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index be7fd55..ab1187d 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -16,20 +16,13 @@ //---------------------------------------------------------------------------- cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator() { + this->VersionId = "MSVC11"; this->FindMakeProgramFile = "CMakeVS11FindMake.cmake"; this->ExpressEdition = false; // TODO: VS 11 Express support 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) { fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n"; diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h index 7e8f6aa..56337a4 100644 --- a/Source/cmGlobalVisualStudio11Generator.h +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -28,7 +28,6 @@ public: virtual const char* GetName() const { return cmGlobalVisualStudio11Generator::GetActualName();} static const char* GetActualName() {return "Visual Studio 11";} - virtual void AddPlatformDefinitions(cmMakefile* mf); virtual void WriteSLNHeader(std::ostream& fout); diff --git a/Source/cmGlobalVisualStudio11Win64Generator.cxx b/Source/cmGlobalVisualStudio11Win64Generator.cxx index 10c9027..94e07bf 100644 --- a/Source/cmGlobalVisualStudio11Win64Generator.cxx +++ b/Source/cmGlobalVisualStudio11Win64Generator.cxx @@ -14,6 +14,12 @@ #include "cmake.h" //---------------------------------------------------------------------------- +cmGlobalVisualStudio11Win64Generator::cmGlobalVisualStudio11Win64Generator() +{ + this->ArchitectureId = "x64"; +} + +//---------------------------------------------------------------------------- void cmGlobalVisualStudio11Win64Generator ::GetDocumentation(cmDocumentationEntry& entry) const { @@ -28,6 +34,4 @@ void cmGlobalVisualStudio11Win64Generator { this->cmGlobalVisualStudio11Generator::AddPlatformDefinitions(mf); mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE"); - mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "x64"); - mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "x64"); } diff --git a/Source/cmGlobalVisualStudio11Win64Generator.h b/Source/cmGlobalVisualStudio11Win64Generator.h index 53f1953..9445d15 100644 --- a/Source/cmGlobalVisualStudio11Win64Generator.h +++ b/Source/cmGlobalVisualStudio11Win64Generator.h @@ -18,7 +18,7 @@ class cmGlobalVisualStudio11Win64Generator : public cmGlobalVisualStudio11Generator { public: - cmGlobalVisualStudio11Win64Generator() {} + cmGlobalVisualStudio11Win64Generator(); static cmGlobalGenerator* New() { return new cmGlobalVisualStudio11Win64Generator; } diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index cc70341..ca06b66 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -32,6 +32,7 @@ std::string GetVS6TargetName(const std::string& targetName) cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator() { + this->VersionId = "MSVC60"; this->FindMakeProgramFile = "CMakeVS6FindMake.cmake"; } @@ -40,14 +41,12 @@ void cmGlobalVisualStudio6Generator cmMakefile *mf, bool optional) { + cmGlobalVisualStudioGenerator::AddPlatformDefinitions(mf); mf->AddDefinition("CMAKE_GENERATOR_CC", "cl"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl"); mf->AddDefinition("CMAKE_GENERATOR_RC", "rc"); mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); 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->cmGlobalGenerator::EnableLanguage(lang, mf, optional); } diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 1da575e..d99fa03 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -18,6 +18,7 @@ //---------------------------------------------------------------------------- cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator() { + this->VersionId = "MSVC71"; this->FindMakeProgramFile = "CMakeVS71FindMake.cmake"; this->ProjectConfigurationSectionName = "ProjectConfiguration"; } @@ -34,14 +35,6 @@ cmLocalGenerator *cmGlobalVisualStudio71Generator::CreateLocalGenerator() } //---------------------------------------------------------------------------- -void cmGlobalVisualStudio71Generator::AddPlatformDefinitions(cmMakefile* mf) -{ - this->cmGlobalVisualStudio7Generator::AddPlatformDefinitions(mf); - mf->RemoveDefinition("MSVC70"); - mf->AddDefinition("MSVC71", "1"); -} - -//---------------------------------------------------------------------------- std::string cmGlobalVisualStudio71Generator::GetUserMacrosDirectory() { // Macros not supported on Visual Studio 7.1 and earlier because diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index 285f202..a8daad6 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -53,7 +53,6 @@ public: protected: virtual const char* GetIDEVersion() { return "7.1"; } - virtual void AddPlatformDefinitions(cmMakefile* mf); virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root, std::vector& generators); diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index d485d6e..0567d55 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -18,6 +18,7 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator() { + this->VersionId = "MSVC70"; 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 ::GenerateBuildCommand(const char* makeProgram, const char *projectName, diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 9b9107d..1df58f9 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -112,7 +112,6 @@ protected: virtual void WriteSLNFooter(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout); virtual std::string WriteUtilityDepend(cmTarget* target); - virtual void AddPlatformDefinitions(cmMakefile* mf); virtual void WriteTargetsToSolution( std::ostream& fout, diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index a74a4ee..f469188 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -19,9 +19,9 @@ //---------------------------------------------------------------------------- cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator() { + this->VersionId = "MSVC80"; this->FindMakeProgramFile = "CMakeVS8FindMake.cmake"; this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms"; - this->ArchitectureId = "X86"; } //---------------------------------------------------------------------------- @@ -54,14 +54,6 @@ void cmGlobalVisualStudio8Generator } //---------------------------------------------------------------------------- -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() { this->cmGlobalVisualStudio7Generator::Configure(); diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index 31501bc..5009f29 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -72,7 +72,6 @@ protected: void AddCheckTarget(); static cmIDEFlagTable const* GetExtraFlagTableVS8(); - virtual void AddPlatformDefinitions(cmMakefile* mf); virtual void WriteSLNHeader(std::ostream& fout); virtual void WriteSolutionConfigurations(std::ostream& fout); virtual void WriteProjectConfigurations(std::ostream& fout, @@ -82,7 +81,5 @@ protected: virtual bool ComputeTargetDepends(); virtual void WriteProjectDepends(std::ostream& fout, const char* name, const char* path, cmTarget &t); - - const char* ArchitectureId; }; #endif diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index fcf00d5..531395b 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -19,18 +19,11 @@ cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator() { + this->VersionId = "MSVC90"; 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) { fout << "Microsoft Visual Studio Solution File, Format Version 10.00\n"; diff --git a/Source/cmGlobalVisualStudio9Generator.h b/Source/cmGlobalVisualStudio9Generator.h index 361b58c..0b0d143 100644 --- a/Source/cmGlobalVisualStudio9Generator.h +++ b/Source/cmGlobalVisualStudio9Generator.h @@ -32,7 +32,6 @@ public: virtual const char* GetName() const { return cmGlobalVisualStudio9Generator::GetActualName();} static const char* GetActualName() {return "Visual Studio 9 2008";} - virtual void AddPlatformDefinitions(cmMakefile* mf); /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry) const; diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index a2b4c65..feb3ac9 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -21,6 +21,8 @@ //---------------------------------------------------------------------------- cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator() { + this->ArchitectureId = "X86"; + this->VersionId = 0; } //---------------------------------------------------------------------------- @@ -489,6 +491,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) { UtilityDependsMap::iterator i = this->UtilityDepends.find(target); diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 27fc8cf..a042dc0 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -84,6 +84,8 @@ protected: virtual const char* GetIDEVersion() = 0; + virtual void AddPlatformDefinitions(cmMakefile* mf); + virtual bool ComputeTargetDepends(); class VSDependSet: public std::set {}; class VSDependMap: public std::map {}; @@ -96,6 +98,9 @@ protected: std::string GetUtilityDepend(cmTarget* target); typedef std::map UtilityDependsMap; UtilityDependsMap UtilityDepends; + const char* ArchitectureId; + const char* VersionId; + private: void ComputeTargetObjects(cmGeneratorTarget* gt) const; -- cgit v0.12