summaryrefslogtreecommitdiffstats
path: root/Source/cmBuildCommand.cxx
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2009-12-04 17:09:01 (GMT)
committerDavid Cole <david.cole@kitware.com>2009-12-04 17:09:01 (GMT)
commit0b38bb4c535ae972d7f973e3e69945a6d0c14d75 (patch)
treeac80395b194b2a8ed2bcf6b1f997b62c21d151be /Source/cmBuildCommand.cxx
parentaf14f1f2c3750ba3cf9b9cc1a809a88b1878a5c3 (diff)
downloadCMake-0b38bb4c535ae972d7f973e3e69945a6d0c14d75.zip
CMake-0b38bb4c535ae972d7f973e3e69945a6d0c14d75.tar.gz
CMake-0b38bb4c535ae972d7f973e3e69945a6d0c14d75.tar.bz2
Fix issue #2336 - honor the -C arg to ctest. Honor it for all stages of running -D dashboards from the command line and running ctest_configure, ctest_build and ctest_test commands in -S scripts. Also, allow a script to change it by setting the CTEST_CONFIGURATION_TYPE variable: allows for multiple configuration build/test cycles within one script. Add a new signature for the cmake command build_command that accepts CONFIGURATION as one argument. The original build_command signature is still there, but now marked as deprecated in the documentation. Of course... also add CTestConfig tests to verify that -C is honored for -D dashboards and -S scripts.
Diffstat (limited to 'Source/cmBuildCommand.cxx')
-rw-r--r--Source/cmBuildCommand.cxx115
1 files changed, 112 insertions, 3 deletions
diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx
index b9ce561..3722ab6 100644
--- a/Source/cmBuildCommand.cxx
+++ b/Source/cmBuildCommand.cxx
@@ -14,25 +14,135 @@
#include "cmLocalGenerator.h"
#include "cmGlobalGenerator.h"
-// cmBuildCommand
+//----------------------------------------------------------------------
bool cmBuildCommand
::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
{
+ // Support the legacy signature of the command:
+ //
+ if(2 == args.size())
+ {
+ return this->TwoArgsSignature(args);
+ }
+
+ return this->MainSignature(args);
+}
+
+//----------------------------------------------------------------------
+bool cmBuildCommand
+::MainSignature(std::vector<std::string> const& args)
+{
+ if(args.size() < 1)
+ {
+ this->SetError("requires at least one argument naming a CMake variable");
+ return false;
+ }
+
+ // The cmake variable in which to store the result.
+ const char* variable = args[0].c_str();
+
+ // Parse remaining arguments.
+ const char* configuration = 0;
+ const char* project_name = 0;
+ const char* target = 0;
+ enum Doing { DoingNone, DoingConfiguration, DoingProjectName, DoingTarget };
+ Doing doing = DoingNone;
+ for(unsigned int i=1; i < args.size(); ++i)
+ {
+ if(args[i] == "CONFIGURATION")
+ {
+ doing = DoingConfiguration;
+ }
+ else if(args[i] == "PROJECT_NAME")
+ {
+ doing = DoingProjectName;
+ }
+ else if(args[i] == "TARGET")
+ {
+ doing = DoingTarget;
+ }
+ else if(doing == DoingConfiguration)
+ {
+ doing = DoingNone;
+ configuration = args[i].c_str();
+ }
+ else if(doing == DoingProjectName)
+ {
+ doing = DoingNone;
+ project_name = args[i].c_str();
+ }
+ else if(doing == DoingTarget)
+ {
+ doing = DoingNone;
+ target = args[i].c_str();
+ }
+ else
+ {
+ cmOStringStream e;
+ e << "unknown argument \"" << args[i] << "\"";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+ }
+
+ const char* makeprogram
+ = this->Makefile->GetDefinition("CMAKE_MAKE_PROGRAM");
+
+ // If null/empty CONFIGURATION argument, GenerateBuildCommand uses 'Debug'
+ // in the currently implemented multi-configuration global generators...
+ // so we put this code here to end up with the same default configuration
+ // as the original 2-arg build_command signature:
+ //
+ if(!configuration || !*configuration)
+ {
+ configuration = getenv("CMAKE_CONFIG_TYPE");
+ }
+ if(!configuration || !*configuration)
+ {
+ configuration = "Release";
+ }
+
+ // If null/empty PROJECT_NAME argument, use the Makefile's project name:
+ //
+ if(!project_name || !*project_name)
+ {
+ project_name = this->Makefile->GetProjectName();
+ }
+
+ // If null/empty TARGET argument, GenerateBuildCommand omits any mention
+ // of a target name on the build command line...
+ //
+ std::string makecommand = this->Makefile->GetLocalGenerator()
+ ->GetGlobalGenerator()->GenerateBuildCommand
+ (makeprogram, project_name, 0, target, configuration, true, false);
+
+ this->Makefile->AddDefinition(variable, makecommand.c_str());
+
+ return true;
+}
+
+//----------------------------------------------------------------------
+bool cmBuildCommand
+::TwoArgsSignature(std::vector<std::string> const& args)
+{
if(args.size() < 2 )
{
- this->SetError("called with incorrect number of arguments");
+ this->SetError("called with less than two arguments");
return false;
}
+
const char* define = args[0].c_str();
const char* cacheValue
= this->Makefile->GetDefinition(define);
std::string makeprogram = args[1];
+
std::string configType = "Release";
const char* cfg = getenv("CMAKE_CONFIG_TYPE");
if ( cfg )
{
configType = cfg;
}
+
std::string makecommand = this->Makefile->GetLocalGenerator()
->GetGlobalGenerator()->GenerateBuildCommand
(makeprogram.c_str(), this->Makefile->GetProjectName(), 0,
@@ -49,4 +159,3 @@ bool cmBuildCommand
cmCacheManager::STRING);
return true;
}
-