BUG: fix for 7738, allow for spaces in the package target path to CPackConfig files

This commit is contained in:
Bill Hoffman 2008-10-01 09:50:11 -04:00
parent ecf312ccc8
commit ab409fec89
2 changed files with 25 additions and 15 deletions

View File

@ -1559,6 +1559,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
const char* cmakeCommand = mf->GetRequiredDefinition("CMAKE_COMMAND"); const char* cmakeCommand = mf->GetRequiredDefinition("CMAKE_COMMAND");
// CPack // CPack
std::string workingDir = mf->GetStartOutputDirectory();
cmCustomCommandLines cpackCommandLines; cmCustomCommandLines cpackCommandLines;
std::vector<std::string> depends; std::vector<std::string> depends;
cmCustomCommandLine singleLine; cmCustomCommandLine singleLine;
@ -1571,7 +1572,8 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
singleLine.push_back("--config"); singleLine.push_back("--config");
std::string configFile = mf->GetStartOutputDirectory();; std::string configFile = mf->GetStartOutputDirectory();;
configFile += "/CPackConfig.cmake"; configFile += "/CPackConfig.cmake";
singleLine.push_back(configFile); std::string relConfigFile = "./CPackConfig.cmake";
singleLine.push_back(relConfigFile);
cpackCommandLines.push_back(singleLine); cpackCommandLines.push_back(singleLine);
if ( this->GetPreinstallTargetName() ) if ( this->GetPreinstallTargetName() )
{ {
@ -1591,7 +1593,8 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
(*targets)[this->GetPackageTargetName()] (*targets)[this->GetPackageTargetName()]
= this->CreateGlobalTarget(this->GetPackageTargetName(), = this->CreateGlobalTarget(this->GetPackageTargetName(),
"Run CPack packaging tool...", "Run CPack packaging tool...",
&cpackCommandLines, depends); &cpackCommandLines, depends,
workingDir.c_str());
} }
// CPack source // CPack source
const char* packageSourceTargetName = this->GetPackageSourceTargetName(); const char* packageSourceTargetName = this->GetPackageSourceTargetName();
@ -1603,8 +1606,10 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
depends.erase(depends.begin(), depends.end()); depends.erase(depends.begin(), depends.end());
singleLine.push_back(this->GetCMakeInstance()->GetCPackCommand()); singleLine.push_back(this->GetCMakeInstance()->GetCPackCommand());
singleLine.push_back("--config"); singleLine.push_back("--config");
configFile = mf->GetStartOutputDirectory();; std::string configFile = mf->GetStartOutputDirectory();;
configFile += "/CPackSourceConfig.cmake"; configFile += "/CPackSourceCConfig.cmake";
std::string relConfigFile = "./CPackSourceConfig.cmake";
singleLine.push_back(relConfigFile);
if(cmSystemTools::FileExists(configFile.c_str())) if(cmSystemTools::FileExists(configFile.c_str()))
{ {
singleLine.push_back(configFile); singleLine.push_back(configFile);
@ -1612,7 +1617,9 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
(*targets)[packageSourceTargetName] (*targets)[packageSourceTargetName]
= this->CreateGlobalTarget(packageSourceTargetName, = this->CreateGlobalTarget(packageSourceTargetName,
"Run CPack packaging tool for source...", "Run CPack packaging tool for source...",
&cpackCommandLines, depends); &cpackCommandLines, depends,
workingDir.c_str()
);
} }
} }
@ -1637,7 +1644,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
cpackCommandLines.push_back(singleLine); cpackCommandLines.push_back(singleLine);
(*targets)[this->GetTestTargetName()] (*targets)[this->GetTestTargetName()]
= this->CreateGlobalTarget(this->GetTestTargetName(), = this->CreateGlobalTarget(this->GetTestTargetName(),
"Running tests...", &cpackCommandLines, depends); "Running tests...", &cpackCommandLines, depends, 0);
} }
//Edit Cache //Edit Cache
@ -1660,7 +1667,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
(*targets)[editCacheTargetName] = (*targets)[editCacheTargetName] =
this->CreateGlobalTarget( this->CreateGlobalTarget(
editCacheTargetName, "Running CMake cache editor...", editCacheTargetName, "Running CMake cache editor...",
&cpackCommandLines, depends); &cpackCommandLines, depends, 0);
} }
else else
{ {
@ -1672,7 +1679,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
this->CreateGlobalTarget( this->CreateGlobalTarget(
editCacheTargetName, editCacheTargetName,
"Running interactive CMake command-line interface...", "Running interactive CMake command-line interface...",
&cpackCommandLines, depends); &cpackCommandLines, depends, 0);
} }
} }
@ -1691,7 +1698,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
(*targets)[rebuildCacheTargetName] = (*targets)[rebuildCacheTargetName] =
this->CreateGlobalTarget( this->CreateGlobalTarget(
rebuildCacheTargetName, "Running CMake to regenerate build system...", rebuildCacheTargetName, "Running CMake to regenerate build system...",
&cpackCommandLines, depends); &cpackCommandLines, depends, 0);
} }
//Install //Install
@ -1724,7 +1731,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
(*targets)["list_install_components"] (*targets)["list_install_components"]
= this->CreateGlobalTarget("list_install_components", = this->CreateGlobalTarget("list_install_components",
ostr.str().c_str(), ostr.str().c_str(),
&cpackCommandLines, depends); &cpackCommandLines, depends, 0);
} }
std::string cmd; std::string cmd;
cpackCommandLines.erase(cpackCommandLines.begin(), cpackCommandLines.erase(cpackCommandLines.begin(),
@ -1773,7 +1780,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
(*targets)[this->GetInstallTargetName()] = (*targets)[this->GetInstallTargetName()] =
this->CreateGlobalTarget( this->CreateGlobalTarget(
this->GetInstallTargetName(), "Install the project...", this->GetInstallTargetName(), "Install the project...",
&cpackCommandLines, depends); &cpackCommandLines, depends, 0);
// install_local // install_local
if(const char* install_local = this->GetInstallLocalTargetName()) if(const char* install_local = this->GetInstallLocalTargetName())
@ -1789,7 +1796,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
(*targets)[install_local] = (*targets)[install_local] =
this->CreateGlobalTarget( this->CreateGlobalTarget(
install_local, "Installing only the local directory...", install_local, "Installing only the local directory...",
&cpackCommandLines, depends); &cpackCommandLines, depends, 0);
} }
// install_strip // install_strip
@ -1806,7 +1813,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
(*targets)[install_strip] = (*targets)[install_strip] =
this->CreateGlobalTarget( this->CreateGlobalTarget(
install_strip, "Installing the project stripped...", install_strip, "Installing the project stripped...",
&cpackCommandLines, depends); &cpackCommandLines, depends, 0);
} }
} }
} }
@ -1815,6 +1822,7 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(
const char* name, const char* message, const char* name, const char* message,
const cmCustomCommandLines* commandLines, const cmCustomCommandLines* commandLines,
std::vector<std::string> depends, std::vector<std::string> depends,
const char* workingDirectory,
bool depends_on_all /* = false */) bool depends_on_all /* = false */)
{ {
// Package // Package
@ -1826,7 +1834,8 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(
std::vector<std::string> no_outputs; std::vector<std::string> no_outputs;
std::vector<std::string> no_depends; std::vector<std::string> no_depends;
// Store the custom command in the target. // Store the custom command in the target.
cmCustomCommand cc(no_outputs, no_depends, *commandLines, 0, 0); cmCustomCommand cc(no_outputs, no_depends, *commandLines, 0,
workingDirectory);
target.GetPostBuildCommands().push_back(cc); target.GetPostBuildCommands().push_back(cc);
target.SetProperty("EchoString", message); target.SetProperty("EchoString", message);
if ( depends_on_all ) if ( depends_on_all )

View File

@ -280,7 +280,8 @@ protected:
void CreateDefaultGlobalTargets(cmTargets* targets); void CreateDefaultGlobalTargets(cmTargets* targets);
cmTarget CreateGlobalTarget(const char* name, const char* message, cmTarget CreateGlobalTarget(const char* name, const char* message,
const cmCustomCommandLines* commandLines, const cmCustomCommandLines* commandLines,
std::vector<std::string> depends, bool depends_on_all = false); std::vector<std::string> depends, const char* workingDir,
bool depends_on_all = false);
bool NeedSymbolicMark; bool NeedSymbolicMark;
bool UseLinkScript; bool UseLinkScript;