ctest: Make the --build-makeprogram optional for --build-and-test

GenerateBuildCommand now knows how to lookup CMAKE_MAKE_PROGRAM or
choose a generator-provided default build tool.  Therefore the
--build-makeprogram can now be optional and simply override the
default selection when provided.

Note that with --build-nocmake we now need to load the cache in order to
make the CMAKE_MAKE_PROGRAM entry available to GenerateBuildCommand.
This commit is contained in:
Brad King 2013-11-14 10:14:35 -05:00
parent 91a021146c
commit 96966b5c80
2 changed files with 12 additions and 7 deletions

View File

@ -225,8 +225,8 @@ Options
and or execute a test. The configure and test steps are optional.
The arguments to this command line are the source and binary
directories. By default this will run CMake on the Source/Bin
directories specified unless --build-nocmake is specified. Both
--build-makeprogram and --build-generator MUST be provided to use
directories specified unless --build-nocmake is specified.
The --build-generator option *must* be provided to use
--build-and-test. If --test-command is specified then that will be
run after the build is complete. Other options that affect this
mode are --build-target --build-nocmake, --build-run-dir,
@ -265,7 +265,7 @@ Options
Specify the name of the project to build.
``--build-makeprogram``
Specify the make program to use.
Override the make program chosen by CTest with a given one.
``--build-noclean``
Skip the make clean step.

View File

@ -18,6 +18,7 @@
#include "cmGlobalGenerator.h"
#include <cmsys/Process.h>
#include "cmCTestTestHandler.h"
#include "cmCacheManager.h"
//----------------------------------------------------------------------
cmCTestBuildAndTestHandler::cmCTestBuildAndTestHandler()
@ -184,14 +185,14 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
cmOStringStream out;
// if the generator and make program are not specified then it is an error
if (!this->BuildGenerator.size() || !this->BuildMakeProgram.size())
if (!this->BuildGenerator.size())
{
if(outstring)
{
*outstring =
"--build-and-test requires that both the generator and makeprogram "
"be provided using the --build-generator and --build-makeprogram "
"command line options. ";
"--build-and-test requires that the generator "
"be provided using the --build-generator "
"command line option. ";
}
return 1;
}
@ -238,9 +239,13 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
if(this->BuildNoCMake)
{
// Make the generator available for the Build call below.
cm.SetGlobalGenerator(cm.CreateGlobalGenerator(
this->BuildGenerator.c_str()));
cm.SetGeneratorToolset(this->BuildGeneratorToolset);
// Load the cache to make CMAKE_MAKE_PROGRAM available.
cm.GetCacheManager()->LoadCache(this->BinaryDir.c_str());
}
else
{