浏览代码

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.
Brad King 12 年之前
父节点
当前提交
96966b5c80
共有 2 个文件被更改,包括 12 次插入7 次删除
  1. 3 3
      Help/manual/ctest.1.rst
  2. 9 4
      Source/CTest/cmCTestBuildAndTestHandler.cxx

+ 3 - 3
Help/manual/ctest.1.rst

@@ -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.

+ 9 - 4
Source/CTest/cmCTestBuildAndTestHandler.cxx

@@ -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
     {