From ecb34faaaba841aac6dae722dd2c6256a1472d74 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 17 Jul 2014 15:05:17 -0400 Subject: [PATCH 1/6] Tell generators about CMAKE_SYSTEM_NAME as soon as it is known Add a cmGlobalGenerator::SetSystemName virtual method. Call it from cmGlobalGenerator::EnableLanguage as soon as CMAKE_SYSTEM_NAME is known. This will give generators a chance to adapt themselves to the target system. Pass the cmMakefile instance to the method so that the generator can update it accordingly. Return early from EnableLanguage if SetSystemName returns false. --- Source/cmGlobalGenerator.cxx | 8 ++++++++ Source/cmGlobalGenerator.h | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 36932aacd..6d737b165 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -448,6 +448,14 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, mf->ReadListFile(0,fpath.c_str()); } + // Tell the generator about the target system. + std::string system = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME"); + if(!this->SetSystemName(system, mf)) + { + cmSystemTools::SetFatalErrorOccured(); + return; + } + // Tell the generator about the toolset, if any. std::string toolset = mf->GetSafeDefinition("CMAKE_GENERATOR_TOOLSET"); if(!toolset.empty() && diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 5e6c03e8d..ee3f2692c 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -61,6 +61,10 @@ public: virtual bool MatchesGeneratorName(const std::string& name) const { return this->GetName() == name; } + /** Tell the generator about the target system. */ + virtual bool SetSystemName(std::string const&, cmMakefile*) + { return true; } + /** Set the generator-specific toolset name. Returns true if toolset is supported and false otherwise. */ virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf); From eeb60102e813c6c69546e4257a332ede4e234171 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 17 Jul 2014 16:16:10 -0400 Subject: [PATCH 2/6] VS: Refactor CMAKE_FORCE_*64 platform definitions Remove the general infrastructure for these additional platform definitions and hard-code the only two special cases that used it. They are only for historical reasons so no new such cases should be added. --- Source/cmGlobalVisualStudio10Generator.cxx | 12 +++++------- Source/cmGlobalVisualStudio10Generator.h | 3 +-- Source/cmGlobalVisualStudio11Generator.cxx | 14 ++++++-------- Source/cmGlobalVisualStudio11Generator.h | 3 +-- Source/cmGlobalVisualStudio12Generator.cxx | 12 +++++------- Source/cmGlobalVisualStudio12Generator.h | 3 +-- Source/cmGlobalVisualStudio14Generator.cxx | 12 +++++------- Source/cmGlobalVisualStudio14Generator.h | 3 +-- Source/cmGlobalVisualStudio6Generator.cxx | 1 - Source/cmGlobalVisualStudio7Generator.cxx | 9 ++++++++- Source/cmGlobalVisualStudio8Generator.cxx | 14 ++++---------- Source/cmGlobalVisualStudio8Generator.h | 3 +-- Source/cmGlobalVisualStudio9Generator.cxx | 14 ++++++-------- Source/cmGlobalVisualStudio9Generator.h | 3 +-- Source/cmGlobalVisualStudioGenerator.cxx | 10 ---------- Source/cmGlobalVisualStudioGenerator.h | 3 --- 16 files changed, 45 insertions(+), 74 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index a6d1c3189..80d08b99a 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -51,19 +51,19 @@ public: if(!*p) { return new cmGlobalVisualStudio10Generator( - genName, "", ""); + genName, ""); } if(*p++ != ' ') { return 0; } if(strcmp(p, "Win64") == 0) { return new cmGlobalVisualStudio10Generator( - genName, "x64", "CMAKE_FORCE_WIN64"); + genName, "x64"); } if(strcmp(p, "IA64") == 0) { return new cmGlobalVisualStudio10Generator( - genName, "Itanium", "CMAKE_FORCE_IA64"); + genName, "Itanium"); } return 0; } @@ -90,10 +90,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio10Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( - const std::string& name, const std::string& platformName, - const std::string& additionalPlatformDefinition) - : cmGlobalVisualStudio8Generator(name, platformName, - additionalPlatformDefinition) + const std::string& name, const std::string& platformName) + : cmGlobalVisualStudio8Generator(name, platformName) { std::string vc10Express; this->ExpressEdition = cmSystemTools::ReadRegistryValue( diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index b4dcc7e0f..107b646f9 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -25,8 +25,7 @@ class cmGlobalVisualStudio10Generator : { public: cmGlobalVisualStudio10Generator(const std::string& name, - const std::string& platformName, - const std::string& additionalPlatformDefinition); + const std::string& platformName); static cmGlobalGeneratorFactory* NewFactory(); virtual bool MatchesGeneratorName(const std::string& name) const; diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index fa134fc47..0bd51eab5 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -46,19 +46,19 @@ public: if(!*p) { return new cmGlobalVisualStudio11Generator( - genName, "", ""); + genName, ""); } if(*p++ != ' ') { return 0; } if(strcmp(p, "Win64") == 0) { return new cmGlobalVisualStudio11Generator( - genName, "x64", "CMAKE_FORCE_WIN64"); + genName, "x64"); } if(strcmp(p, "ARM") == 0) { return new cmGlobalVisualStudio11Generator( - genName, "ARM", ""); + genName, "ARM"); } std::set installedSDKs = @@ -70,7 +70,7 @@ public: } cmGlobalVisualStudio11Generator* ret = - new cmGlobalVisualStudio11Generator(name, p, NULL); + new cmGlobalVisualStudio11Generator(name, p); ret->WindowsCEVersion = "8.00"; return ret; } @@ -105,10 +105,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio11Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator( - const std::string& name, const std::string& platformName, - const std::string& additionalPlatformDefinition) - : cmGlobalVisualStudio10Generator(name, platformName, - additionalPlatformDefinition) + const std::string& name, const std::string& platformName) + : cmGlobalVisualStudio10Generator(name, platformName) { std::string vc11Express; this->ExpressEdition = cmSystemTools::ReadRegistryValue( diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h index 48ea4891d..3d89a9408 100644 --- a/Source/cmGlobalVisualStudio11Generator.h +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -21,8 +21,7 @@ class cmGlobalVisualStudio11Generator: { public: cmGlobalVisualStudio11Generator(const std::string& name, - const std::string& platformName, - const std::string& additionalPlatformDefinition); + const std::string& platformName); static cmGlobalGeneratorFactory* NewFactory(); virtual bool MatchesGeneratorName(const std::string& name) const; diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index 698624ddf..47c43faec 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -46,19 +46,19 @@ public: if(!*p) { return new cmGlobalVisualStudio12Generator( - genName, "", ""); + genName, ""); } if(*p++ != ' ') { return 0; } if(strcmp(p, "Win64") == 0) { return new cmGlobalVisualStudio12Generator( - genName, "x64", "CMAKE_FORCE_WIN64"); + genName, "x64"); } if(strcmp(p, "ARM") == 0) { return new cmGlobalVisualStudio12Generator( - genName, "ARM", ""); + genName, "ARM"); } return 0; } @@ -85,10 +85,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio12Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator( - const std::string& name, const std::string& platformName, - const std::string& additionalPlatformDefinition) - : cmGlobalVisualStudio11Generator(name, platformName, - additionalPlatformDefinition) + const std::string& name, const std::string& platformName) + : cmGlobalVisualStudio11Generator(name, platformName) { std::string vc12Express; this->ExpressEdition = cmSystemTools::ReadRegistryValue( diff --git a/Source/cmGlobalVisualStudio12Generator.h b/Source/cmGlobalVisualStudio12Generator.h index 4557f28d0..8ac2d1d20 100644 --- a/Source/cmGlobalVisualStudio12Generator.h +++ b/Source/cmGlobalVisualStudio12Generator.h @@ -21,8 +21,7 @@ class cmGlobalVisualStudio12Generator: { public: cmGlobalVisualStudio12Generator(const std::string& name, - const std::string& platformName, - const std::string& additionalPlatformDefinition); + const std::string& platformName); static cmGlobalGeneratorFactory* NewFactory(); virtual bool MatchesGeneratorName(const std::string& name) const; diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index 9bde0ade9..076b057c8 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -31,19 +31,19 @@ public: if(!*p) { return new cmGlobalVisualStudio14Generator( - genName, "", ""); + genName, ""); } if(*p++ != ' ') { return 0; } if(strcmp(p, "Win64") == 0) { return new cmGlobalVisualStudio14Generator( - genName, "x64", "CMAKE_FORCE_WIN64"); + genName, "x64"); } if(strcmp(p, "ARM") == 0) { return new cmGlobalVisualStudio14Generator( - genName, "ARM", ""); + genName, "ARM"); } return 0; } @@ -70,10 +70,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio14Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio14Generator::cmGlobalVisualStudio14Generator( - const std::string& name, const std::string& platformName, - const std::string& additionalPlatformDefinition) - : cmGlobalVisualStudio12Generator(name, platformName, - additionalPlatformDefinition) + const std::string& name, const std::string& platformName) + : cmGlobalVisualStudio12Generator(name, platformName) { std::string vc14Express; this->ExpressEdition = cmSystemTools::ReadRegistryValue( diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h index 707411901..3fd60a0bb 100644 --- a/Source/cmGlobalVisualStudio14Generator.h +++ b/Source/cmGlobalVisualStudio14Generator.h @@ -21,8 +21,7 @@ class cmGlobalVisualStudio14Generator: { public: cmGlobalVisualStudio14Generator(const std::string& name, - const std::string& platformName, - const std::string& additionalPlatformDefinition); + const std::string& platformName); static cmGlobalGeneratorFactory* NewFactory(); virtual bool MatchesGeneratorName(const std::string& name) const; diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 7397bbb95..455a7a2d9 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -41,7 +41,6 @@ void cmGlobalVisualStudio6Generator cmMakefile *mf, bool optional) { - cmGlobalVisualStudioGenerator::AddPlatformDefinitions(mf); mf->AddDefinition("CMAKE_GENERATOR_RC", "rc"); mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); this->GenerateConfigurations(mf); diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index a918d1df6..759e81e0d 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -262,7 +262,14 @@ cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator() //---------------------------------------------------------------------------- void cmGlobalVisualStudio7Generator::AddPlatformDefinitions(cmMakefile* mf) { - cmGlobalVisualStudioGenerator::AddPlatformDefinitions(mf); + if(this->PlatformName == "x64") + { + mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE"); + } + else if(this->PlatformName == "Itanium") + { + mf->AddDefinition("CMAKE_FORCE_IA64", "TRUE"); + } mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName().c_str()); mf->AddDefinition("CMAKE_VS_INTEL_Fortran_PROJECT_VERSION", this->GetIntelProjectVersion()); diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index e6672a816..67583de48 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -36,7 +36,7 @@ public: if(p[0] == '\0') { return new cmGlobalVisualStudio8Generator( - name, "", ""); + name, ""); } if(p[0] != ' ') @@ -49,7 +49,7 @@ public: if(!strcmp(p, "Win64")) { return new cmGlobalVisualStudio8Generator( - name, "x64", "CMAKE_FORCE_WIN64"); + name, "x64"); } cmVisualStudioWCEPlatformParser parser(p); @@ -60,7 +60,7 @@ public: } cmGlobalVisualStudio8Generator* ret = new cmGlobalVisualStudio8Generator( - name, p, ""); + name, p); ret->WindowsCEVersion = parser.GetOSVersion(); return ret; } @@ -93,17 +93,11 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio8Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator( - const std::string& name, const std::string& platformName, - const std::string& additionalPlatformDefinition) + const std::string& name, const std::string& platformName) : cmGlobalVisualStudio71Generator(platformName) { this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms"; this->Name = name; - - if (!additionalPlatformDefinition.empty()) - { - this->AdditionalPlatformDefinition = additionalPlatformDefinition; - } } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index 2459c05a5..07bcceec0 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -24,8 +24,7 @@ class cmGlobalVisualStudio8Generator : public cmGlobalVisualStudio71Generator { public: cmGlobalVisualStudio8Generator(const std::string& name, - const std::string& platformName, - const std::string& additionalPlatformDefinition); + const std::string& platformName); static cmGlobalGeneratorFactory* NewFactory(); ///! Get the name for the generator. diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index c0051c723..45608e18c 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -34,7 +34,7 @@ public: if(p[0] == '\0') { return new cmGlobalVisualStudio9Generator( - name, "", ""); + name, ""); } if(p[0] != ' ') @@ -47,13 +47,13 @@ public: if(!strcmp(p, "IA64")) { return new cmGlobalVisualStudio9Generator( - name, "Itanium", "CMAKE_FORCE_IA64"); + name, "Itanium"); } if(!strcmp(p, "Win64")) { return new cmGlobalVisualStudio9Generator( - name, "x64", "CMAKE_FORCE_WIN64"); + name, "x64"); } cmVisualStudioWCEPlatformParser parser(p); @@ -64,7 +64,7 @@ public: } cmGlobalVisualStudio9Generator* ret = new cmGlobalVisualStudio9Generator( - name, p, NULL); + name, p); ret->WindowsCEVersion = parser.GetOSVersion(); return ret; } @@ -98,10 +98,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator( - const std::string& name, const std::string& platformName, - const std::string& additionalPlatformDefinition) - : cmGlobalVisualStudio8Generator(name, platformName, - additionalPlatformDefinition) + const std::string& name, const std::string& platformName) + : cmGlobalVisualStudio8Generator(name, platformName) { } diff --git a/Source/cmGlobalVisualStudio9Generator.h b/Source/cmGlobalVisualStudio9Generator.h index fb87bbefa..f1c7091bd 100644 --- a/Source/cmGlobalVisualStudio9Generator.h +++ b/Source/cmGlobalVisualStudio9Generator.h @@ -25,8 +25,7 @@ class cmGlobalVisualStudio9Generator : { public: cmGlobalVisualStudio9Generator(const std::string& name, - const std::string& platformName, - const std::string& additionalPlatformDefinition); + const std::string& platformName); static cmGlobalGeneratorFactory* NewFactory(); ///! create the correct local generator diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index c5a0e29e7..2dab23c1b 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -23,7 +23,6 @@ //---------------------------------------------------------------------------- cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator() { - this->AdditionalPlatformDefinition = ""; } //---------------------------------------------------------------------------- @@ -477,15 +476,6 @@ void cmGlobalVisualStudioGenerator::FindMakeProgram(cmMakefile* mf) } } -//---------------------------------------------------------------------------- -void cmGlobalVisualStudioGenerator::AddPlatformDefinitions(cmMakefile* mf) -{ - if(!this->AdditionalPlatformDefinition.empty()) - { - mf->AddDefinition(this->AdditionalPlatformDefinition, "TRUE"); - } -} - //---------------------------------------------------------------------------- std::string cmGlobalVisualStudioGenerator::GetUtilityDepend(cmTarget const* target) diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 1ab899097..05dbb11b5 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -97,8 +97,6 @@ protected: virtual const char* GetIDEVersion() = 0; - virtual void AddPlatformDefinitions(cmMakefile* mf); - virtual bool ComputeTargetDepends(); class VSDependSet: public std::set {}; class VSDependMap: public std::map {}; @@ -111,7 +109,6 @@ protected: std::string GetUtilityDepend(cmTarget const* target); typedef std::map UtilityDependsMap; UtilityDependsMap UtilityDepends; - std::string AdditionalPlatformDefinition; private: virtual std::string GetVSMakeProgram() = 0; From d3d9218a52dad04c1cfa87e537d98ee0678db1db Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 17 Jul 2014 16:19:27 -0400 Subject: [PATCH 3/6] VS: Remove unused method from VS 9 generator --- Source/cmGlobalVisualStudio9Generator.cxx | 8 -------- Source/cmGlobalVisualStudio9Generator.h | 2 -- 2 files changed, 10 deletions(-) diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index 45608e18c..00d9179d1 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -121,14 +121,6 @@ cmLocalGenerator *cmGlobalVisualStudio9Generator::CreateLocalGenerator() return lg; } -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio9Generator -::EnableLanguage(std::vectorconst & lang, - cmMakefile *mf, bool optional) -{ - cmGlobalVisualStudio8Generator::EnableLanguage(lang, mf, optional); -} - //---------------------------------------------------------------------------- std::string cmGlobalVisualStudio9Generator::GetUserMacrosDirectory() { diff --git a/Source/cmGlobalVisualStudio9Generator.h b/Source/cmGlobalVisualStudio9Generator.h index f1c7091bd..c24d5fed8 100644 --- a/Source/cmGlobalVisualStudio9Generator.h +++ b/Source/cmGlobalVisualStudio9Generator.h @@ -35,8 +35,6 @@ public: * Try to determine system infomation such as shared library * extension, pthreads, byte order etc. */ - virtual void EnableLanguage(std::vectorconst& languages, - cmMakefile *, bool optional); virtual void WriteSLNHeader(std::ostream& fout); /** From 6e176e6d9efa80fb4d08f1ead6bc33f115f8885d Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 17 Jul 2014 16:34:21 -0400 Subject: [PATCH 4/6] VS: Delay platform definitions until system name is known Move the definition of CMAKE_VS_PLATFORM_NAME and other variables that are not needed by CMakeDetermineSystem out of the AddPlatformDefinitions method and into a SetSystemName method. The latter may later use CMAKE_SYSTEM_NAME to decide what platform-specific definitions to add. --- Source/cmGlobalVisualStudio10Generator.cxx | 5 +++-- Source/cmGlobalVisualStudio10Generator.h | 3 +-- Source/cmGlobalVisualStudio7Generator.cxx | 5 +++-- Source/cmGlobalVisualStudio7Generator.h | 2 +- Source/cmGlobalVisualStudio8Generator.cxx | 11 +++++++++-- Source/cmGlobalVisualStudio8Generator.h | 2 ++ 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 80d08b99a..03b2b2f09 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -125,10 +125,11 @@ cmGlobalVisualStudio10Generator::SetGeneratorToolset(std::string const& ts, } //---------------------------------------------------------------------------- -void cmGlobalVisualStudio10Generator::AddPlatformDefinitions(cmMakefile* mf) +bool cmGlobalVisualStudio10Generator::SetSystemName(std::string const& s, + cmMakefile* mf) { - cmGlobalVisualStudio8Generator::AddPlatformDefinitions(mf); this->AddVSPlatformToolsetDefinition(mf); + return this->cmGlobalVisualStudio8Generator::SetSystemName(s, mf); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 107b646f9..cb639dd83 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -31,6 +31,7 @@ public: virtual bool MatchesGeneratorName(const std::string& name) const; virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf); + virtual bool SetSystemName(std::string const& s, cmMakefile* mf); virtual void GenerateBuildCommand( std::vector& makeCommand, @@ -43,8 +44,6 @@ public: std::vector const& makeOptions = std::vector() ); - virtual void AddPlatformDefinitions(cmMakefile* mf); - ///! create the correct local generator virtual cmLocalGenerator *CreateLocalGenerator(); diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 759e81e0d..602d67804 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -80,7 +80,6 @@ void cmGlobalVisualStudio7Generator { mf->AddDefinition("CMAKE_GENERATOR_RC", "rc"); mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); - this->AddPlatformDefinitions(mf); if(!mf->GetDefinition("CMAKE_CONFIGURATION_TYPES")) { mf->AddCacheDefinition( @@ -260,7 +259,8 @@ cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator() } //---------------------------------------------------------------------------- -void cmGlobalVisualStudio7Generator::AddPlatformDefinitions(cmMakefile* mf) +bool cmGlobalVisualStudio7Generator::SetSystemName(std::string const& s, + cmMakefile* mf) { if(this->PlatformName == "x64") { @@ -273,6 +273,7 @@ void cmGlobalVisualStudio7Generator::AddPlatformDefinitions(cmMakefile* mf) mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName().c_str()); mf->AddDefinition("CMAKE_VS_INTEL_Fortran_PROJECT_VERSION", this->GetIntelProjectVersion()); + return this->cmGlobalVisualStudioGenerator::SetSystemName(s, mf); } void cmGlobalVisualStudio7Generator::GenerateConfigurations(cmMakefile* mf) diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 291d2974d..bd844333b 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -44,7 +44,7 @@ public: ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); - virtual void AddPlatformDefinitions(cmMakefile* mf); + virtual bool SetSystemName(std::string const& s, cmMakefile* mf); /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 67583de48..1bac3223e 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -132,11 +132,18 @@ cmLocalGenerator *cmGlobalVisualStudio8Generator::CreateLocalGenerator() return lg; } +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio8Generator +::EnableLanguage(std::vectorconst & lang, + cmMakefile *mf, bool optional) +{ + this->AddPlatformDefinitions(mf); + cmGlobalVisualStudio7Generator::EnableLanguage(lang, mf, optional); +} + //---------------------------------------------------------------------------- void cmGlobalVisualStudio8Generator::AddPlatformDefinitions(cmMakefile* mf) { - cmGlobalVisualStudio71Generator::AddPlatformDefinitions(mf); - if(this->TargetsWindowsCE()) { mf->AddDefinition("CMAKE_VS_WINCE_VERSION", diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index 07bcceec0..aea2f012e 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -36,6 +36,8 @@ public: ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); + virtual void EnableLanguage(std::vectorconst& languages, + cmMakefile *, bool optional); virtual void AddPlatformDefinitions(cmMakefile* mf); /** From e7fdb44b1be63e18d03e86f61611dba677e98978 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 17 Jul 2014 16:35:41 -0400 Subject: [PATCH 5/6] VS: Delay detection of VS 10 Express 64-bit tools Wait until SetSystemName when the CMAKE_SYSTEM_NAME is known. Later the decision to use 64-bit tools may depend on it. --- Source/cmGlobalVisualStudio10Generator.cxx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 03b2b2f09..043f89ddc 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -128,6 +128,13 @@ cmGlobalVisualStudio10Generator::SetGeneratorToolset(std::string const& ts, bool cmGlobalVisualStudio10Generator::SetSystemName(std::string const& s, cmMakefile* mf) { + if(this->PlatformName == "Itanium" || this->PlatformName == "x64") + { + if(this->IsExpressEdition() && !this->Find64BitTools(mf)) + { + return false; + } + } this->AddVSPlatformToolsetDefinition(mf); return this->cmGlobalVisualStudio8Generator::SetSystemName(s, mf); } @@ -203,14 +210,6 @@ void cmGlobalVisualStudio10Generator ::EnableLanguage(std::vectorconst & lang, cmMakefile *mf, bool optional) { - if(this->PlatformName == "Itanium" || this->PlatformName == "x64") - { - if(this->IsExpressEdition() && !this->Find64BitTools(mf)) - { - return; - } - } - for(std::vector::const_iterator it = lang.begin(); it != lang.end(); ++it) { From 7a526c35f60ced43606bf028a21dedfaac77c2e9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 17 Jul 2014 16:58:34 -0400 Subject: [PATCH 6/6] VS: Delay getting platform name in local generator Ask the global generator during generation instead of trying to store it up front. Later the global generator may not know the platform name when it is creating the local generator. --- Source/cmGlobalVisualStudio10Generator.cxx | 1 - Source/cmGlobalVisualStudio11Generator.cxx | 1 - Source/cmGlobalVisualStudio12Generator.cxx | 1 - Source/cmGlobalVisualStudio14Generator.cxx | 1 - Source/cmGlobalVisualStudio8Generator.cxx | 1 - Source/cmGlobalVisualStudio9Generator.cxx | 1 - Source/cmLocalVisualStudio7Generator.cxx | 24 ++++++++++++++-------- Source/cmLocalVisualStudio7Generator.h | 3 --- 8 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 043f89ddc..c1b087a94 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -168,7 +168,6 @@ cmLocalGenerator *cmGlobalVisualStudio10Generator::CreateLocalGenerator() { cmLocalVisualStudio10Generator* lg = new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS10); - lg->SetPlatformName(this->GetPlatformName()); lg->SetGlobalGenerator(this); return lg; } diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index 0bd51eab5..e5a159ba1 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -147,7 +147,6 @@ cmLocalGenerator *cmGlobalVisualStudio11Generator::CreateLocalGenerator() { cmLocalVisualStudio10Generator* lg = new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS11); - lg->SetPlatformName(this->GetPlatformName()); lg->SetGlobalGenerator(this); return lg; } diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index 47c43faec..4235cbc7c 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -127,7 +127,6 @@ cmLocalGenerator *cmGlobalVisualStudio12Generator::CreateLocalGenerator() { cmLocalVisualStudio10Generator* lg = new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS12); - lg->SetPlatformName(this->GetPlatformName()); lg->SetGlobalGenerator(this); return lg; } diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index 076b057c8..d001f9316 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -108,7 +108,6 @@ cmLocalGenerator *cmGlobalVisualStudio14Generator::CreateLocalGenerator() { cmLocalVisualStudio10Generator* lg = new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS14); - lg->SetPlatformName(this->GetPlatformName()); lg->SetGlobalGenerator(this); return lg; } diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 1bac3223e..9fd3d5af6 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -126,7 +126,6 @@ cmLocalGenerator *cmGlobalVisualStudio8Generator::CreateLocalGenerator() { cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS8); - lg->SetPlatformName(this->GetPlatformName()); lg->SetExtraFlagTable(this->GetExtraFlagTableVS8()); lg->SetGlobalGenerator(this); return lg; diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index 00d9179d1..1d73b5c08 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -115,7 +115,6 @@ cmLocalGenerator *cmGlobalVisualStudio9Generator::CreateLocalGenerator() { cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS9); - lg->SetPlatformName(this->GetPlatformName()); lg->SetExtraFlagTable(this->GetExtraFlagTableVS8()); lg->SetGlobalGenerator(this); return lg; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index a6c6e8d65..e0fe0fd60 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -48,7 +48,6 @@ extern cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[]; cmLocalVisualStudio7Generator::cmLocalVisualStudio7Generator(VSVersion v): cmLocalVisualStudioGenerator(v) { - this->PlatformName = "Win32"; this->ExtraFlagTable = 0; this->Internal = new cmLocalVisualStudio7GeneratorInternals(this); } @@ -647,8 +646,11 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, { mfcFlag = "0"; } + cmGlobalVisualStudio7Generator* gg = + static_cast(this->GlobalGenerator); fout << "\t\tPlatformName << "\"\n" + << "\t\t\tName=\"" << configName + << "|" << gg->GetPlatformName() << "\"\n" << "\t\t\tOutputDirectory=\"" << configName << "\"\n"; // This is an internal type to Visual Studio, it seems that: // 4 == static library @@ -896,11 +898,11 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, } fout << "\"\n"; fout << "\t\t\t\tMkTypLibCompatible=\"false\"\n"; - if( this->PlatformName == "x64" ) + if( gg->GetPlatformName() == "x64" ) { fout << "\t\t\t\tTargetEnvironment=\"3\"\n"; } - else if( this->PlatformName == "ia64" ) + else if( gg->GetPlatformName() == "ia64" ) { fout << "\t\t\t\tTargetEnvironment=\"2\"\n"; } @@ -1640,6 +1642,8 @@ bool cmLocalVisualStudio7Generator std::ostream &fout, const std::string& libName, std::vector *configs) { + cmGlobalVisualStudio7Generator* gg = + static_cast(this->GlobalGenerator); const std::vector &sourceFiles = sg->GetSourceFiles(); std::vector const& children = sg->GetGroupChildren(); @@ -1730,7 +1734,7 @@ bool cmLocalVisualStudio7Generator cmLVS7GFileConfig const& fc = fci->second; fout << "\t\t\t\tfirst - << "|" << this->PlatformName << "\""; + << "|" << gg->GetPlatformName() << "\""; if(fc.ExcludedFromBuild) { fout << " ExcludedFromBuild=\"true\""; @@ -1800,6 +1804,9 @@ WriteCustomRule(std::ostream& fout, const cmCustomCommand& command, FCInfo& fcinfo) { + cmGlobalVisualStudio7Generator* gg = + static_cast(this->GlobalGenerator); + // Write the rule for each configuration. std::vector::iterator i; std::vector *configs = @@ -1820,7 +1827,8 @@ WriteCustomRule(std::ostream& fout, cmCustomCommandGenerator ccg(command, *i, this->Makefile); cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[*i]; fout << "\t\t\t\tPlatformName << "\">\n"; + fout << "\t\t\t\t\tName=\"" << *i << "|" + << gg->GetPlatformName() << "\">\n"; if(!fc.CompileFlags.empty()) { fout << "\t\t\t\t\t\n" << "\tProjectGUID=\"{" << gg->GetGUID(libName.c_str()) << "}\">\n" << "\t\n" - << "\t\tPlatformName << "\"/>\n" + << "\t\tGetPlatformName() << "\"/>\n" << "\t\n"; } @@ -2085,7 +2093,7 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, } fout << "\tKeyword=\"" << keyword << "\">\n" << "\t\n" - << "\t\tPlatformName << "\"/>\n" + << "\t\tGetPlatformName() << "\"/>\n" << "\t\n"; } diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 6c045594a..c2caa26f3 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -53,8 +53,6 @@ public: */ void SetBuildType(BuildType,const std::string& name); - void SetPlatformName(const std::string& n) { this->PlatformName = n;} - void SetExtraFlagTable(cmVS7FlagTable const* table) { this->ExtraFlagTable = table; } virtual std::string GetTargetDirectory(cmTarget const&) const; @@ -124,7 +122,6 @@ private: std::string ModuleDefinitionFile; bool FortranProject; bool WindowsCEProject; - std::string PlatformName; // Win32 or x64 cmLocalVisualStudio7GeneratorInternals* Internal; };