CTest: Add options to set generator toolset
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_TOOLSET for -T. The "ctest --build-and-test" mode already has "--build-generator" to specify the -G option to CMake. Add a "--build-generator-toolset" option to specify the -T value.
This commit is contained in:
parent
f980a80495
commit
e3841cf4a2
|
@ -67,6 +67,12 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
|
|||
generator += this->BuildGenerator;
|
||||
args.push_back(generator);
|
||||
}
|
||||
if(this->BuildGeneratorToolset.size())
|
||||
{
|
||||
std::string toolset = "-T";
|
||||
toolset += this->BuildGeneratorToolset;
|
||||
args.push_back(toolset);
|
||||
}
|
||||
|
||||
const char* config = 0;
|
||||
if ( this->CTest->GetConfigType().size() > 0 )
|
||||
|
@ -229,10 +235,14 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
|
|||
// should we cmake?
|
||||
cmake cm;
|
||||
cm.SetProgressCallback(CMakeProgressCallback, &cmakeOutString);
|
||||
cm.SetGlobalGenerator(cm.CreateGlobalGenerator(
|
||||
this->BuildGenerator.c_str()));
|
||||
|
||||
if(!this->BuildNoCMake)
|
||||
if(this->BuildNoCMake)
|
||||
{
|
||||
cm.SetGlobalGenerator(cm.CreateGlobalGenerator(
|
||||
this->BuildGenerator.c_str()));
|
||||
cm.SetGeneratorToolset(this->BuildGeneratorToolset);
|
||||
}
|
||||
else
|
||||
{
|
||||
// do the cmake step, no timeout here since it is not a sub process
|
||||
if (this->RunCMake(outstring,out,cmakeOutString,cwd,&cm))
|
||||
|
@ -466,11 +476,17 @@ int cmCTestBuildAndTestHandler::ProcessCommandLineArguments(
|
|||
idx++;
|
||||
this->Timeout = atof(allArgs[idx].c_str());
|
||||
}
|
||||
if(currentArg.find("--build-generator",0) == 0 && idx < allArgs.size() - 1)
|
||||
if(currentArg == "--build-generator" && idx < allArgs.size() - 1)
|
||||
{
|
||||
idx++;
|
||||
this->BuildGenerator = allArgs[idx];
|
||||
}
|
||||
if(currentArg == "--build-generator-toolset" &&
|
||||
idx < allArgs.size() - 1)
|
||||
{
|
||||
idx++;
|
||||
this->BuildGeneratorToolset = allArgs[idx];
|
||||
}
|
||||
if(currentArg.find("--build-project",0) == 0 && idx < allArgs.size() - 1)
|
||||
{
|
||||
idx++;
|
||||
|
|
|
@ -57,6 +57,7 @@ protected:
|
|||
cmStdString Output;
|
||||
|
||||
std::string BuildGenerator;
|
||||
std::string BuildGeneratorToolset;
|
||||
std::vector<std::string> BuildOptions;
|
||||
bool BuildTwoConfig;
|
||||
std::string BuildMakeProgram;
|
||||
|
|
|
@ -144,6 +144,15 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
|
|||
cmakeConfigureCommand += cmakeGeneratorName;
|
||||
cmakeConfigureCommand += "\"";
|
||||
|
||||
const char* cmakeGeneratorToolset =
|
||||
this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_TOOLSET");
|
||||
if(cmakeGeneratorToolset && *cmakeGeneratorToolset)
|
||||
{
|
||||
cmakeConfigureCommand += " \"-T";
|
||||
cmakeConfigureCommand += cmakeGeneratorToolset;
|
||||
cmakeConfigureCommand += "\"";
|
||||
}
|
||||
|
||||
cmakeConfigureCommand += " \"";
|
||||
cmakeConfigureCommand += source_dir;
|
||||
cmakeConfigureCommand += "\"";
|
||||
|
|
|
@ -187,6 +187,7 @@ static const char * cmDocumentationOptions[][3] =
|
|||
{"--build-two-config", "Run CMake twice", "" },
|
||||
{"--build-exe-dir", "Specify the directory for the executable.", "" },
|
||||
{"--build-generator", "Specify the generator to use.", "" },
|
||||
{"--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.", "" },
|
||||
{"--build-noclean", "Skip the make clean step.", "" },
|
||||
|
|
Loading…
Reference in New Issue