ENH: Add support for stipping and make more things overwritable

This commit is contained in:
Andy Cedilnik 2006-05-02 08:49:01 -04:00
parent 3eea1990f5
commit 2324e7ec5d
6 changed files with 64 additions and 18 deletions

View File

@ -269,6 +269,7 @@ IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
SET(CPACK_NSIS_CONTACT "cmake@cmake.org") SET(CPACK_NSIS_CONTACT "cmake@cmake.org")
SET(CPACK_NSIS_MODIFY_PATH ON) SET(CPACK_NSIS_MODIFY_PATH ON)
ELSE(WIN32 AND NOT UNIX) ELSE(WIN32 AND NOT UNIX)
SET(CPACK_STRIP_FILES "bin/ccmake;bin/cmake;bin/cpack;bin/ctest")
SET(CPACK_PACKAGE_EXECUTABLES "ccmake" "CMake") SET(CPACK_PACKAGE_EXECUTABLES "ccmake" "CMake")
ENDIF(WIN32 AND NOT UNIX) ENDIF(WIN32 AND NOT UNIX)
INCLUDE(CPack) INCLUDE(CPack)

View File

@ -68,15 +68,15 @@ int cmCPackGenericGenerator::PrepareNames()
std::string outFile = topDirectory + "/" + outName; std::string outFile = topDirectory + "/" + outName;
std::string installPrefix = tempDirectory + this->GetInstallPrefix(); std::string installPrefix = tempDirectory + this->GetInstallPrefix();
this->SetOption("CPACK_TOPLEVEL_DIRECTORY", topDirectory.c_str()); this->SetOptionIfNotSet("CPACK_TOPLEVEL_DIRECTORY", topDirectory.c_str());
this->SetOption("CPACK_TEMPORARY_DIRECTORY", tempDirectory.c_str()); this->SetOptionIfNotSet("CPACK_TEMPORARY_DIRECTORY", tempDirectory.c_str());
this->SetOption("CPACK_OUTPUT_FILE_NAME", outName.c_str()); this->SetOptionIfNotSet("CPACK_OUTPUT_FILE_NAME", outName.c_str());
this->SetOption("CPACK_OUTPUT_FILE_PATH", destFile.c_str()); this->SetOptionIfNotSet("CPACK_OUTPUT_FILE_PATH", destFile.c_str());
this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME", outFile.c_str()); this->SetOptionIfNotSet("CPACK_TEMPORARY_PACKAGE_FILE_NAME", outFile.c_str());
this->SetOption("CPACK_INSTALL_DIRECTORY", this->GetInstallPath()); this->SetOptionIfNotSet("CPACK_INSTALL_DIRECTORY", this->GetInstallPath());
this->SetOption("CPACK_NATIVE_INSTALL_DIRECTORY", this->SetOptionIfNotSet("CPACK_NATIVE_INSTALL_DIRECTORY",
cmsys::SystemTools::ConvertToOutputPath(this->GetInstallPath()).c_str()); cmsys::SystemTools::ConvertToOutputPath(this->GetInstallPath()).c_str());
this->SetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY", installPrefix.c_str()); this->SetOptionIfNotSet("CPACK_TEMPORARY_INSTALL_DIRECTORY", installPrefix.c_str());
cmCPackLogger(cmCPackLog::LOG_DEBUG, cmCPackLogger(cmCPackLog::LOG_DEBUG,
"Look for: CPACK_PACKAGE_DESCRIPTION_FILE" << std::endl); "Look for: CPACK_PACKAGE_DESCRIPTION_FILE" << std::endl);
@ -108,7 +108,7 @@ int cmCPackGenericGenerator::PrepareNames()
{ {
ostr << cmSystemTools::MakeXMLSafe(line.c_str()) << std::endl; ostr << cmSystemTools::MakeXMLSafe(line.c_str()) << std::endl;
} }
this->SetOption("CPACK_PACKAGE_DESCRIPTION", ostr.str().c_str()); this->SetOptionIfNotSet("CPACK_PACKAGE_DESCRIPTION", ostr.str().c_str());
} }
if ( !this->GetOption("CPACK_PACKAGE_DESCRIPTION") ) if ( !this->GetOption("CPACK_PACKAGE_DESCRIPTION") )
{ {
@ -119,6 +119,13 @@ int cmCPackGenericGenerator::PrepareNames()
return 0; return 0;
} }
std::vector<std::string> path;
std::string pkgPath = cmSystemTools::FindProgram("strip", path, false);
if ( !pkgPath.empty() )
{
this->SetOptionIfNotSet("CPACK_STRIP_COMMAND", pkgPath.c_str());
}
return 1; return 1;
} }
@ -432,6 +439,44 @@ int cmCPackGenericGenerator::InstallProject()
{ {
cmSystemTools::PutEnv("DESTDIR="); cmSystemTools::PutEnv("DESTDIR=");
} }
const char* stripExecutable = this->GetOption("CPACK_STRIP_COMMAND");
const char* stripFiles
= this->GetOption("CPACK_STRIP_FILES");
if ( stripFiles && *stripFiles && stripExecutable && *stripExecutable )
{
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Strip files" << std::endl);
std::vector<std::string> stripFilesVector;
cmSystemTools::ExpandListArgument(stripFiles,
stripFilesVector);
std::vector<std::string>::iterator it;
for ( it = stripFilesVector.begin();
it != stripFilesVector.end();
++it )
{
std::string fileName = tempInstallDirectory;
fileName += "/" + *it;
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
" Strip file: " << fileName.c_str()
<< std::endl);
std::string stripCommand = stripExecutable;
stripCommand += " \"";
stripCommand += fileName + "\"";
int retVal = 1;
std::string output;
bool resB = cmSystemTools::RunSingleCommand(stripCommand.c_str(), &output,
&retVal, 0, this->GeneratorVerbose, 0);
if ( !resB || retVal )
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem running install command: " << stripCommand.c_str()
<< std::endl
<< "Error was: \"" << output.c_str() << "\""
<< std::endl);
return 0;
}
}
}
return res; return res;
} }

View File

@ -78,7 +78,7 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName,
} }
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Files: " cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Files: "
<< str.str().c_str() << std::endl); << str.str().c_str() << std::endl);
this->SetOption("CPACK_NSIS_DELETE_FILES", str.str().c_str()); this->SetOptionIfNotSet("CPACK_NSIS_DELETE_FILES", str.str().c_str());
std::vector<std::string> dirs; std::vector<std::string> dirs;
this->GetListOfSubdirectories(toplevel, dirs); this->GetListOfSubdirectories(toplevel, dirs);
std::vector<std::string>::const_iterator sit; std::vector<std::string>::const_iterator sit;
@ -96,7 +96,7 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName,
} }
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Dirs: " cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Dirs: "
<< dstr.str().c_str() << std::endl); << dstr.str().c_str() << std::endl);
this->SetOption("CPACK_NSIS_DELETE_DIRECTORIES", dstr.str().c_str()); this->SetOptionIfNotSet("CPACK_NSIS_DELETE_DIRECTORIES", dstr.str().c_str());
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << nsisInFileName cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << nsisInFileName
<< " to " << nsisFileName << std::endl); << " to " << nsisFileName << std::endl);
@ -193,7 +193,7 @@ int cmCPackNSISGenerator::InitializeInternal()
return 0; return 0;
} }
this->SetOption("CPACK_INSTALLER_PROGRAM", nsisPath.c_str()); this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", nsisPath.c_str());
const char* cpackPackageExecutables const char* cpackPackageExecutables
= this->GetOption("CPACK_PACKAGE_EXECUTABLES"); = this->GetOption("CPACK_PACKAGE_EXECUTABLES");
if ( cpackPackageExecutables ) if ( cpackPackageExecutables )
@ -226,8 +226,8 @@ int cmCPackNSISGenerator::InitializeInternal()
deleteStr << " Delete \"$SMPROGRAMS\\$MUI_TEMP\\" << linkName deleteStr << " Delete \"$SMPROGRAMS\\$MUI_TEMP\\" << linkName
<< ".lnk\"" << std::endl; << ".lnk\"" << std::endl;
} }
this->SetOption("CPACK_NSIS_CREATE_ICONS", str.str().c_str()); this->SetOptionIfNotSet("CPACK_NSIS_CREATE_ICONS", str.str().c_str());
this->SetOption("CPACK_NSIS_DELETE_ICONS", deleteStr.str().c_str()); this->SetOptionIfNotSet("CPACK_NSIS_DELETE_ICONS", deleteStr.str().c_str());
} }
return this->Superclass::InitializeInternal(); return this->Superclass::InitializeInternal();

View File

@ -213,7 +213,7 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
<< std::endl); << std::endl);
return 0; return 0;
} }
this->SetOption("CPACK_INSTALLER_PROGRAM", pkgPath.c_str()); this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", pkgPath.c_str());
pkgPath = cmSystemTools::FindProgram("hdiutil", path, false); pkgPath = cmSystemTools::FindProgram("hdiutil", path, false);
if ( pkgPath.empty() ) if ( pkgPath.empty() )
{ {
@ -221,7 +221,7 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
<< std::endl); << std::endl);
return 0; return 0;
} }
this->SetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE", pkgPath.c_str()); this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM_DISK_IMAGE", pkgPath.c_str());
return this->Superclass::InitializeInternal(); return this->Superclass::InitializeInternal();
} }

View File

@ -51,7 +51,7 @@ int cmCPackSTGZGenerator::InitializeInternal()
return 0; return 0;
} }
this->SetOptionIfNotSet("CPACK_STGZ_HEADER_FILE", inFile.c_str()); this->SetOptionIfNotSet("CPACK_STGZ_HEADER_FILE", inFile.c_str());
this->SetOption("CPACK_AT_SIGN", "@"); this->SetOptionIfNotSet("CPACK_AT_SIGN", "@");
return this->Superclass::InitializeInternal(); return this->Superclass::InitializeInternal();
} }

View File

@ -79,7 +79,7 @@ int cmCPackZIPGenerator::InitializeInternal()
<< std::endl); << std::endl);
return 0; return 0;
} }
this->SetOption("CPACK_INSTALLER_PROGRAM", pkgPath.c_str()); this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", pkgPath.c_str());
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Found ZIP program: " cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Found ZIP program: "
<< pkgPath.c_str() << pkgPath.c_str()
<< std::endl); << std::endl);