summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-11-19 15:55:39 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2013-11-19 15:55:39 (GMT)
commit1da77bf1ee4f3ba315ebb00da2eaeac474614cad (patch)
tree3832a8e9ce070baea6434691201d873bb54f3958 /Source/cmGlobalGenerator.cxx
parent856468213640417d401c6ff70c1f43c1c31145dc (diff)
parent4cce44b6c50a40ee13f423ae311d5db5a66a13f4 (diff)
downloadCMake-1da77bf1ee4f3ba315ebb00da2eaeac474614cad.zip
CMake-1da77bf1ee4f3ba315ebb00da2eaeac474614cad.tar.gz
CMake-1da77bf1ee4f3ba315ebb00da2eaeac474614cad.tar.bz2
Merge topic 'cleanup-build-commands'
4cce44b Help: Document the CMAKE_MAKE_PROGRAM variable in more detail 558c74d VS: Switch to internal CMAKE_MAKE_PROGRAM lookup by generators 5229f2d Tests: Do not use an explicit make program for VS generators 72dd738 Tests: Fix MFC test heuristic for empty CMAKE_TEST_MAKEPROGRAM fd6076d Tests: Pass CMAKE_MAKE_PROGRAM instead of --build-makeprogram 68031ab Tests: Configure SubProject-Stage2 test more robustly 003d10c Tests: Simplify VSExcludeFromDefaultBuild configuration e47d934 Tests: Simplify VSProjectInSubdir configuration e965cb1 Tests: Simplify CTest.BuildCommand.ProjectInSubdir configuration 72bf255 Tests: Pass --build-options to every test 4d1d772 ctest: Teach --build-options to allow zero options 96966b5 ctest: Make the --build-makeprogram optional for --build-and-test 91a0211 Simplify some calls to cmGlobalGenerator::Build 123a060 Teach GenerateBuildCommand to find its own make program 5f5c92b VS: Add internal APIs to find MSBuild, devenv/VCExpress, and msdev 4ac75fd Prefer CMAKE_MAKE_PROGRAM over CMAKE_BUILD_TOOL (#14548) ...
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r--Source/cmGlobalGenerator.cxx145
1 files changed, 79 insertions, 66 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index b76b943..65a7118 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -88,6 +88,26 @@ bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts)
return false;
}
+std::string cmGlobalGenerator::SelectMakeProgram(const char* makeProgram,
+ std::string makeDefault)
+{
+ if(cmSystemTools::IsOff(makeProgram))
+ {
+ makeProgram =
+ this->CMakeInstance->GetCacheDefinition("CMAKE_MAKE_PROGRAM");
+ if(cmSystemTools::IsOff(makeProgram))
+ {
+ makeProgram = makeDefault.c_str();
+ }
+ if(cmSystemTools::IsOff(makeProgram) &&
+ !(makeProgram && *makeProgram))
+ {
+ makeProgram = "CMAKE_MAKE_PROGRAM-NOTFOUND";
+ }
+ }
+ return makeProgram;
+}
+
void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang,
cmMakefile *mf,
bool optional)
@@ -1542,15 +1562,6 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir,
this->FirstTimeProgress);
}
- std::string makeCommand = this->CMakeInstance->
- GetCacheManager()->GetCacheValue("CMAKE_MAKE_PROGRAM");
- if(makeCommand.size() == 0)
- {
- cmSystemTools::Error(
- "Generator cannot find the appropriate make command.");
- return 1;
- }
-
std::string newTarget;
if (target && strlen(target))
{
@@ -1570,45 +1581,16 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir,
const char* config = mf->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION");
return this->Build(srcdir,bindir,projectName,
newTarget.c_str(),
- output,makeCommand.c_str(),config,false,fast,
+ output,0,config,false,fast,
this->TryCompileTimeout);
}
-std::string cmGlobalGenerator
-::GenerateBuildCommand(const char* makeProgram, const char *projectName,
- const char *projectDir, const char* additionalOptions,
- const char *targetName, const char* config,
- bool ignoreErrors, bool)
+void cmGlobalGenerator::GenerateBuildCommand(
+ std::vector<std::string>& makeCommand, const char*, const char*, const char*,
+ const char*, const char*, bool, std::vector<std::string> const&)
{
- // Project name & dir and config are not used yet.
- (void)projectName;
- (void)projectDir;
- (void)config;
-
- std::string makeCommand =
- cmSystemTools::ConvertToUnixOutputPath(makeProgram);
-
- // Since we have full control over the invocation of nmake, let us
- // make it quiet.
- if ( strcmp(this->GetName(), "NMake Makefiles") == 0 )
- {
- makeCommand += " /NOLOGO ";
- }
- if ( ignoreErrors )
- {
- makeCommand += " -i";
- }
- if ( additionalOptions )
- {
- makeCommand += " ";
- makeCommand += additionalOptions;
- }
- if ( targetName )
- {
- makeCommand += " ";
- makeCommand += targetName;
- }
- return makeCommand;
+ makeCommand.push_back(
+ "cmGlobalGenerator::GenerateBuildCommand not implemented");
}
int cmGlobalGenerator::Build(
@@ -1620,7 +1602,6 @@ int cmGlobalGenerator::Build(
bool clean, bool fast,
double timeout,
cmSystemTools::OutputOption outputflag,
- const char* extraOptions,
std::vector<std::string> const& nativeOptions)
{
/**
@@ -1648,17 +1629,17 @@ int cmGlobalGenerator::Build(
// should we do a clean first?
if (clean)
{
- std::string cleanCommand =
- this->GenerateBuildCommand(makeCommandCSTR, projectName, bindir,
- 0, "clean", config, false, fast);
+ std::vector<std::string> cleanCommand;
+ this->GenerateBuildCommand(cleanCommand, makeCommandCSTR, projectName,
+ bindir, "clean", config, fast);
if(output)
{
*output += "\nRun Clean Command:";
- *output += cleanCommand;
+ *output += cmSystemTools::PrintSingleCommand(cleanCommand);
*output += "\n";
}
- if (!cmSystemTools::RunSingleCommand(cleanCommand.c_str(), outputPtr,
+ if (!cmSystemTools::RunSingleCommand(cleanCommand, outputPtr,
&retVal, 0, outputflag, timeout))
{
cmSystemTools::SetRunCommandHideConsole(hideconsole);
@@ -1680,37 +1661,29 @@ int cmGlobalGenerator::Build(
}
// now build
- std::string makeCommand =
- this->GenerateBuildCommand(makeCommandCSTR, projectName, bindir,
- extraOptions, target,
- config, false, fast);
+ std::vector<std::string> makeCommand;
+ this->GenerateBuildCommand(makeCommand, makeCommandCSTR, projectName,
+ bindir, target, config, fast, nativeOptions);
+ std::string makeCommandStr = cmSystemTools::PrintSingleCommand(makeCommand);
if(output)
{
*output += "\nRun Build Command:";
- *output += makeCommand;
+ *output += makeCommandStr;
*output += "\n";
}
- std::vector<cmStdString> command =
- cmSystemTools::ParseArguments(makeCommand.c_str());
- for(std::vector<std::string>::const_iterator ni = nativeOptions.begin();
- ni != nativeOptions.end(); ++ni)
- {
- command.push_back(*ni);
- }
-
- if (!cmSystemTools::RunSingleCommand(command, outputPtr,
+ if (!cmSystemTools::RunSingleCommand(makeCommand, outputPtr,
&retVal, 0, outputflag, timeout))
{
cmSystemTools::SetRunCommandHideConsole(hideconsole);
cmSystemTools::Error
("Generator: execution of make failed. Make command was: ",
- makeCommand.c_str());
+ makeCommandStr.c_str());
if (output)
{
*output += *outputPtr;
*output += "\nGenerator: execution of make failed. Make command was: "
- + makeCommand + "\n";
+ + makeCommandStr + "\n";
}
// return to the original directory
@@ -1735,6 +1708,46 @@ int cmGlobalGenerator::Build(
return retVal;
}
+//----------------------------------------------------------------------------
+std::string cmGlobalGenerator::GenerateCMakeBuildCommand(
+ const char* target, const char* config, const char* native,
+ bool ignoreErrors)
+{
+ std::string makeCommand = cmSystemTools::GetCMakeCommand();
+ makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand.c_str());
+ makeCommand += " --build .";
+ if(config && *config)
+ {
+ makeCommand += " --config \"";
+ makeCommand += config;
+ makeCommand += "\"";
+ }
+ if(target && *target)
+ {
+ makeCommand += " --target \"";
+ makeCommand += target;
+ makeCommand += "\"";
+ }
+ const char* sep = " -- ";
+ if(ignoreErrors)
+ {
+ const char* iflag = this->GetBuildIgnoreErrorsFlag();
+ if(iflag && *iflag)
+ {
+ makeCommand += sep;
+ makeCommand += iflag;
+ sep = " ";
+ }
+ }
+ if(native && *native)
+ {
+ makeCommand += sep;
+ makeCommand += native;
+ }
+ return makeCommand;
+}
+
+//----------------------------------------------------------------------------
void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg)
{
this->LocalGenerators.push_back(lg);