ENH: Improved support for icons, random directories, etc...
This commit is contained in:
parent
2d29e48726
commit
3bce601c41
|
@ -230,12 +230,14 @@ IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
|||
SET(CPACK_PACKAGE_VERSION_MAJOR "${CMake_VERSION_MAJOR}")
|
||||
SET(CPACK_PACKAGE_VERSION_MINOR "${CMake_VERSION_MINOR}")
|
||||
SET(CPACK_PACKAGE_VERSION_PATCH "${CMake_VERSION_PATCH}")
|
||||
SET(CPACK_PACKAGE_EXECUTABLE "CMakeSetup")
|
||||
SET(CPACK_PACKAGE_EXECUTABLE_LABEL "CMake")
|
||||
|
||||
IF(WIN32 AND NOT UNIX)
|
||||
# There is a bug in NSI that does not handle full unix paths properly. Make
|
||||
# sure there is at least one set of four (4) backlasshes.
|
||||
SET(CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\CMakeInstall.bmp")
|
||||
SET(CPACK_PACKAGE_EXECUTABLE "CMakeSetup" "CMake")
|
||||
ELSE(WIN32 AND NOT UNIX)
|
||||
SET(CPACK_PACKAGE_EXECUTABLE "ccmake" "CMake")
|
||||
ENDIF(WIN32 AND NOT UNIX)
|
||||
INCLUDE(CPack)
|
||||
ENDIF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
||||
|
|
|
@ -44,7 +44,6 @@ IF(NOT CPACK_GENERATOR)
|
|||
ENDIF(NOT CPACK_GENERATOR)
|
||||
|
||||
# Set some other variables
|
||||
SET(CPACK_SOURCE_DIR "${CMAKE_SOURCE_DIR}")
|
||||
SET(CPACK_BINARY_DIR "${CMAKE_BINARY_DIR}")
|
||||
|
||||
# Hack for Visual Studio support
|
||||
|
|
|
@ -56,9 +56,6 @@ int cmCPackGenericGenerator::PrepareNames()
|
|||
outName += ".";
|
||||
outName += this->GetOutputExtension();
|
||||
|
||||
std::string installFile = this->GetOption("CPACK_PACKAGE_DIRECTORY");
|
||||
installFile += "/cmake_install.cmake";
|
||||
|
||||
std::string destFile = this->GetOption("CPACK_PACKAGE_DIRECTORY");
|
||||
destFile += "/" + outName;
|
||||
|
||||
|
@ -67,7 +64,6 @@ int cmCPackGenericGenerator::PrepareNames()
|
|||
|
||||
this->SetOption("CPACK_TOPLEVEL_DIRECTORY", topDirectory.c_str());
|
||||
this->SetOption("CPACK_TEMPORARY_DIRECTORY", tempDirectory.c_str());
|
||||
this->SetOption("CPACK_INSTALL_FILE_NAME", installFile.c_str());
|
||||
this->SetOption("CPACK_OUTPUT_FILE_NAME", outName.c_str());
|
||||
this->SetOption("CPACK_OUTPUT_FILE_PATH", destFile.c_str());
|
||||
this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME", outFile.c_str());
|
||||
|
@ -118,7 +114,6 @@ int cmCPackGenericGenerator::InstallProject()
|
|||
{
|
||||
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Install project" << std::endl);
|
||||
const char* tempInstallDirectory = this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY");
|
||||
const char* installFile = this->GetOption("CPACK_INSTALL_FILE_NAME");
|
||||
int res = 1;
|
||||
if ( !cmsys::SystemTools::MakeDirectory(tempInstallDirectory))
|
||||
{
|
||||
|
@ -165,8 +160,54 @@ int cmCPackGenericGenerator::InstallProject()
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
const char* installDirectories = this->GetOption("CPACK_INSTALLED_DIRECTORIES");
|
||||
if ( installDirectories )
|
||||
{
|
||||
std::vector<std::string> installDirectoriesVector;
|
||||
cmSystemTools::ExpandListArgument(installDirectories,installDirectoriesVector);
|
||||
if ( installDirectoriesVector.size() % 2 != 0 )
|
||||
{
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_INSTALLED_DIRECTORIES should contain pairs of <directory> and <subdirectory>. The <subdirectory> can be '.' to be installed in the toplevel directory of installation." << std::endl);
|
||||
return 0;
|
||||
}
|
||||
std::vector<std::string>::iterator it;
|
||||
const char* tempDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
|
||||
for ( it = installDirectoriesVector.begin(); it != installDirectoriesVector.end();
|
||||
++it )
|
||||
{
|
||||
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Find files" << std::endl);
|
||||
cmsys::Glob gl;
|
||||
std::string toplevel = it->c_str();
|
||||
it ++;
|
||||
std::string subdir = it->c_str();
|
||||
std::string findExpr = toplevel;
|
||||
findExpr += "/*";
|
||||
gl.RecurseOn();
|
||||
if ( !gl.FindFiles(findExpr) )
|
||||
{
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find any files in the installed directory" << std::endl);
|
||||
return 0;
|
||||
}
|
||||
std::vector<std::string>& files = gl.GetFiles();
|
||||
std::vector<std::string>::iterator gfit;
|
||||
for ( gfit = files.begin(); gfit != files.end(); ++ gfit )
|
||||
{
|
||||
std::string filePath = tempDir;
|
||||
filePath += "/" + subdir + "/" + cmSystemTools::RelativePath(toplevel.c_str(), gfit->c_str());
|
||||
std::string &inFile = *gfit;
|
||||
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: " << inFile.c_str() << " -> " << filePath.c_str() << std::endl);
|
||||
if ( !cmSystemTools::CopyFileIfDifferent(inFile.c_str(), filePath.c_str()) )
|
||||
{
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying file: " << inFile.c_str() << " -> " << filePath.c_str() << std::endl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const char* binaryDir = this->GetOption("CPACK_BINARY_DIR");
|
||||
if ( binaryDir )
|
||||
{
|
||||
std::string installFile = binaryDir;
|
||||
installFile += "/cmake_install.cmake";
|
||||
cmake cm;
|
||||
cmGlobalGenerator gg;
|
||||
gg.SetCMakeInstance(&cm);
|
||||
|
@ -183,7 +224,7 @@ int cmCPackGenericGenerator::InstallProject()
|
|||
mf->AddDefinition("BUILD_TYPE", buildConfig);
|
||||
}
|
||||
|
||||
res = mf->ReadListFile(0, installFile);
|
||||
res = mf->ReadListFile(0, installFile.c_str());
|
||||
if ( cmSystemTools::GetErrorOccuredFlag() )
|
||||
{
|
||||
res = 0;
|
||||
|
|
|
@ -51,7 +51,7 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os)
|
|||
<< "# take the archive portion of this file and pipe it to tar" << std::endl
|
||||
<< "# the NUMERIC parameter in this command should be one more" << std::endl
|
||||
<< "# than the number of lines in this header file" << std::endl
|
||||
<< "tail +18 $0 | gunzip | tar xf -" << std::endl
|
||||
<< "tail +18 \"$0\" | gunzip | tar xf -" << std::endl
|
||||
<< "" << std::endl
|
||||
<< "exit 0" << std::endl
|
||||
<< "echo \"\"" << std::endl
|
||||
|
|
|
@ -295,12 +295,16 @@ int main (int argc, char *argv[])
|
|||
parsed = 0;
|
||||
}
|
||||
|
||||
cmsys::SystemTools::ConvertToUnixSlashes(cpackProjectDirectory);
|
||||
std::string makeInstallFile = cpackProjectDirectory + "/cmake_install.cmake";
|
||||
if ( !cmsys::SystemTools::FileExists(makeInstallFile.c_str()) )
|
||||
if ( !mf->GetDefinition("CPACK_INSTALL_COMMANDS") && !mf->GetDefinition("CPACK_INSTALLED_DIRECTORIES") )
|
||||
{
|
||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Cannot find installation file: " << makeInstallFile.c_str() << std::endl);
|
||||
parsed = 0;
|
||||
cmsys::SystemTools::ConvertToUnixSlashes(cpackProjectDirectory);
|
||||
std::string makeInstallFile = cpackProjectDirectory + "/cmake_install.cmake";
|
||||
if ( !cmsys::SystemTools::FileExists(makeInstallFile.c_str()) )
|
||||
{
|
||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Cannot find installation file: " << makeInstallFile.c_str() << std::endl);
|
||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Please specify build tree of the project that uses CMake, specify CPACK_INSTALL_COMMANDS, or specify CPACK_INSTALLED_DIRECTORIES." << std::endl);
|
||||
parsed = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ SET(CPACK_PACKAGE_EXECUTABLE_LABEL "@CPACK_PACKAGE_EXECUTABLE_LABEL@")
|
|||
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "@CPACK_PACKAGE_DESCRIPTION_SUMMARY@")
|
||||
SET(CPACK_PACKAGE_DESCRIPTION_FILE "@CPACK_PACKAGE_DESCRIPTION_FILE@")
|
||||
|
||||
SET(CPACK_SOURCE_DIR "@CPACK_SOURCE_DIR@")
|
||||
# It is a CMake project, so we need a binary directory
|
||||
SET(CPACK_BINARY_DIR "@CPACK_BINARY_DIR@")
|
||||
|
||||
SET(CPACK_PACKAGE_ICON "@CPACK_PACKAGE_ICON@")
|
||||
|
|
Loading…
Reference in New Issue