CTest: Add options to set generator platform

The ctest_configure command already reads the CTEST_CMAKE_GENERATOR
variable to get the value for the cmake -G option.  Read new variable
CTEST_CMAKE_GENERATOR_PLATFORM to pass on as CMAKE_GENERATOR_PLATFORM.

The "ctest --build-and-test" mode already has "--build-generator" to
specify the -G option to CMake.  Add a "--build-generator-platform" option
to specify a value to pass on as CMAKE_GENERATOR_PLATFORM.
This commit is contained in:
Brad King 2014-09-05 15:14:13 -04:00
parent b97736a23d
commit 8d33209170
5 changed files with 27 additions and 0 deletions

View File

@ -258,6 +258,9 @@ Options
``--build-generator`` ``--build-generator``
Specify the generator to use. Specify the generator to use.
``--build-generator-platform``
Specify the generator-specific platform.
``--build-generator-toolset`` ``--build-generator-toolset``
Specify the generator-specific toolset. Specify the generator-specific toolset.

View File

@ -68,6 +68,12 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
generator += this->BuildGenerator; generator += this->BuildGenerator;
args.push_back(generator); 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()) if(this->BuildGeneratorToolset.size())
{ {
std::string toolset = "-T"; std::string toolset = "-T";
@ -246,6 +252,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
// Make the generator available for the Build call below. // Make the generator available for the Build call below.
cm.SetGlobalGenerator(cm.CreateGlobalGenerator( cm.SetGlobalGenerator(cm.CreateGlobalGenerator(
this->BuildGenerator)); this->BuildGenerator));
cm.SetGeneratorPlatform(this->BuildGeneratorPlatform);
cm.SetGeneratorToolset(this->BuildGeneratorToolset); cm.SetGeneratorToolset(this->BuildGeneratorToolset);
// Load the cache to make CMAKE_MAKE_PROGRAM available. // Load the cache to make CMAKE_MAKE_PROGRAM available.
@ -490,6 +497,12 @@ int cmCTestBuildAndTestHandler::ProcessCommandLineArguments(
idx++; idx++;
this->BuildGenerator = allArgs[idx]; this->BuildGenerator = allArgs[idx];
} }
if(currentArg == "--build-generator-platform" &&
idx < allArgs.size() - 1)
{
idx++;
this->BuildGeneratorPlatform = allArgs[idx];
}
if(currentArg == "--build-generator-toolset" && if(currentArg == "--build-generator-toolset" &&
idx < allArgs.size() - 1) idx < allArgs.size() - 1)
{ {

View File

@ -57,6 +57,7 @@ protected:
std::string Output; std::string Output;
std::string BuildGenerator; std::string BuildGenerator;
std::string BuildGeneratorPlatform;
std::string BuildGeneratorToolset; std::string BuildGeneratorToolset;
std::vector<std::string> BuildOptions; std::vector<std::string> BuildOptions;
bool BuildTwoConfig; bool BuildTwoConfig;

View File

@ -118,6 +118,15 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
cmakeConfigureCommand += cmakeGeneratorName; cmakeConfigureCommand += cmakeGeneratorName;
cmakeConfigureCommand += "\""; cmakeConfigureCommand += "\"";
const char* cmakeGeneratorPlatform =
this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_PLATFORM");
if(cmakeGeneratorPlatform && *cmakeGeneratorPlatform)
{
cmakeConfigureCommand += " \"-DCMAKE_GENERATOR_PLATFORM=";
cmakeConfigureCommand += cmakeGeneratorPlatform;
cmakeConfigureCommand += "\"";
}
const char* cmakeGeneratorToolset = const char* cmakeGeneratorToolset =
this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_TOOLSET"); this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_TOOLSET");
if(cmakeGeneratorToolset && *cmakeGeneratorToolset) if(cmakeGeneratorToolset && *cmakeGeneratorToolset)

View File

@ -86,6 +86,7 @@ static const char * cmDocumentationOptions[][2] =
{"--build-two-config", "Run CMake twice"}, {"--build-two-config", "Run CMake twice"},
{"--build-exe-dir", "Specify the directory for the executable."}, {"--build-exe-dir", "Specify the directory for the executable."},
{"--build-generator", "Specify the generator to use."}, {"--build-generator", "Specify the generator to use."},
{"--build-generator-platform", "Specify the generator-specific platform."},
{"--build-generator-toolset", "Specify the generator-specific toolset."}, {"--build-generator-toolset", "Specify the generator-specific toolset."},
{"--build-project", "Specify the name of the project to build."}, {"--build-project", "Specify the name of the project to build."},
{"--build-makeprogram", "Specify the make program to use."}, {"--build-makeprogram", "Specify the make program to use."},