summaryrefslogtreecommitdiffstats
path: root/Source/CPack
diff options
context:
space:
mode:
authorDeniz Bahadir <deniz@code.bahadir.email>2024-04-30 16:36:25 (GMT)
committerDeniz Bahadir <deniz@code.bahadir.email>2024-04-30 16:36:25 (GMT)
commitd26eed4c7516ddf13d31c0a8e3199a4f70ac8de6 (patch)
tree75207ac4b0b736c86f67cfedb4fcb343eb87e40f /Source/CPack
parent12123b5b6bc460b3ec6d88d72a62da31d69ea37b (diff)
downloadCMake-d26eed4c7516ddf13d31c0a8e3199a4f70ac8de6.zip
CMake-d26eed4c7516ddf13d31c0a8e3199a4f70ac8de6.tar.gz
CMake-d26eed4c7516ddf13d31c0a8e3199a4f70ac8de6.tar.bz2
cmCPackGenerator: Clean up and simplify function `PrepareNames`
Diffstat (limited to 'Source/CPack')
-rw-r--r--Source/CPack/cmCPackGenerator.cxx75
1 files changed, 42 insertions, 33 deletions
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index 8b584ae..7b42823 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -79,51 +79,60 @@ int cmCPackGenerator::PrepareNames()
}
}
- std::string tempDirectory =
- cmStrCat(this->GetOption("CPACK_PACKAGE_DIRECTORY"), "/_CPack_Packages/");
- cmValue toplevelTag = this->GetOption("CPACK_TOPLEVEL_TAG");
- if (toplevelTag) {
- tempDirectory += *toplevelTag;
- tempDirectory += "/";
- }
- tempDirectory += *this->GetOption("CPACK_GENERATOR");
- std::string topDirectory = tempDirectory;
- cmValue pfname = this->GetOption("CPACK_PACKAGE_FILE_NAME");
- if (!pfname) {
+ // Determine package-directory.
+ cmValue pkgDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY");
+ if (!pkgDirectory) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "CPACK_PACKAGE_DIRECTORY not specified" << std::endl);
+ return 0;
+ }
+ // Determine base-filename of the package.
+ cmValue pkgBaseFileName = this->GetOption("CPACK_PACKAGE_FILE_NAME");
+ if (!pkgBaseFileName) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"CPACK_PACKAGE_FILE_NAME not specified" << std::endl);
return 0;
}
- std::string outName = *pfname;
- tempDirectory += "/" + outName;
+ // Determine filename of the package.
if (!this->GetOutputExtension()) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"No output extension specified" << std::endl);
return 0;
}
- outName += this->GetOutputExtension();
- cmValue pdir = this->GetOption("CPACK_PACKAGE_DIRECTORY");
- if (!pdir) {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "CPACK_PACKAGE_DIRECTORY not specified" << std::endl);
- return 0;
+ std::string pkgFileName =
+ cmStrCat(pkgBaseFileName, this->GetOutputExtension());
+ // Determine path to the package.
+ std::string pkgFilePath = cmStrCat(pkgDirectory, "/", pkgFileName);
+ // Determine top-level directory for packaging.
+ std::string topDirectory = cmStrCat(pkgDirectory, "/_CPack_Packages/");
+ {
+ cmValue toplevelTag = this->GetOption("CPACK_TOPLEVEL_TAG");
+ if (toplevelTag) {
+ topDirectory += cmStrCat(toplevelTag, "/");
+ }
}
+ topDirectory += *this->GetOption("CPACK_GENERATOR");
+ // Determine temporary packaging-directory.
+ std::string tmpDirectory = cmStrCat(topDirectory, "/", pkgBaseFileName);
+ // Determine path to temporary package file.
+ std::string tmpPkgFilePath = topDirectory + "/" + pkgFileName;
- std::string destFile = *pdir;
- this->SetOptionIfNotSet("CPACK_OUTPUT_FILE_PREFIX", destFile);
- destFile += "/" + outName;
- std::string outFile = topDirectory + "/" + outName;
+ // Set CPack variables which are not set already.
+ this->SetOptionIfNotSet("CPACK_REMOVE_TOPLEVEL_DIRECTORY", "1");
this->SetOptionIfNotSet("CPACK_TOPLEVEL_DIRECTORY", topDirectory);
- this->SetOptionIfNotSet("CPACK_TEMPORARY_DIRECTORY", tempDirectory);
- this->SetOptionIfNotSet("CPACK_OUTPUT_FILE_NAME", outName);
- this->SetOptionIfNotSet("CPACK_OUTPUT_FILE_PATH", destFile);
- this->SetOptionIfNotSet("CPACK_TEMPORARY_PACKAGE_FILE_NAME", outFile);
+ this->SetOptionIfNotSet("CPACK_TEMPORARY_DIRECTORY", tmpDirectory);
+ this->SetOptionIfNotSet("CPACK_TEMPORARY_INSTALL_DIRECTORY", tmpDirectory);
+ this->SetOptionIfNotSet("CPACK_OUTPUT_FILE_PREFIX", pkgDirectory);
+ this->SetOptionIfNotSet("CPACK_OUTPUT_FILE_NAME", pkgFileName);
+ this->SetOptionIfNotSet("CPACK_OUTPUT_FILE_PATH", pkgFilePath);
+ this->SetOptionIfNotSet("CPACK_TEMPORARY_PACKAGE_FILE_NAME", tmpPkgFilePath);
this->SetOptionIfNotSet("CPACK_INSTALL_DIRECTORY", this->GetInstallPath());
this->SetOptionIfNotSet(
"CPACK_NATIVE_INSTALL_DIRECTORY",
cmsys::SystemTools::ConvertToOutputPath(this->GetInstallPath()));
- this->SetOptionIfNotSet("CPACK_TEMPORARY_INSTALL_DIRECTORY", tempDirectory);
+ // Determine description of the package and set as CPack variable,
+ // if not already set.
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"Look for: CPACK_PACKAGE_DESCRIPTION_FILE" << std::endl);
cmValue descFileName = this->GetOption("CPACK_PACKAGE_DESCRIPTION_FILE");
@@ -143,14 +152,14 @@ int cmCPackGenerator::PrepareNames()
<< std::endl);
return 0;
}
- std::ostringstream ostr;
- std::string line;
-
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Read description file: " << *descFileName << std::endl);
+ std::ostringstream ostr;
+ std::string line;
while (ifs && cmSystemTools::GetLineFromStream(ifs, line)) {
ostr << cmXMLSafe(line) << std::endl;
}
+
this->SetOption("CPACK_PACKAGE_DESCRIPTION", ostr.str());
cmValue defFileName =
this->GetOption("CPACK_DEFAULT_PACKAGE_DESCRIPTION_FILE");
@@ -166,6 +175,8 @@ int cmCPackGenerator::PrepareNames()
<< std::endl);
return 0;
}
+
+ // Check algorithm for calculating the checksum of the package.
cmValue algoSignature = this->GetOption("CPACK_PACKAGE_CHECKSUM");
if (algoSignature) {
if (!cmCryptoHash::New(*algoSignature)) {
@@ -176,8 +187,6 @@ int cmCPackGenerator::PrepareNames()
}
}
- this->SetOptionIfNotSet("CPACK_REMOVE_TOPLEVEL_DIRECTORY", "1");
-
return 1;
}