From d8294fefe8063cc2e0a0cfecf7fd8fef619cf0da Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 25 Sep 2018 10:08:57 -0400 Subject: cmake: Fix generator platform under --build mode --- Source/cmake.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index c26a380..889a5fb 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2467,6 +2467,14 @@ int cmake::Build(int jobs, const std::string& dir, const std::string& target, return 1; } } + const char* cachedGeneratorPlatform = + this->State->GetCacheEntryValue("CMAKE_GENERATOR_PLATFORM"); + if (cachedGeneratorPlatform) { + cmMakefile mf(gen, this->GetCurrentSnapshot()); + if (!gen->SetGeneratorPlatform(cachedGeneratorPlatform, &mf)) { + return 1; + } + } std::string output; std::string projName; const char* cachedProjectName = -- cgit v0.12 From 6597428c364c0a495bba88a6154ac0ed7f3cd461 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 25 Sep 2018 13:20:30 -0400 Subject: ctest: Fix generator platform under --build-nocmake When constructing a global generator instance in `--build-and-test` mode we need to set the platform passed by `--build-generator-platform` directly on the generator. The old code that set it on the `cmake` class instance did nothing because that only affects cache initialization, which is not done by `--build-nocmake`. --- Source/CTest/cmCTestBuildAndTestHandler.cxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index fccbc95..668a387 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -5,6 +5,7 @@ #include "cmCTest.h" #include "cmCTestTestHandler.h" #include "cmGlobalGenerator.h" +#include "cmMakefile.h" #include "cmSystemTools.h" #include "cmWorkingDirectory.h" #include "cmake.h" @@ -210,9 +211,14 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) if (this->BuildNoCMake) { // Make the generator available for the Build call below. - cm.SetGlobalGenerator(cm.CreateGlobalGenerator(this->BuildGenerator)); - cm.SetGeneratorPlatform(this->BuildGeneratorPlatform); - cm.SetGeneratorToolset(this->BuildGeneratorToolset); + cmGlobalGenerator* gen = cm.CreateGlobalGenerator(this->BuildGenerator); + cm.SetGlobalGenerator(gen); + if (!this->BuildGeneratorPlatform.empty()) { + cmMakefile mf(gen, cm.GetCurrentSnapshot()); + if (!gen->SetGeneratorPlatform(this->BuildGeneratorPlatform, &mf)) { + return 1; + } + } // Load the cache to make CMAKE_MAKE_PROGRAM available. cm.LoadCache(this->BinaryDir); -- cgit v0.12 From 98e4fbdc063ea738f1f2fa38028be14492297d0f Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 25 Sep 2018 13:25:36 -0400 Subject: VS: Pass platform when invoking MSBuild MSBuild expects a `/p:Platform=...` argument to tell it which platform to build among those in the `.vcxproj` files. We have not historically had to do this because we generate only one platform. However, when a project uses `include_external_msproject` the included project file may have other platforms. Fixes: #18308 --- Source/cmGlobalVisualStudio10Generator.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 5ea323a..82fcaad 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -938,6 +938,7 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( configArg += "Debug"; } makeCommand.push_back(configArg); + makeCommand.push_back("/p:Platform=" + this->GetPlatformName()); makeCommand.push_back(std::string("/p:VisualStudioVersion=") + this->GetIDEVersion()); -- cgit v0.12