CPack: Fix make tool selection during preinstall (#15483)
The CMAKE_MAKE_PROGRAM selected by CMake while configuring the project should also be used to drive the "preinstall" target during packaging. Teach CPack to use "cmake --build" instead of constructing the build command line itself. The "cmake --build" command already knows how to select the proper make tool.
This commit is contained in:
parent
ed989122c3
commit
93a3ec8b77
|
@ -655,26 +655,19 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
|
||||||
cmSystemTools::SetForceUnixPaths(globalGenerator->GetForceUnixPaths());
|
cmSystemTools::SetForceUnixPaths(globalGenerator->GetForceUnixPaths());
|
||||||
|
|
||||||
// Does this generator require pre-install?
|
// Does this generator require pre-install?
|
||||||
if ( globalGenerator->GetPreinstallTargetName() )
|
if (const char* preinstall = globalGenerator->GetPreinstallTargetName())
|
||||||
{
|
{
|
||||||
globalGenerator->FindMakeProgram(this->MakefileMap);
|
std::string buildCommand =
|
||||||
std::string cmakeMakeProgram
|
globalGenerator->GenerateCMakeBuildCommand(
|
||||||
= this->MakefileMap->GetSafeDefinition("CMAKE_MAKE_PROGRAM");
|
preinstall, buildConfig, "", false);
|
||||||
std::vector<std::string> buildCommand;
|
|
||||||
globalGenerator->GenerateBuildCommand(buildCommand, cmakeMakeProgram,
|
|
||||||
installProjectName, installDirectory,
|
|
||||||
globalGenerator->GetPreinstallTargetName(),
|
|
||||||
buildConfig, false, false);
|
|
||||||
std::string buildCommandStr =
|
|
||||||
cmSystemTools::PrintSingleCommand(buildCommand);
|
|
||||||
cmCPackLogger(cmCPackLog::LOG_DEBUG,
|
cmCPackLogger(cmCPackLog::LOG_DEBUG,
|
||||||
"- Install command: " << buildCommandStr << std::endl);
|
"- Install command: " << buildCommand << 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,
|
cmSystemTools::RunSingleCommand(buildCommand.c_str(),
|
||||||
&output,
|
&output,
|
||||||
&retVal,
|
&retVal,
|
||||||
installDirectory.c_str(),
|
installDirectory.c_str(),
|
||||||
|
@ -684,12 +677,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: " << buildCommandStr << std::endl
|
ofs << "# Run command: " << buildCommand << std::endl
|
||||||
<< "# Directory: " << installDirectory << std::endl
|
<< "# Directory: " << installDirectory << std::endl
|
||||||
<< "# Output:" << std::endl
|
<< "# Output:" << std::endl
|
||||||
<< output << std::endl;
|
<< output << std::endl;
|
||||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||||
"Problem running install command: " << buildCommandStr
|
"Problem running install command: " << buildCommand
|
||||||
<< std::endl
|
<< std::endl
|
||||||
<< "Please check " << tmpFile << " for errors"
|
<< "Please check " << tmpFile << " for errors"
|
||||||
<< std::endl);
|
<< std::endl);
|
||||||
|
|
Loading…
Reference in New Issue