Add projectDir parameter to GenerateBuildCommand

Extend the cmGlobalGenerator::GenerateBuildCommand virtual method
signature with a "projectDir" parameter specifying the top of the
project build tree for which the build command will be generated.
Populate it from call sites in cmGlobalGenerator::Build where a
fully-generated build tree should be available.
This commit is contained in:
Petr Kmoch 2013-03-21 15:53:26 +01:00 committed by Brad King
parent 674f918a1a
commit de8be9ef7d
17 changed files with 41 additions and 21 deletions

View File

@ -638,7 +638,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
= this->MakefileMap->GetDefinition("CMAKE_MAKE_PROGRAM"); = this->MakefileMap->GetDefinition("CMAKE_MAKE_PROGRAM");
std::string buildCommand std::string buildCommand
= globalGenerator->GenerateBuildCommand(cmakeMakeProgram, = globalGenerator->GenerateBuildCommand(cmakeMakeProgram,
installProjectName.c_str(), 0, installProjectName.c_str(), 0, 0,
globalGenerator->GetPreinstallTargetName(), globalGenerator->GetPreinstallTargetName(),
buildConfig, false, false); buildConfig, false, false);
cmCPackLogger(cmCPackLog::LOG_DEBUG, cmCPackLogger(cmCPackLog::LOG_DEBUG,

View File

@ -133,7 +133,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
std::string buildCommand std::string buildCommand
= this->GlobalGenerator-> = this->GlobalGenerator->
GenerateBuildCommand(cmakeMakeProgram, GenerateBuildCommand(cmakeMakeProgram,
cmakeProjectName, cmakeProjectName, 0,
cmakeBuildAdditionalFlags, cmakeBuildTarget, cmakeBuildAdditionalFlags, cmakeBuildTarget,
cmakeBuildConfiguration, true, false); cmakeBuildConfiguration, true, false);
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,

View File

@ -122,7 +122,7 @@ bool cmBuildCommand
// //
std::string makecommand = this->Makefile->GetLocalGenerator() std::string makecommand = this->Makefile->GetLocalGenerator()
->GetGlobalGenerator()->GenerateBuildCommand ->GetGlobalGenerator()->GenerateBuildCommand
(makeprogram, project_name, 0, target, configuration, true, false); (makeprogram, project_name, 0, 0, target, configuration, true, false);
this->Makefile->AddDefinition(variable, makecommand.c_str()); this->Makefile->AddDefinition(variable, makecommand.c_str());
@ -153,7 +153,7 @@ bool cmBuildCommand
std::string makecommand = this->Makefile->GetLocalGenerator() std::string makecommand = this->Makefile->GetLocalGenerator()
->GetGlobalGenerator()->GenerateBuildCommand ->GetGlobalGenerator()->GenerateBuildCommand
(makeprogram.c_str(), this->Makefile->GetProjectName(), 0, (makeprogram.c_str(), this->Makefile->GetProjectName(), 0, 0,
0, configType.c_str(), true, false); 0, configType.c_str(), true, false);
if(cacheValue) if(cacheValue)

View File

@ -1340,11 +1340,13 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir,
std::string cmGlobalGenerator std::string cmGlobalGenerator
::GenerateBuildCommand(const char* makeProgram, const char *projectName, ::GenerateBuildCommand(const char* makeProgram, const char *projectName,
const char* additionalOptions, const char *targetName, const char *projectDir, const char* additionalOptions,
const char* config, bool ignoreErrors, bool) const char *targetName, const char* config,
bool ignoreErrors, bool)
{ {
// Project name and config are not used yet. // Project name & dir and config are not used yet.
(void)projectName; (void)projectName;
(void)projectDir;
(void)config; (void)config;
std::string makeCommand = std::string makeCommand =
@ -1411,7 +1413,7 @@ int cmGlobalGenerator::Build(
if (clean) if (clean)
{ {
std::string cleanCommand = std::string cleanCommand =
this->GenerateBuildCommand(makeCommandCSTR, projectName, this->GenerateBuildCommand(makeCommandCSTR, projectName, bindir,
0, "clean", config, false, fast); 0, "clean", config, false, fast);
if(output) if(output)
{ {
@ -1443,7 +1445,7 @@ int cmGlobalGenerator::Build(
// now build // now build
std::string makeCommand = std::string makeCommand =
this->GenerateBuildCommand(makeCommandCSTR, projectName, this->GenerateBuildCommand(makeCommandCSTR, projectName, bindir,
extraOptions, target, extraOptions, target,
config, false, fast); config, false, fast);
if(output) if(output)

View File

@ -121,9 +121,10 @@ public:
virtual std::string GenerateBuildCommand( virtual std::string GenerateBuildCommand(
const char* makeProgram, const char* makeProgram,
const char *projectName, const char* additionalOptions, const char *projectName, const char *projectDir,
const char *targetName, const char* additionalOptions,
const char* config, bool ignoreErrors, bool fast); const char *targetName, const char* config,
bool ignoreErrors, bool fast);
///! Set the CMake instance ///! Set the CMake instance

View File

@ -523,14 +523,16 @@ bool cmGlobalNinjaGenerator::UsingMinGW = false;
std::string cmGlobalNinjaGenerator std::string cmGlobalNinjaGenerator
::GenerateBuildCommand(const char* makeProgram, ::GenerateBuildCommand(const char* makeProgram,
const char* projectName, const char* projectName,
const char* projectDir,
const char* additionalOptions, const char* additionalOptions,
const char* targetName, const char* targetName,
const char* config, const char* config,
bool ignoreErrors, bool ignoreErrors,
bool fast) bool fast)
{ {
// Project name and config are not used yet. // Project name & dir and config are not used yet.
(void)projectName; (void)projectName;
(void)projectDir;
(void)config; (void)config;
// Ninja does not have -i equivalent option yet. // Ninja does not have -i equivalent option yet.
(void)ignoreErrors; (void)ignoreErrors;

View File

@ -191,6 +191,7 @@ public:
/// Overloaded methods. @see cmGlobalGenerator::GenerateBuildCommand() /// Overloaded methods. @see cmGlobalGenerator::GenerateBuildCommand()
virtual std::string GenerateBuildCommand(const char* makeProgram, virtual std::string GenerateBuildCommand(const char* makeProgram,
const char* projectName, const char* projectName,
const char* projectDir,
const char* additionalOptions, const char* additionalOptions,
const char* targetName, const char* targetName,
const char* config, const char* config,

View File

@ -517,11 +517,13 @@ cmGlobalUnixMakefileGenerator3
std::string cmGlobalUnixMakefileGenerator3 std::string cmGlobalUnixMakefileGenerator3
::GenerateBuildCommand(const char* makeProgram, const char *projectName, ::GenerateBuildCommand(const char* makeProgram, const char *projectName,
const char* additionalOptions, const char *targetName, const char *projectDir, const char* additionalOptions,
const char* config, bool ignoreErrors, bool fast) const char *targetName, const char* config,
bool ignoreErrors, bool fast)
{ {
// Project name and config are not used yet. // Project name & dir and config are not used yet.
(void)projectName; (void)projectName;
(void)projectDir;
(void)config; (void)config;
std::string makeCommand = std::string makeCommand =

View File

@ -107,7 +107,8 @@ public:
// change the build command for speed // change the build command for speed
virtual std::string GenerateBuildCommand virtual std::string GenerateBuildCommand
(const char* makeProgram, (const char* makeProgram,
const char *projectName, const char* additionalOptions, const char *projectName, const char *projectDir,
const char* additionalOptions,
const char *targetName, const char *targetName,
const char* config, bool ignoreErrors, bool fast); const char* config, bool ignoreErrors, bool fast);

View File

@ -215,7 +215,7 @@ std::string cmGlobalVisualStudio10Generator::GetUserMacrosRegKeyBase()
std::string cmGlobalVisualStudio10Generator std::string cmGlobalVisualStudio10Generator
::GenerateBuildCommand(const char* makeProgram, ::GenerateBuildCommand(const char* makeProgram,
const char *projectName, const char *projectName, const char *projectDir,
const char* additionalOptions, const char *targetName, const char* additionalOptions, const char *targetName,
const char* config, bool ignoreErrors, bool fast) const char* config, bool ignoreErrors, bool fast)
{ {
@ -230,7 +230,8 @@ std::string cmGlobalVisualStudio10Generator
lowerCaseCommand.find("VCExpress") != std::string::npos) lowerCaseCommand.find("VCExpress") != std::string::npos)
{ {
return cmGlobalVisualStudio7Generator::GenerateBuildCommand(makeProgram, return cmGlobalVisualStudio7Generator::GenerateBuildCommand(makeProgram,
projectName, additionalOptions, targetName, config, ignoreErrors, fast); projectName, projectDir, additionalOptions, targetName, config,
ignoreErrors, fast);
} }
// Otherwise, assume MSBuild command line, and construct accordingly. // Otherwise, assume MSBuild command line, and construct accordingly.

View File

@ -32,7 +32,7 @@ public:
virtual std::string virtual std::string
GenerateBuildCommand(const char* makeProgram, GenerateBuildCommand(const char* makeProgram,
const char *projectName, const char *projectName, const char *projectDir,
const char* additionalOptions, const char *targetName, const char* additionalOptions, const char *targetName,
const char* config, bool ignoreErrors, bool); const char* config, bool ignoreErrors, bool);

View File

@ -80,12 +80,15 @@ void cmGlobalVisualStudio6Generator::GenerateConfigurations(cmMakefile* mf)
std::string cmGlobalVisualStudio6Generator std::string cmGlobalVisualStudio6Generator
::GenerateBuildCommand(const char* makeProgram, ::GenerateBuildCommand(const char* makeProgram,
const char *projectName, const char *projectName,
const char *projectDir,
const char* additionalOptions, const char* additionalOptions,
const char *targetName, const char *targetName,
const char* config, const char* config,
bool ignoreErrors, bool ignoreErrors,
bool) bool)
{ {
// Visual studio 6 doesn't need project dir
(void) projectDir;
// Ingoring errors is not implemented in visual studio 6 // Ingoring errors is not implemented in visual studio 6
(void) ignoreErrors; (void) ignoreErrors;

View File

@ -54,6 +54,7 @@ public:
*/ */
virtual std::string GenerateBuildCommand(const char* makeProgram, virtual std::string GenerateBuildCommand(const char* makeProgram,
const char *projectName, const char *projectName,
const char *projectDir,
const char* additionalOptions, const char* additionalOptions,
const char *targetName, const char *targetName,
const char* config, const char* config,

View File

@ -56,10 +56,12 @@ void cmGlobalVisualStudio7Generator
std::string cmGlobalVisualStudio7Generator std::string cmGlobalVisualStudio7Generator
::GenerateBuildCommand(const char* makeProgram, ::GenerateBuildCommand(const char* makeProgram,
const char *projectName, const char *projectName, const char *projectDir,
const char* additionalOptions, const char *targetName, const char* additionalOptions, const char *targetName,
const char* config, bool ignoreErrors, bool) const char* config, bool ignoreErrors, bool)
{ {
// Visual studio 7 doesn't need project dir
(void) projectDir;
// Ingoring errors is not implemented in visual studio 6 // Ingoring errors is not implemented in visual studio 6
(void) ignoreErrors; (void) ignoreErrors;

View File

@ -55,6 +55,7 @@ public:
*/ */
virtual std::string GenerateBuildCommand(const char* makeProgram, virtual std::string GenerateBuildCommand(const char* makeProgram,
const char *projectName, const char *projectName,
const char *projectDir,
const char* additionalOptions, const char* additionalOptions,
const char *targetName, const char *targetName,
const char* config, const char* config,

View File

@ -260,6 +260,7 @@ void cmGlobalXCodeGenerator::EnableLanguage(std::vector<std::string>const&
std::string cmGlobalXCodeGenerator std::string cmGlobalXCodeGenerator
::GenerateBuildCommand(const char* makeProgram, ::GenerateBuildCommand(const char* makeProgram,
const char *projectName, const char *projectName,
const char *projectDir,
const char* additionalOptions, const char* additionalOptions,
const char *targetName, const char *targetName,
const char* config, const char* config,
@ -268,6 +269,7 @@ std::string cmGlobalXCodeGenerator
{ {
// Config is not used yet // Config is not used yet
(void) ignoreErrors; (void) ignoreErrors;
(void) projectDir;
// now build the test // now build the test
if(makeProgram == 0 || !strlen(makeProgram)) if(makeProgram == 0 || !strlen(makeProgram))

View File

@ -55,6 +55,7 @@ public:
*/ */
virtual std::string GenerateBuildCommand(const char* makeProgram, virtual std::string GenerateBuildCommand(const char* makeProgram,
const char *projectName, const char *projectName,
const char *projectDir,
const char* additionalOptions, const char* additionalOptions,
const char *targetName, const char *targetName,
const char* config, const char* config,