cmGlobalGenerator: Cleanup GenerateBuildCommand API
All cmGlobalGenerator::GenerateBuildCommand call sites that need to produce a string now generate "cmake --build" commands. The remaining call sites immediately pass the result to cmSystemTools::RunSingleCommand. Avoid the intermediate string and argument parsing by directly producing a vector of strings. Also drop the ignoreErrors argument because no call sites remain that use it.
This commit is contained in:
parent
0814d0a655
commit
8904d1410b
|
@ -637,19 +637,21 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
|
||||||
globalGenerator->FindMakeProgram(this->MakefileMap);
|
globalGenerator->FindMakeProgram(this->MakefileMap);
|
||||||
const char* cmakeMakeProgram
|
const char* cmakeMakeProgram
|
||||||
= this->MakefileMap->GetDefinition("CMAKE_MAKE_PROGRAM");
|
= this->MakefileMap->GetDefinition("CMAKE_MAKE_PROGRAM");
|
||||||
std::string buildCommand
|
std::vector<std::string> buildCommand;
|
||||||
= globalGenerator->GenerateBuildCommand(cmakeMakeProgram,
|
globalGenerator->GenerateBuildCommand(buildCommand, cmakeMakeProgram,
|
||||||
installProjectName.c_str(), 0, 0,
|
installProjectName.c_str(), installDirectory.c_str(),
|
||||||
globalGenerator->GetPreinstallTargetName(),
|
globalGenerator->GetPreinstallTargetName(),
|
||||||
buildConfig, false, false);
|
buildConfig, false);
|
||||||
|
std::string buildCommandStr =
|
||||||
|
cmSystemTools::PrintSingleCommand(buildCommand);
|
||||||
cmCPackLogger(cmCPackLog::LOG_DEBUG,
|
cmCPackLogger(cmCPackLog::LOG_DEBUG,
|
||||||
"- Install command: " << buildCommand << std::endl);
|
"- Install command: " << buildCommandStr << std::endl);
|
||||||
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
|
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
|
||||||
"- Run preinstall target for: " << installProjectName << std::endl);
|
"- Run preinstall target for: " << installProjectName << std::endl);
|
||||||
std::string output;
|
std::string output;
|
||||||
int retVal = 1;
|
int retVal = 1;
|
||||||
bool resB =
|
bool resB =
|
||||||
cmSystemTools::RunSingleCommand(buildCommand.c_str(),
|
cmSystemTools::RunSingleCommand(buildCommand,
|
||||||
&output,
|
&output,
|
||||||
&retVal,
|
&retVal,
|
||||||
installDirectory.c_str(),
|
installDirectory.c_str(),
|
||||||
|
@ -659,12 +661,12 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
|
||||||
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
||||||
tmpFile += "/PreinstallOutput.log";
|
tmpFile += "/PreinstallOutput.log";
|
||||||
cmGeneratedFileStream ofs(tmpFile.c_str());
|
cmGeneratedFileStream ofs(tmpFile.c_str());
|
||||||
ofs << "# Run command: " << buildCommand.c_str() << std::endl
|
ofs << "# Run command: " << buildCommandStr.c_str() << std::endl
|
||||||
<< "# Directory: " << installDirectory.c_str() << std::endl
|
<< "# Directory: " << installDirectory.c_str() << std::endl
|
||||||
<< "# Output:" << std::endl
|
<< "# Output:" << std::endl
|
||||||
<< output.c_str() << std::endl;
|
<< output.c_str() << std::endl;
|
||||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||||
"Problem running install command: " << buildCommand.c_str()
|
"Problem running install command: " << buildCommandStr.c_str()
|
||||||
<< std::endl
|
<< std::endl
|
||||||
<< "Please check " << tmpFile.c_str() << " for errors"
|
<< "Please check " << tmpFile.c_str() << " for errors"
|
||||||
<< std::endl);
|
<< std::endl);
|
||||||
|
|
|
@ -1574,13 +1574,12 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir,
|
||||||
this->TryCompileTimeout);
|
this->TryCompileTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string cmGlobalGenerator
|
void cmGlobalGenerator::GenerateBuildCommand(
|
||||||
::GenerateBuildCommand(const char*, const char*,
|
std::vector<std::string>& makeCommand, const char*, const char*, const char*,
|
||||||
const char*, const char*,
|
const char*, const char*, bool, std::vector<std::string> const&)
|
||||||
const char*, const char*,
|
|
||||||
bool, bool)
|
|
||||||
{
|
{
|
||||||
return "cmGlobalGenerator::GenerateBuildCommand not implemented";
|
makeCommand.push_back(
|
||||||
|
"cmGlobalGenerator::GenerateBuildCommand not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
int cmGlobalGenerator::Build(
|
int cmGlobalGenerator::Build(
|
||||||
|
@ -1592,7 +1591,6 @@ int cmGlobalGenerator::Build(
|
||||||
bool clean, bool fast,
|
bool clean, bool fast,
|
||||||
double timeout,
|
double timeout,
|
||||||
cmSystemTools::OutputOption outputflag,
|
cmSystemTools::OutputOption outputflag,
|
||||||
const char* extraOptions,
|
|
||||||
std::vector<std::string> const& nativeOptions)
|
std::vector<std::string> const& nativeOptions)
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -1620,17 +1618,17 @@ int cmGlobalGenerator::Build(
|
||||||
// should we do a clean first?
|
// should we do a clean first?
|
||||||
if (clean)
|
if (clean)
|
||||||
{
|
{
|
||||||
std::string cleanCommand =
|
std::vector<std::string> cleanCommand;
|
||||||
this->GenerateBuildCommand(makeCommandCSTR, projectName, bindir,
|
this->GenerateBuildCommand(cleanCommand, makeCommandCSTR, projectName,
|
||||||
0, "clean", config, false, fast);
|
bindir, "clean", config, fast);
|
||||||
if(output)
|
if(output)
|
||||||
{
|
{
|
||||||
*output += "\nRun Clean Command:";
|
*output += "\nRun Clean Command:";
|
||||||
*output += cleanCommand;
|
*output += cmSystemTools::PrintSingleCommand(cleanCommand);
|
||||||
*output += "\n";
|
*output += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cmSystemTools::RunSingleCommand(cleanCommand.c_str(), outputPtr,
|
if (!cmSystemTools::RunSingleCommand(cleanCommand, outputPtr,
|
||||||
&retVal, 0, outputflag, timeout))
|
&retVal, 0, outputflag, timeout))
|
||||||
{
|
{
|
||||||
cmSystemTools::SetRunCommandHideConsole(hideconsole);
|
cmSystemTools::SetRunCommandHideConsole(hideconsole);
|
||||||
|
@ -1652,37 +1650,29 @@ int cmGlobalGenerator::Build(
|
||||||
}
|
}
|
||||||
|
|
||||||
// now build
|
// now build
|
||||||
std::string makeCommand =
|
std::vector<std::string> makeCommand;
|
||||||
this->GenerateBuildCommand(makeCommandCSTR, projectName, bindir,
|
this->GenerateBuildCommand(makeCommand, makeCommandCSTR, projectName,
|
||||||
extraOptions, target,
|
bindir, target, config, fast, nativeOptions);
|
||||||
config, false, fast);
|
std::string makeCommandStr = cmSystemTools::PrintSingleCommand(makeCommand);
|
||||||
if(output)
|
if(output)
|
||||||
{
|
{
|
||||||
*output += "\nRun Build Command:";
|
*output += "\nRun Build Command:";
|
||||||
*output += makeCommand;
|
*output += makeCommandStr;
|
||||||
*output += "\n";
|
*output += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<cmStdString> command =
|
if (!cmSystemTools::RunSingleCommand(makeCommand, outputPtr,
|
||||||
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,
|
|
||||||
&retVal, 0, outputflag, timeout))
|
&retVal, 0, outputflag, timeout))
|
||||||
{
|
{
|
||||||
cmSystemTools::SetRunCommandHideConsole(hideconsole);
|
cmSystemTools::SetRunCommandHideConsole(hideconsole);
|
||||||
cmSystemTools::Error
|
cmSystemTools::Error
|
||||||
("Generator: execution of make failed. Make command was: ",
|
("Generator: execution of make failed. Make command was: ",
|
||||||
makeCommand.c_str());
|
makeCommandStr.c_str());
|
||||||
if (output)
|
if (output)
|
||||||
{
|
{
|
||||||
*output += *outputPtr;
|
*output += *outputPtr;
|
||||||
*output += "\nGenerator: execution of make failed. Make command was: "
|
*output += "\nGenerator: execution of make failed. Make command was: "
|
||||||
+ makeCommand + "\n";
|
+ makeCommandStr + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// return to the original directory
|
// return to the original directory
|
||||||
|
|
|
@ -123,16 +123,16 @@ public:
|
||||||
bool clean, bool fast,
|
bool clean, bool fast,
|
||||||
double timeout,
|
double timeout,
|
||||||
cmSystemTools::OutputOption outputflag=cmSystemTools::OUTPUT_NONE,
|
cmSystemTools::OutputOption outputflag=cmSystemTools::OUTPUT_NONE,
|
||||||
const char* extraOptions = 0,
|
|
||||||
std::vector<std::string> const& nativeOptions =
|
std::vector<std::string> const& nativeOptions =
|
||||||
std::vector<std::string>());
|
std::vector<std::string>());
|
||||||
|
|
||||||
virtual std::string GenerateBuildCommand(
|
virtual void GenerateBuildCommand(
|
||||||
|
std::vector<std::string>& makeCommand,
|
||||||
const char* makeProgram,
|
const char* makeProgram,
|
||||||
const char *projectName, const char *projectDir,
|
const char *projectName, const char *projectDir,
|
||||||
const char* additionalOptions,
|
const char *targetName, const char* config, bool fast,
|
||||||
const char *targetName, const char* config,
|
std::vector<std::string> const& makeOptions = std::vector<std::string>()
|
||||||
bool ignoreErrors, bool fast);
|
);
|
||||||
|
|
||||||
/** Generate a "cmake --build" call for a given target and config. */
|
/** Generate a "cmake --build" call for a given target and config. */
|
||||||
std::string GenerateCMakeBuildCommand(const char* target,
|
std::string GenerateCMakeBuildCommand(const char* target,
|
||||||
|
|
|
@ -549,47 +549,32 @@ bool cmGlobalNinjaGenerator::UsingMinGW = false;
|
||||||
// cmGlobalXCodeGenerator
|
// cmGlobalXCodeGenerator
|
||||||
// Called by:
|
// Called by:
|
||||||
// cmGlobalGenerator::Build()
|
// cmGlobalGenerator::Build()
|
||||||
std::string cmGlobalNinjaGenerator
|
void cmGlobalNinjaGenerator
|
||||||
::GenerateBuildCommand(const char* makeProgram,
|
::GenerateBuildCommand(std::vector<std::string>& makeCommand,
|
||||||
const char* projectName,
|
const char* makeProgram,
|
||||||
const char* projectDir,
|
const char* /*projectName*/,
|
||||||
const char* additionalOptions,
|
const char* /*projectDir*/,
|
||||||
const char* targetName,
|
const char* targetName,
|
||||||
const char* config,
|
const char* /*config*/,
|
||||||
bool ignoreErrors,
|
bool /*fast*/,
|
||||||
bool fast)
|
std::vector<std::string> const& makeOptions)
|
||||||
{
|
{
|
||||||
// Project name & dir and config are not used yet.
|
makeCommand.push_back(makeProgram);
|
||||||
(void)projectName;
|
|
||||||
(void)projectDir;
|
|
||||||
(void)config;
|
|
||||||
// Ninja does not have -i equivalent option yet.
|
|
||||||
(void)ignoreErrors;
|
|
||||||
// We do not handle fast build yet.
|
|
||||||
(void)fast;
|
|
||||||
|
|
||||||
std::string makeCommand =
|
makeCommand.insert(makeCommand.end(),
|
||||||
cmSystemTools::ConvertToUnixOutputPath(makeProgram);
|
makeOptions.begin(), makeOptions.end());
|
||||||
|
if(targetName && *targetName)
|
||||||
if(additionalOptions)
|
|
||||||
{
|
|
||||||
makeCommand += " ";
|
|
||||||
makeCommand += additionalOptions;
|
|
||||||
}
|
|
||||||
if(targetName)
|
|
||||||
{
|
{
|
||||||
if(strcmp(targetName, "clean") == 0)
|
if(strcmp(targetName, "clean") == 0)
|
||||||
{
|
{
|
||||||
makeCommand += " -t clean";
|
makeCommand.push_back("-t");
|
||||||
|
makeCommand.push_back("clean");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
makeCommand += " ";
|
makeCommand.push_back(targetName);
|
||||||
makeCommand += targetName;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return makeCommand;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
|
@ -191,14 +191,16 @@ public:
|
||||||
bool optional);
|
bool optional);
|
||||||
|
|
||||||
/// Overloaded methods. @see cmGlobalGenerator::GenerateBuildCommand()
|
/// Overloaded methods. @see cmGlobalGenerator::GenerateBuildCommand()
|
||||||
virtual std::string GenerateBuildCommand(const char* makeProgram,
|
virtual void GenerateBuildCommand(
|
||||||
const char* projectName,
|
std::vector<std::string>& makeCommand,
|
||||||
const char* projectDir,
|
const char* makeProgram,
|
||||||
const char* additionalOptions,
|
const char* projectName,
|
||||||
const char* targetName,
|
const char* projectDir,
|
||||||
const char* config,
|
const char* targetName,
|
||||||
bool ignoreErrors,
|
const char* config,
|
||||||
bool fast);
|
bool fast,
|
||||||
|
std::vector<std::string> const& makeOptions = std::vector<std::string>()
|
||||||
|
);
|
||||||
|
|
||||||
// Setup target names
|
// Setup target names
|
||||||
virtual const char* GetAllTargetName() const { return "all"; }
|
virtual const char* GetAllTargetName() const { return "all"; }
|
||||||
|
|
|
@ -555,36 +555,27 @@ cmGlobalUnixMakefileGenerator3
|
||||||
this->WriteDirectoryRule2(ruleFileStream, lg, "preinstall", true, true);
|
this->WriteDirectoryRule2(ruleFileStream, lg, "preinstall", true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
std::string cmGlobalUnixMakefileGenerator3
|
void cmGlobalUnixMakefileGenerator3
|
||||||
::GenerateBuildCommand(const char* makeProgram, const char *projectName,
|
::GenerateBuildCommand(std::vector<std::string>& makeCommand,
|
||||||
const char *projectDir, const char* additionalOptions,
|
const char* makeProgram,
|
||||||
const char *targetName, const char* config,
|
const char* /*projectName*/,
|
||||||
bool ignoreErrors, bool fast)
|
const char* /*projectDir*/,
|
||||||
|
const char* targetName,
|
||||||
|
const char* /*config*/,
|
||||||
|
bool fast,
|
||||||
|
std::vector<std::string> const& makeOptions)
|
||||||
{
|
{
|
||||||
// Project name & dir and config are not used yet.
|
makeCommand.push_back(makeProgram);
|
||||||
(void)projectName;
|
|
||||||
(void)projectDir;
|
|
||||||
(void)config;
|
|
||||||
|
|
||||||
std::string makeCommand =
|
|
||||||
cmSystemTools::ConvertToUnixOutputPath(makeProgram);
|
|
||||||
|
|
||||||
// Since we have full control over the invocation of nmake, let us
|
// Since we have full control over the invocation of nmake, let us
|
||||||
// make it quiet.
|
// make it quiet.
|
||||||
if ( strcmp(this->GetName(), "NMake Makefiles") == 0 )
|
if ( strcmp(this->GetName(), "NMake Makefiles") == 0 )
|
||||||
{
|
{
|
||||||
makeCommand += " /NOLOGO ";
|
makeCommand.push_back("/NOLOGO");
|
||||||
}
|
|
||||||
if ( ignoreErrors )
|
|
||||||
{
|
|
||||||
makeCommand += " -i";
|
|
||||||
}
|
|
||||||
if ( additionalOptions )
|
|
||||||
{
|
|
||||||
makeCommand += " ";
|
|
||||||
makeCommand += additionalOptions;
|
|
||||||
}
|
}
|
||||||
|
makeCommand.insert(makeCommand.end(),
|
||||||
|
makeOptions.begin(), makeOptions.end());
|
||||||
if ( targetName && strlen(targetName))
|
if ( targetName && strlen(targetName))
|
||||||
{
|
{
|
||||||
cmLocalUnixMakefileGenerator3 *lg;
|
cmLocalUnixMakefileGenerator3 *lg;
|
||||||
|
@ -605,22 +596,19 @@ std::string cmGlobalUnixMakefileGenerator3
|
||||||
lg->GetMakefile()->MakeStartDirectoriesCurrent();
|
lg->GetMakefile()->MakeStartDirectoriesCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
makeCommand += " \"";
|
|
||||||
std::string tname = targetName;
|
std::string tname = targetName;
|
||||||
if(fast)
|
if(fast)
|
||||||
{
|
{
|
||||||
tname += "/fast";
|
tname += "/fast";
|
||||||
}
|
}
|
||||||
tname = lg->Convert(tname.c_str(),cmLocalGenerator::HOME_OUTPUT,
|
tname = lg->Convert(tname.c_str(),cmLocalGenerator::HOME_OUTPUT);
|
||||||
cmLocalGenerator::MAKEFILE);
|
cmSystemTools::ConvertToOutputSlashes(tname);
|
||||||
makeCommand += tname.c_str();
|
makeCommand.push_back(tname);
|
||||||
makeCommand += "\"";
|
|
||||||
if (!this->LocalGenerators.size())
|
if (!this->LocalGenerators.size())
|
||||||
{
|
{
|
||||||
delete lg;
|
delete lg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return makeCommand;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
|
@ -107,12 +107,16 @@ public:
|
||||||
std::string GetEmptyRuleHackDepends() { return this->EmptyRuleHackDepends; }
|
std::string GetEmptyRuleHackDepends() { return this->EmptyRuleHackDepends; }
|
||||||
|
|
||||||
// change the build command for speed
|
// change the build command for speed
|
||||||
virtual std::string GenerateBuildCommand
|
virtual void GenerateBuildCommand(
|
||||||
(const char* makeProgram,
|
std::vector<std::string>& makeCommand,
|
||||||
const char *projectName, const char *projectDir,
|
const char* makeProgram,
|
||||||
const char* additionalOptions,
|
const char* projectName,
|
||||||
const char *targetName,
|
const char* projectDir,
|
||||||
const char* config, bool ignoreErrors, bool fast);
|
const char* targetName,
|
||||||
|
const char* config,
|
||||||
|
bool fast,
|
||||||
|
std::vector<std::string> const& makeOptions = std::vector<std::string>()
|
||||||
|
);
|
||||||
|
|
||||||
/** Record per-target progress information. */
|
/** Record per-target progress information. */
|
||||||
void RecordTargetProgress(cmMakefileTargetGenerator* tg);
|
void RecordTargetProgress(cmMakefileTargetGenerator* tg);
|
||||||
|
|
|
@ -256,49 +256,43 @@ std::string cmGlobalVisualStudio10Generator::GetUserMacrosRegKeyBase()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string cmGlobalVisualStudio10Generator
|
void cmGlobalVisualStudio10Generator::GenerateBuildCommand(
|
||||||
::GenerateBuildCommand(const char* makeProgram,
|
std::vector<std::string>& makeCommand,
|
||||||
const char *projectName, const char *projectDir,
|
const char* makeProgram,
|
||||||
const char* additionalOptions, const char *targetName,
|
const char* projectName,
|
||||||
const char* config, bool ignoreErrors, bool fast)
|
const char* projectDir,
|
||||||
|
const char* targetName,
|
||||||
|
const char* config,
|
||||||
|
bool fast,
|
||||||
|
std::vector<std::string> const& makeOptions)
|
||||||
{
|
{
|
||||||
// now build the test
|
// now build the test
|
||||||
std::string makeCommand
|
std::string lowerCaseCommand = makeProgram;
|
||||||
= cmSystemTools::ConvertToOutputPath(makeProgram);
|
|
||||||
std::string lowerCaseCommand = makeCommand;
|
|
||||||
cmSystemTools::LowerCase(lowerCaseCommand);
|
cmSystemTools::LowerCase(lowerCaseCommand);
|
||||||
|
|
||||||
// If makeProgram is devenv, parent class knows how to generate command:
|
// If makeProgram is devenv, parent class knows how to generate command:
|
||||||
if (lowerCaseCommand.find("devenv") != std::string::npos ||
|
if (lowerCaseCommand.find("devenv") != std::string::npos ||
|
||||||
lowerCaseCommand.find("VCExpress") != std::string::npos)
|
lowerCaseCommand.find("VCExpress") != std::string::npos)
|
||||||
{
|
{
|
||||||
return cmGlobalVisualStudio7Generator::GenerateBuildCommand(makeProgram,
|
cmGlobalVisualStudio7Generator::GenerateBuildCommand(
|
||||||
projectName, projectDir, additionalOptions, targetName, config,
|
makeCommand, makeProgram, projectName, projectDir,
|
||||||
ignoreErrors, fast);
|
targetName, config, fast, makeOptions);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, assume MSBuild command line, and construct accordingly.
|
// Otherwise, assume MSBuild command line, and construct accordingly.
|
||||||
|
|
||||||
// if there are spaces in the makeCommand, assume a full path
|
makeCommand.push_back(makeProgram);
|
||||||
// and convert it to a path with no spaces in it as the
|
|
||||||
// RunSingleCommand does not like spaces
|
|
||||||
if(makeCommand.find(' ') != std::string::npos)
|
|
||||||
{
|
|
||||||
cmSystemTools::GetShortPath(makeCommand.c_str(), makeCommand);
|
|
||||||
}
|
|
||||||
// msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD
|
// msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD
|
||||||
if(!targetName || strlen(targetName) == 0)
|
if(!targetName || strlen(targetName) == 0)
|
||||||
{
|
{
|
||||||
targetName = "ALL_BUILD";
|
targetName = "ALL_BUILD";
|
||||||
}
|
}
|
||||||
bool clean = false;
|
|
||||||
if ( targetName && strcmp(targetName, "clean") == 0 )
|
if ( targetName && strcmp(targetName, "clean") == 0 )
|
||||||
{
|
{
|
||||||
clean = true;
|
makeCommand.push_back(std::string(projectName)+".sln");
|
||||||
makeCommand += " ";
|
makeCommand.push_back("/t:Clean");
|
||||||
makeCommand += projectName;
|
|
||||||
makeCommand += ".sln ";
|
|
||||||
makeCommand += "/t:Clean ";
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -331,27 +325,22 @@ std::string cmGlobalVisualStudio10Generator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
makeCommand += " ";
|
makeCommand.push_back(targetProject);
|
||||||
makeCommand += targetProject;
|
|
||||||
makeCommand += " ";
|
|
||||||
}
|
}
|
||||||
makeCommand += "/p:Configuration=";
|
std::string configArg = "/p:Configuration=";
|
||||||
if(config && strlen(config))
|
if(config && strlen(config))
|
||||||
{
|
{
|
||||||
makeCommand += config;
|
configArg += config;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
makeCommand += "Debug";
|
configArg += "Debug";
|
||||||
}
|
}
|
||||||
makeCommand += " /p:VisualStudioVersion=";
|
makeCommand.push_back(configArg);
|
||||||
makeCommand += this->GetIDEVersion();
|
makeCommand.push_back(std::string("/p:VisualStudioVersion=")+
|
||||||
if ( additionalOptions )
|
this->GetIDEVersion());
|
||||||
{
|
makeCommand.insert(makeCommand.end(),
|
||||||
makeCommand += " ";
|
makeOptions.begin(), makeOptions.end());
|
||||||
makeCommand += additionalOptions;
|
|
||||||
}
|
|
||||||
return makeCommand;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
|
@ -32,11 +32,16 @@ public:
|
||||||
|
|
||||||
virtual bool SetGeneratorToolset(std::string const& ts);
|
virtual bool SetGeneratorToolset(std::string const& ts);
|
||||||
|
|
||||||
virtual std::string
|
virtual void GenerateBuildCommand(
|
||||||
GenerateBuildCommand(const char* makeProgram,
|
std::vector<std::string>& makeCommand,
|
||||||
const char *projectName, const char *projectDir,
|
const char* makeProgram,
|
||||||
const char* additionalOptions, const char *targetName,
|
const char* projectName,
|
||||||
const char* config, bool ignoreErrors, bool);
|
const char* projectDir,
|
||||||
|
const char* targetName,
|
||||||
|
const char* config,
|
||||||
|
bool fast,
|
||||||
|
std::vector<std::string> const& makeOptions = std::vector<std::string>()
|
||||||
|
);
|
||||||
|
|
||||||
virtual void AddPlatformDefinitions(cmMakefile* mf);
|
virtual void AddPlatformDefinitions(cmMakefile* mf);
|
||||||
|
|
||||||
|
|
|
@ -77,52 +77,41 @@ void cmGlobalVisualStudio6Generator::GenerateConfigurations(cmMakefile* mf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string cmGlobalVisualStudio6Generator
|
void
|
||||||
::GenerateBuildCommand(const char* makeProgram,
|
cmGlobalVisualStudio6Generator::GenerateBuildCommand(
|
||||||
const char *projectName,
|
std::vector<std::string>& makeCommand,
|
||||||
const char *projectDir,
|
const char* makeProgram,
|
||||||
const char* additionalOptions,
|
const char* projectName,
|
||||||
const char *targetName,
|
const char* /*projectDir*/,
|
||||||
const char* config,
|
const char* targetName,
|
||||||
bool ignoreErrors,
|
const char* config,
|
||||||
bool)
|
bool /*fast*/,
|
||||||
|
std::vector<std::string> const& makeOptions
|
||||||
|
)
|
||||||
{
|
{
|
||||||
// Visual studio 6 doesn't need project dir
|
|
||||||
(void) projectDir;
|
|
||||||
// Ingoring errors is not implemented in visual studio 6
|
|
||||||
(void) ignoreErrors;
|
|
||||||
|
|
||||||
// now build the test
|
// now build the test
|
||||||
std::vector<std::string> mp;
|
std::vector<std::string> mp;
|
||||||
mp.push_back("[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio"
|
mp.push_back("[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio"
|
||||||
"\\6.0\\Setup;VsCommonDir]/MSDev98/Bin");
|
"\\6.0\\Setup;VsCommonDir]/MSDev98/Bin");
|
||||||
cmSystemTools::ExpandRegistryValues(mp[0]);
|
cmSystemTools::ExpandRegistryValues(mp[0]);
|
||||||
std::string originalCommand = makeProgram;
|
std::string originalCommand = makeProgram;
|
||||||
std::string makeCommand =
|
std::string makeCommandFound =
|
||||||
cmSystemTools::FindProgram(makeProgram, mp);
|
cmSystemTools::FindProgram(makeProgram, mp);
|
||||||
if(makeCommand.size() == 0)
|
if(makeCommandFound.size() == 0)
|
||||||
{
|
{
|
||||||
std::string e = "Generator cannot find Visual Studio 6 msdev program \"";
|
std::string e = "Generator cannot find Visual Studio 6 msdev program \"";
|
||||||
e += originalCommand;
|
e += originalCommand;
|
||||||
e += "\" specified by CMAKE_MAKE_PROGRAM cache entry. ";
|
e += "\" specified by CMAKE_MAKE_PROGRAM cache entry. ";
|
||||||
e += "Please fix the setting.";
|
e += "Please fix the setting.";
|
||||||
cmSystemTools::Error(e.c_str());
|
cmSystemTools::Error(e.c_str());
|
||||||
return "";
|
return;
|
||||||
}
|
}
|
||||||
makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand.c_str());
|
|
||||||
|
|
||||||
// if there are spaces in the makeCommand, assume a full path
|
makeCommand.push_back(makeCommandFound);
|
||||||
// and convert it to a path with no spaces in it as the
|
|
||||||
// RunSingleCommand does not like spaces
|
makeCommand.push_back(std::string(projectName)+".dsw");
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
makeCommand.push_back("/MAKE");
|
||||||
if(makeCommand.find(' ') != std::string::npos)
|
std::string targetArg;
|
||||||
{
|
|
||||||
cmSystemTools::GetShortPath(makeCommand.c_str(), makeCommand);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
makeCommand += " ";
|
|
||||||
makeCommand += projectName;
|
|
||||||
makeCommand += ".dsw /MAKE \"";
|
|
||||||
bool clean = false;
|
bool clean = false;
|
||||||
if ( targetName && strcmp(targetName, "clean") == 0 )
|
if ( targetName && strcmp(targetName, "clean") == 0 )
|
||||||
{
|
{
|
||||||
|
@ -131,35 +120,32 @@ std::string cmGlobalVisualStudio6Generator
|
||||||
}
|
}
|
||||||
if (targetName && strlen(targetName))
|
if (targetName && strlen(targetName))
|
||||||
{
|
{
|
||||||
makeCommand += targetName;
|
targetArg += targetName;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
makeCommand += "ALL_BUILD";
|
targetArg += "ALL_BUILD";
|
||||||
}
|
}
|
||||||
makeCommand += " - ";
|
targetArg += " - ";
|
||||||
if(config && strlen(config))
|
if(config && strlen(config))
|
||||||
{
|
{
|
||||||
makeCommand += config;
|
targetArg += config;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
makeCommand += "Debug";
|
targetArg += "Debug";
|
||||||
}
|
}
|
||||||
|
makeCommand.push_back(targetArg);
|
||||||
if(clean)
|
if(clean)
|
||||||
{
|
{
|
||||||
makeCommand += "\" /CLEAN";
|
makeCommand.push_back("/CLEAN");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
makeCommand += "\" /BUILD";
|
makeCommand.push_back("/BUILD");
|
||||||
}
|
}
|
||||||
if ( additionalOptions )
|
makeCommand.insert(makeCommand.end(),
|
||||||
{
|
makeOptions.begin(), makeOptions.end());
|
||||||
makeCommand += " ";
|
|
||||||
makeCommand += additionalOptions;
|
|
||||||
}
|
|
||||||
return makeCommand;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///! Create a local generator appropriate to this Global Generator
|
///! Create a local generator appropriate to this Global Generator
|
||||||
|
|
|
@ -52,14 +52,16 @@ public:
|
||||||
* Try running cmake and building a file. This is used for dynalically
|
* Try running cmake and building a file. This is used for dynalically
|
||||||
* loaded commands, not as part of the usual build process.
|
* loaded commands, not as part of the usual build process.
|
||||||
*/
|
*/
|
||||||
virtual std::string GenerateBuildCommand(const char* makeProgram,
|
virtual void GenerateBuildCommand(
|
||||||
const char *projectName,
|
std::vector<std::string>& makeCommand,
|
||||||
const char *projectDir,
|
const char* makeProgram,
|
||||||
const char* additionalOptions,
|
const char* projectName,
|
||||||
const char *targetName,
|
const char* projectDir,
|
||||||
const char* config,
|
const char* targetName,
|
||||||
bool ignoreErrors,
|
const char* config,
|
||||||
bool fast);
|
bool fast,
|
||||||
|
std::vector<std::string> const& makeOptions = std::vector<std::string>()
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the all required files for building this project/tree. This
|
* Generate the all required files for building this project/tree. This
|
||||||
|
|
|
@ -110,35 +110,19 @@ void cmGlobalVisualStudio7Generator
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string cmGlobalVisualStudio7Generator
|
void cmGlobalVisualStudio7Generator::GenerateBuildCommand(
|
||||||
::GenerateBuildCommand(const char* makeProgram,
|
std::vector<std::string>& makeCommand,
|
||||||
const char *projectName, const char *projectDir,
|
const char* makeProgram,
|
||||||
const char* additionalOptions, const char *targetName,
|
const char* projectName,
|
||||||
const char* config, bool ignoreErrors, bool)
|
const char* /*projectDir*/,
|
||||||
|
const char* targetName,
|
||||||
|
const char* config,
|
||||||
|
bool /*fast*/,
|
||||||
|
std::vector<std::string> const& makeOptions)
|
||||||
{
|
{
|
||||||
// Visual studio 7 doesn't need project dir
|
makeCommand.push_back(makeProgram);
|
||||||
(void) projectDir;
|
|
||||||
// Ingoring errors is not implemented in visual studio 6
|
|
||||||
(void) ignoreErrors;
|
|
||||||
|
|
||||||
// now build the test
|
makeCommand.push_back(std::string(projectName) + ".sln");
|
||||||
std::string makeCommand =
|
|
||||||
cmSystemTools::ConvertToOutputPath(makeProgram);
|
|
||||||
std::string lowerCaseCommand = makeCommand;
|
|
||||||
cmSystemTools::LowerCase(lowerCaseCommand);
|
|
||||||
|
|
||||||
// if there are spaces in the makeCommand, assume a full path
|
|
||||||
// and convert it to a path with no spaces in it as the
|
|
||||||
// RunSingleCommand does not like spaces
|
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
||||||
if(makeCommand.find(' ') != std::string::npos)
|
|
||||||
{
|
|
||||||
cmSystemTools::GetShortPath(makeCommand.c_str(), makeCommand);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
makeCommand += " ";
|
|
||||||
makeCommand += projectName;
|
|
||||||
makeCommand += ".sln ";
|
|
||||||
bool clean = false;
|
bool clean = false;
|
||||||
if ( targetName && strcmp(targetName, "clean") == 0 )
|
if ( targetName && strcmp(targetName, "clean") == 0 )
|
||||||
{
|
{
|
||||||
|
@ -147,37 +131,33 @@ std::string cmGlobalVisualStudio7Generator
|
||||||
}
|
}
|
||||||
if(clean)
|
if(clean)
|
||||||
{
|
{
|
||||||
makeCommand += "/clean ";
|
makeCommand.push_back("/clean");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
makeCommand += "/build ";
|
makeCommand.push_back("/build");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(config && strlen(config))
|
if(config && strlen(config))
|
||||||
{
|
{
|
||||||
makeCommand += config;
|
makeCommand.push_back(config);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
makeCommand += "Debug";
|
makeCommand.push_back("Debug");
|
||||||
}
|
}
|
||||||
makeCommand += " /project ";
|
makeCommand.push_back("/project");
|
||||||
|
|
||||||
if (targetName && strlen(targetName))
|
if (targetName && strlen(targetName))
|
||||||
{
|
{
|
||||||
makeCommand += targetName;
|
makeCommand.push_back(targetName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
makeCommand += "ALL_BUILD";
|
makeCommand.push_back("ALL_BUILD");
|
||||||
}
|
}
|
||||||
if ( additionalOptions )
|
makeCommand.insert(makeCommand.end(),
|
||||||
{
|
makeOptions.begin(), makeOptions.end());
|
||||||
makeCommand += " ";
|
|
||||||
makeCommand += additionalOptions;
|
|
||||||
}
|
|
||||||
return makeCommand;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///! Create a local generator appropriate to this Global Generator
|
///! Create a local generator appropriate to this Global Generator
|
||||||
|
|
|
@ -60,14 +60,16 @@ public:
|
||||||
* Try running cmake and building a file. This is used for dynamically
|
* Try running cmake and building a file. This is used for dynamically
|
||||||
* loaded commands, not as part of the usual build process.
|
* loaded commands, not as part of the usual build process.
|
||||||
*/
|
*/
|
||||||
virtual std::string GenerateBuildCommand(const char* makeProgram,
|
virtual void GenerateBuildCommand(
|
||||||
const char *projectName,
|
std::vector<std::string>& makeCommand,
|
||||||
const char *projectDir,
|
const char* makeProgram,
|
||||||
const char* additionalOptions,
|
const char* projectName,
|
||||||
const char *targetName,
|
const char* projectDir,
|
||||||
const char* config,
|
const char* targetName,
|
||||||
bool ignoreErrors,
|
const char* config,
|
||||||
bool fast);
|
bool fast,
|
||||||
|
std::vector<std::string> const& makeOptions = std::vector<std::string>()
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the all required files for building this project/tree. This
|
* Generate the all required files for building this project/tree. This
|
||||||
|
|
|
@ -257,39 +257,34 @@ void cmGlobalXCodeGenerator::EnableLanguage(std::vector<std::string>const&
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
std::string cmGlobalXCodeGenerator
|
void
|
||||||
::GenerateBuildCommand(const char* makeProgram,
|
cmGlobalXCodeGenerator::GenerateBuildCommand(
|
||||||
const char *projectName,
|
std::vector<std::string>& makeCommand,
|
||||||
const char *projectDir,
|
const char* makeProgram,
|
||||||
const char* additionalOptions,
|
const char* projectName,
|
||||||
const char *targetName,
|
const char* /*projectDir*/,
|
||||||
const char* config,
|
const char* targetName,
|
||||||
bool ignoreErrors,
|
const char* config,
|
||||||
bool)
|
bool /*fast*/,
|
||||||
|
std::vector<std::string> const& makeOptions)
|
||||||
{
|
{
|
||||||
// Config is not used yet
|
|
||||||
(void) ignoreErrors;
|
|
||||||
(void) projectDir;
|
|
||||||
|
|
||||||
// now build the test
|
// now build the test
|
||||||
if(makeProgram == 0 || !strlen(makeProgram))
|
if(makeProgram == 0 || !strlen(makeProgram))
|
||||||
{
|
{
|
||||||
cmSystemTools::Error(
|
cmSystemTools::Error(
|
||||||
"Generator cannot find the appropriate make command.");
|
"Generator cannot find the appropriate make command.");
|
||||||
return "";
|
return;
|
||||||
}
|
}
|
||||||
std::string makeCommand =
|
makeCommand.push_back(makeProgram);
|
||||||
cmSystemTools::ConvertToOutputPath(makeProgram);
|
|
||||||
std::string lowerCaseCommand = makeCommand;
|
|
||||||
cmSystemTools::LowerCase(lowerCaseCommand);
|
|
||||||
|
|
||||||
makeCommand += " -project ";
|
makeCommand.push_back("-project");
|
||||||
makeCommand += projectName;
|
std::string projectArg = projectName;
|
||||||
makeCommand += ".xcode";
|
projectArg += ".xcode";
|
||||||
if(this->XcodeVersion > 20)
|
if(this->XcodeVersion > 20)
|
||||||
{
|
{
|
||||||
makeCommand += "proj";
|
projectArg += "proj";
|
||||||
}
|
}
|
||||||
|
makeCommand.push_back(projectArg);
|
||||||
|
|
||||||
bool clean = false;
|
bool clean = false;
|
||||||
if ( targetName && strcmp(targetName, "clean") == 0 )
|
if ( targetName && strcmp(targetName, "clean") == 0 )
|
||||||
|
@ -299,13 +294,13 @@ std::string cmGlobalXCodeGenerator
|
||||||
}
|
}
|
||||||
if(clean)
|
if(clean)
|
||||||
{
|
{
|
||||||
makeCommand += " clean";
|
makeCommand.push_back("clean");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
makeCommand += " build";
|
makeCommand.push_back("build");
|
||||||
}
|
}
|
||||||
makeCommand += " -target ";
|
makeCommand.push_back("-target");
|
||||||
// if it is a null string for config don't use it
|
// if it is a null string for config don't use it
|
||||||
if(config && *config == 0)
|
if(config && *config == 0)
|
||||||
{
|
{
|
||||||
|
@ -313,27 +308,24 @@ std::string cmGlobalXCodeGenerator
|
||||||
}
|
}
|
||||||
if (targetName && strlen(targetName))
|
if (targetName && strlen(targetName))
|
||||||
{
|
{
|
||||||
makeCommand += targetName;
|
makeCommand.push_back(targetName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
makeCommand += "ALL_BUILD";
|
makeCommand.push_back("ALL_BUILD");
|
||||||
}
|
}
|
||||||
if(this->XcodeVersion == 15)
|
if(this->XcodeVersion == 15)
|
||||||
{
|
{
|
||||||
makeCommand += " -buildstyle Development ";
|
makeCommand.push_back("-buildstyle");
|
||||||
|
makeCommand.push_back("Development");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
makeCommand += " -configuration ";
|
makeCommand.push_back("-configuration");
|
||||||
makeCommand += config?config:"Debug";
|
makeCommand.push_back(config?config:"Debug");
|
||||||
}
|
}
|
||||||
if ( additionalOptions )
|
makeCommand.insert(makeCommand.end(),
|
||||||
{
|
makeOptions.begin(), makeOptions.end());
|
||||||
makeCommand += " ";
|
|
||||||
makeCommand += additionalOptions;
|
|
||||||
}
|
|
||||||
return makeCommand;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
|
@ -53,14 +53,16 @@ public:
|
||||||
* Try running cmake and building a file. This is used for dynalically
|
* Try running cmake and building a file. This is used for dynalically
|
||||||
* loaded commands, not as part of the usual build process.
|
* loaded commands, not as part of the usual build process.
|
||||||
*/
|
*/
|
||||||
virtual std::string GenerateBuildCommand(const char* makeProgram,
|
virtual void GenerateBuildCommand(
|
||||||
const char *projectName,
|
std::vector<std::string>& makeCommand,
|
||||||
const char *projectDir,
|
const char* makeProgram,
|
||||||
const char* additionalOptions,
|
const char* projectName,
|
||||||
const char *targetName,
|
const char* projectDir,
|
||||||
const char* config,
|
const char* targetName,
|
||||||
bool ignoreErrors,
|
const char* config,
|
||||||
bool fast);
|
bool fast,
|
||||||
|
std::vector<std::string> const& makeOptions = std::vector<std::string>()
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the all required files for building this project/tree. This
|
* Generate the all required files for building this project/tree. This
|
||||||
|
|
|
@ -2682,7 +2682,7 @@ int cmake::Build(const std::string& dir,
|
||||||
makeProgram.c_str(),
|
makeProgram.c_str(),
|
||||||
config.c_str(), clean, false, 0,
|
config.c_str(), clean, false, 0,
|
||||||
cmSystemTools::OUTPUT_PASSTHROUGH,
|
cmSystemTools::OUTPUT_PASSTHROUGH,
|
||||||
0, nativeOptions);
|
nativeOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmake::WatchUnusedCli(const char* var)
|
void cmake::WatchUnusedCli(const char* var)
|
||||||
|
|
Loading…
Reference in New Issue