summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2006-02-14 15:28:40 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2006-02-14 15:28:40 (GMT)
commit3bce601c41b8487a18417e32b75c0e22f0750bbc (patch)
tree8dc47a279806741f6fa4ab14a702614e364c4684 /Source
parent2d29e48726235b71db6e38481dd537fb9eb75876 (diff)
downloadCMake-3bce601c41b8487a18417e32b75c0e22f0750bbc.zip
CMake-3bce601c41b8487a18417e32b75c0e22f0750bbc.tar.gz
CMake-3bce601c41b8487a18417e32b75c0e22f0750bbc.tar.bz2
ENH: Improved support for icons, random directories, etc...
Diffstat (limited to 'Source')
-rw-r--r--Source/CPack/cmCPackGenericGenerator.cxx55
-rw-r--r--Source/CPack/cmCPackSTGZGenerator.cxx2
-rw-r--r--Source/CPack/cpack.cxx14
3 files changed, 58 insertions, 13 deletions
diff --git a/Source/CPack/cmCPackGenericGenerator.cxx b/Source/CPack/cmCPackGenericGenerator.cxx
index 60af6eb..b203563 100644
--- a/Source/CPack/cmCPackGenericGenerator.cxx
+++ b/Source/CPack/cmCPackGenericGenerator.cxx
@@ -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;
diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx
index 64e4b76..4cce556 100644
--- a/Source/CPack/cmCPackSTGZGenerator.cxx
+++ b/Source/CPack/cmCPackSTGZGenerator.cxx
@@ -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
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index 4b850e8..c35efbe 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -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;
+ }
}
}
}