diff options
author | Brad King <brad.king@kitware.com> | 2014-09-10 15:23:22 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2014-09-10 15:23:22 (GMT) |
commit | 0a92b23c52675bf8fe93cb9959266a49ab509ac1 (patch) | |
tree | 0f7a40cbf62c8fbbb6b19843a118faa942ce9a51 /Source | |
parent | 2bfe48d6af963472fbd4073f729669306eccac69 (diff) | |
parent | 09c8ad99433df06ed36791bfaef97996cd2de04e (diff) | |
download | CMake-0a92b23c52675bf8fe93cb9959266a49ab509ac1.zip CMake-0a92b23c52675bf8fe93cb9959266a49ab509ac1.tar.gz CMake-0a92b23c52675bf8fe93cb9959266a49ab509ac1.tar.bz2 |
Merge topic 'vs-generator-platform'
09c8ad99 enable_language: Initialize system-specific generator info only once
09ab207c Tests: Add generator platform support
6944997b ExternalProject: Propagate the generator platform
8d332091 CTest: Add options to set generator platform
b97736a2 VS: Implement CMAKE_GENERATOR_PLATFORM for VS >= 8
0f1f1271 CMake: Add CMAKE_GENERATOR_PLATFORM option
4f7d0c42 Help: Document CMAKE_VS_PLATFORM_NAME variable
68d4280a VS: Refactor internal default platform name selection
ad2a4776 cmGlobalVisualStudio10Generator: Re-order some methods
03b7b6cd cmGlobalGenerator: Call SetGeneratorToolset even for empty toolset
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CTest/cmCTestBuildAndTestHandler.cxx | 13 | ||||
-rw-r--r-- | Source/CTest/cmCTestBuildAndTestHandler.h | 1 | ||||
-rw-r--r-- | Source/CTest/cmCTestConfigureCommand.cxx | 9 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 85 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.h | 4 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.cxx | 50 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.h | 4 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio7Generator.cxx | 31 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio7Generator.h | 7 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio8Generator.cxx | 15 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio8Generator.h | 2 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 7 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 1 | ||||
-rw-r--r-- | Source/cmake.cxx | 28 | ||||
-rw-r--r-- | Source/cmake.h | 9 | ||||
-rw-r--r-- | Source/ctest.cxx | 1 |
16 files changed, 208 insertions, 59 deletions
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index 627832c..ece4697 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -68,6 +68,12 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, generator += this->BuildGenerator; args.push_back(generator); } + if(!this->BuildGeneratorPlatform.empty()) + { + std::string platform = "-DCMAKE_GENERATOR_PLATFORM="; + platform += this->BuildGeneratorPlatform; + args.push_back(platform); + } if(this->BuildGeneratorToolset.size()) { std::string toolset = "-T"; @@ -246,6 +252,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) // Make the generator available for the Build call below. cm.SetGlobalGenerator(cm.CreateGlobalGenerator( this->BuildGenerator)); + cm.SetGeneratorPlatform(this->BuildGeneratorPlatform); cm.SetGeneratorToolset(this->BuildGeneratorToolset); // Load the cache to make CMAKE_MAKE_PROGRAM available. @@ -490,6 +497,12 @@ int cmCTestBuildAndTestHandler::ProcessCommandLineArguments( idx++; this->BuildGenerator = allArgs[idx]; } + if(currentArg == "--build-generator-platform" && + idx < allArgs.size() - 1) + { + idx++; + this->BuildGeneratorPlatform = allArgs[idx]; + } if(currentArg == "--build-generator-toolset" && idx < allArgs.size() - 1) { diff --git a/Source/CTest/cmCTestBuildAndTestHandler.h b/Source/CTest/cmCTestBuildAndTestHandler.h index d1e9a4d..5a7b916 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.h +++ b/Source/CTest/cmCTestBuildAndTestHandler.h @@ -57,6 +57,7 @@ protected: std::string Output; std::string BuildGenerator; + std::string BuildGeneratorPlatform; std::string BuildGeneratorToolset; std::vector<std::string> BuildOptions; bool BuildTwoConfig; diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index 1aa8768..8ab5037 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -118,6 +118,15 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() cmakeConfigureCommand += cmakeGeneratorName; cmakeConfigureCommand += "\""; + const char* cmakeGeneratorPlatform = + this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_PLATFORM"); + if(cmakeGeneratorPlatform && *cmakeGeneratorPlatform) + { + cmakeConfigureCommand += " \"-DCMAKE_GENERATOR_PLATFORM="; + cmakeConfigureCommand += cmakeGeneratorPlatform; + cmakeConfigureCommand += "\""; + } + const char* cmakeGeneratorToolset = this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_TOOLSET"); if(cmakeGeneratorToolset && *cmakeGeneratorToolset) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 3681515..4375114 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -76,18 +76,46 @@ cmGlobalGenerator::~cmGlobalGenerator() } } +bool cmGlobalGenerator::SetGeneratorPlatform(std::string const& p, + cmMakefile* mf) +{ + if(p.empty()) + { + return true; + } + else + { + cmOStringStream e; + e << + "Generator\n" + " " << this->GetName() << "\n" + "does not support platform specification, but platform\n" + " " << p << "\n" + "was specified."; + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } +} + bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts, cmMakefile* mf) { - cmOStringStream e; - e << - "Generator\n" - " " << this->GetName() << "\n" - "does not support toolset specification, but toolset\n" - " " << ts << "\n" - "was specified."; - mf->IssueMessage(cmake::FATAL_ERROR, e.str()); - return false; + if(ts.empty()) + { + return true; + } + else + { + cmOStringStream e; + e << + "Generator\n" + " " << this->GetName() << "\n" + "does not support toolset specification, but toolset\n" + " " << ts << "\n" + "was specified."; + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } } std::string cmGlobalGenerator::SelectMakeProgram( @@ -410,7 +438,8 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, // try and load the CMakeSystem.cmake if it is there std::string fpath = rootBin; - if(!mf->GetDefinition("CMAKE_SYSTEM_LOADED")) + bool const readCMakeSystem = !mf->GetDefinition("CMAKE_SYSTEM_LOADED"); + if(readCMakeSystem) { fpath += "/CMakeSystem.cmake"; if(cmSystemTools::FileExists(fpath.c_str())) @@ -444,21 +473,31 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& 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)) + if(readCMakeSystem) { - cmSystemTools::SetFatalErrorOccured(); - return; - } + // 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() && - !this->SetGeneratorToolset(toolset, mf)) - { - cmSystemTools::SetFatalErrorOccured(); - return; + // Tell the generator about the platform, if any. + std::string platform = mf->GetSafeDefinition("CMAKE_GENERATOR_PLATFORM"); + if(!this->SetGeneratorPlatform(platform, mf)) + { + cmSystemTools::SetFatalErrorOccured(); + return; + } + + // Tell the generator about the toolset, if any. + std::string toolset = mf->GetSafeDefinition("CMAKE_GENERATOR_TOOLSET"); + if(!this->SetGeneratorToolset(toolset, mf)) + { + cmSystemTools::SetFatalErrorOccured(); + return; + } } // **** Load the system specific initialization if not yet loaded diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index f80c3c7..f166789 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -65,6 +65,10 @@ public: virtual bool SetSystemName(std::string const&, cmMakefile*) { return true; } + /** Set the generator-specific platform name. Returns true if platform + is supported and false otherwise. */ + virtual bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf); + /** Set the generator-specific toolset name. Returns true if toolset is supported and false otherwise. */ virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf); diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 19aa52c..e2d4645 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -116,16 +116,6 @@ cmGlobalVisualStudio10Generator::MatchesGeneratorName( } //---------------------------------------------------------------------------- -bool -cmGlobalVisualStudio10Generator::SetGeneratorToolset(std::string const& ts, - cmMakefile* mf) -{ - this->GeneratorToolset = ts; - this->AddVSPlatformToolsetDefinition(mf); - return true; -} - -//---------------------------------------------------------------------------- bool cmGlobalVisualStudio10Generator::SetSystemName(std::string const& s, cmMakefile* mf) { @@ -135,15 +125,39 @@ bool cmGlobalVisualStudio10Generator::SetSystemName(std::string const& s, { return false; } - if(this->PlatformName == "Itanium" || this->PlatformName == "x64") + return this->cmGlobalVisualStudio8Generator::SetSystemName(s, mf); +} + +//---------------------------------------------------------------------------- +bool +cmGlobalVisualStudio10Generator::SetGeneratorPlatform(std::string const& p, + cmMakefile* mf) +{ + if(!this->cmGlobalVisualStudio8Generator::SetGeneratorPlatform(p, mf)) + { + return false; + } + if(this->GetPlatformName() == "Itanium" || this->GetPlatformName() == "x64") { if(this->IsExpressEdition() && !this->Find64BitTools(mf)) { return false; } } - this->AddVSPlatformToolsetDefinition(mf); - return this->cmGlobalVisualStudio8Generator::SetSystemName(s, mf); + return true; +} + +//---------------------------------------------------------------------------- +bool +cmGlobalVisualStudio10Generator::SetGeneratorToolset(std::string const& ts, + cmMakefile* mf) +{ + this->GeneratorToolset = ts; + if(const char* toolset = this->GetPlatformToolset()) + { + mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET", toolset); + } + return true; } //---------------------------------------------------------------------------- @@ -187,16 +201,6 @@ bool cmGlobalVisualStudio10Generator::InitializeWindowsStore(cmMakefile* mf) } //---------------------------------------------------------------------------- -void cmGlobalVisualStudio10Generator -::AddVSPlatformToolsetDefinition(cmMakefile* mf) const -{ - if(const char* toolset = this->GetPlatformToolset()) - { - mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET", toolset); - } -} - -//---------------------------------------------------------------------------- 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 11fa954..f1ff9a4 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -30,8 +30,9 @@ 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 bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf); + virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf); virtual void GenerateBuildCommand( std::vector<std::string>& makeCommand, @@ -140,6 +141,5 @@ private: virtual std::string FindMSBuildCommand(); virtual std::string FindDevEnvCommand(); virtual std::string GetVSMakeProgram() { return this->GetMSBuildCommand(); } - void AddVSPlatformToolsetDefinition(cmMakefile* mf) const; }; #endif diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index e312ff1..401e475 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -27,11 +27,11 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator( if (platformName.empty()) { - this->PlatformName = "Win32"; + this->DefaultPlatformName = "Win32"; } else { - this->PlatformName = platformName; + this->DefaultPlatformName = platformName; } } @@ -260,21 +260,38 @@ cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator() } //---------------------------------------------------------------------------- +std::string const& cmGlobalVisualStudio7Generator::GetPlatformName() const +{ + if(!this->GeneratorPlatform.empty()) + { + return this->GeneratorPlatform; + } + return this->DefaultPlatformName; +} + +//---------------------------------------------------------------------------- bool cmGlobalVisualStudio7Generator::SetSystemName(std::string const& s, cmMakefile* mf) { - if(this->PlatformName == "x64") + mf->AddDefinition("CMAKE_VS_INTEL_Fortran_PROJECT_VERSION", + this->GetIntelProjectVersion()); + return this->cmGlobalVisualStudioGenerator::SetSystemName(s, mf); +} + +//---------------------------------------------------------------------------- +bool cmGlobalVisualStudio7Generator::SetGeneratorPlatform(std::string const& p, + cmMakefile* mf) +{ + if(this->GetPlatformName() == "x64") { mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE"); } - else if(this->PlatformName == "Itanium") + else if(this->GetPlatformName() == "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()); - return this->cmGlobalVisualStudioGenerator::SetSystemName(s, mf); + return this->cmGlobalVisualStudioGenerator::SetGeneratorPlatform(p, mf); } void cmGlobalVisualStudio7Generator::GenerateConfigurations(cmMakefile* mf) diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 7e3ed23..04a74db 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -39,13 +39,15 @@ public: static std::string GetActualName() {return "Visual Studio 7";} ///! Get the name for the platform. - const std::string& GetPlatformName() const { return this->PlatformName; } + std::string const& GetPlatformName() const; ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); virtual bool SetSystemName(std::string const& s, cmMakefile* mf); + virtual bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf); + /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); @@ -175,7 +177,8 @@ protected: // Set during OutputSLNFile with the name of the current project. // There is one SLN file per project. std::string CurrentProject; - std::string PlatformName; + std::string GeneratorPlatform; + std::string DefaultPlatformName; bool MasmEnabled; private: diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index c91730f..745515b 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -159,6 +159,21 @@ void cmGlobalVisualStudio8Generator::AddPlatformDefinitions(cmMakefile* mf) } //---------------------------------------------------------------------------- +bool cmGlobalVisualStudio8Generator::SetGeneratorPlatform(std::string const& p, + cmMakefile* mf) +{ + if(this->DefaultPlatformName == "Win32") + { + this->GeneratorPlatform = p; + return this->cmGlobalVisualStudio7Generator::SetGeneratorPlatform("", mf); + } + else + { + return this->cmGlobalVisualStudio7Generator::SetGeneratorPlatform(p, mf); + } +} + +//---------------------------------------------------------------------------- // ouput standard header for dsw file void cmGlobalVisualStudio8Generator::WriteSLNHeader(std::ostream& fout) { diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index cb6d3d9..4b41ed7 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -40,6 +40,8 @@ public: cmMakefile *, bool optional); virtual void AddPlatformDefinitions(cmMakefile* mf); + virtual bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf); + /** * Override Configure and Generate to add the build-system check * target. diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 17f838c..13e6988 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -208,8 +208,11 @@ bool cmGlobalXCodeGenerator::SetGeneratorToolset(std::string const& ts, if(this->XcodeVersion >= 30) { this->GeneratorToolset = ts; - mf->AddDefinition("CMAKE_XCODE_PLATFORM_TOOLSET", - this->GeneratorToolset.c_str()); + if(!this->GeneratorToolset.empty()) + { + mf->AddDefinition("CMAKE_XCODE_PLATFORM_TOOLSET", + this->GeneratorToolset.c_str()); + } return true; } else diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 04b2d27..efdaeec 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3548,6 +3548,7 @@ int cmMakefile::TryCompile(const std::string& srcdir, cm.SetHomeOutputDirectory(bindir); cm.SetStartDirectory(srcdir); cm.SetStartOutputDirectory(bindir); + cm.SetGeneratorPlatform(this->GetCMakeInstance()->GetGeneratorPlatform()); cm.SetGeneratorToolset(this->GetCMakeInstance()->GetGeneratorToolset()); cm.LoadCache(); if(!gg->IsMultiConfig()) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 6cc3b81..c9c63c7 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1445,6 +1445,34 @@ int cmake::ActualConfigure() cmCacheManager::INTERNAL); } + if(const char* platformName = + this->CacheManager->GetCacheValue("CMAKE_GENERATOR_PLATFORM")) + { + if(this->GeneratorPlatform.empty()) + { + this->GeneratorPlatform = platformName; + } + else if(this->GeneratorPlatform != platformName) + { + std::string message = "Error: generator platform: "; + message += this->GeneratorPlatform; + message += "\nDoes not match the platform used previously: "; + message += platformName; + message += + "\nEither remove the CMakeCache.txt file and CMakeFiles " + "directory or choose a different binary directory."; + cmSystemTools::Error(message.c_str()); + return -2; + } + } + else + { + this->CacheManager->AddCacheEntry("CMAKE_GENERATOR_PLATFORM", + this->GeneratorPlatform.c_str(), + "Name of generator platform.", + cmCacheManager::INTERNAL); + } + if(const char* tsName = this->CacheManager->GetCacheValue("CMAKE_GENERATOR_TOOLSET")) { diff --git a/Source/cmake.h b/Source/cmake.h index 2d04902..919fc24 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -191,6 +191,14 @@ class cmake ///! Get the names of the current registered generators void GetRegisteredGenerators(std::vector<std::string>& names); + ///! Set the name of the selected generator-specific platform. + void SetGeneratorPlatform(std::string const& ts) + { this->GeneratorPlatform = ts; } + + ///! Get the name of the selected generator-specific platform. + std::string const& GetGeneratorPlatform() const + { return this->GeneratorPlatform; } + ///! Set the name of the selected generator-specific toolset. void SetGeneratorToolset(std::string const& ts) { this->GeneratorToolset = ts; } @@ -403,6 +411,7 @@ protected: std::string StartOutputDirectory; bool SuppressDevWarnings; bool DoSuppressDevWarnings; + std::string GeneratorPlatform; std::string GeneratorToolset; ///! read in a cmake list file to initialize the cache diff --git a/Source/ctest.cxx b/Source/ctest.cxx index 2c72b4d..fb97af6 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -86,6 +86,7 @@ static const char * cmDocumentationOptions[][2] = {"--build-two-config", "Run CMake twice"}, {"--build-exe-dir", "Specify the directory for the executable."}, {"--build-generator", "Specify the generator to use."}, + {"--build-generator-platform", "Specify the generator-specific platform."}, {"--build-generator-toolset", "Specify the generator-specific toolset."}, {"--build-project", "Specify the name of the project to build."}, {"--build-makeprogram", "Specify the make program to use."}, |