summaryrefslogtreecommitdiffstats
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)
commit1350ed96ffbc05c6b00289fc2cafe438e2b7e5fd (patch)
tree2f42233c9762abc007516327a2d919be93d8e7d4
parentd26eed4c7516ddf13d31c0a8e3199a4f70ac8de6 (diff)
downloadCMake-1350ed96ffbc05c6b00289fc2cafe438e2b7e5fd.zip
CMake-1350ed96ffbc05c6b00289fc2cafe438e2b7e5fd.tar.gz
CMake-1350ed96ffbc05c6b00289fc2cafe438e2b7e5fd.tar.bz2
cmCPackGenerator: Clean up and simplify function `DoPackage`
-rw-r--r--Source/CPack/cmCPackGenerator.cxx79
1 files changed, 47 insertions, 32 deletions
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index 7b42823..fb3df2e 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -1094,6 +1094,7 @@ int cmCPackGenerator::DoPackage()
return 0;
}
+ // Possibly remove the top-level packaging-directory.
if (this->GetOption("CPACK_REMOVE_TOPLEVEL_DIRECTORY").IsOn()) {
cmValue toplevelDirectory = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
if (toplevelDirectory && cmSystemTools::FileExists(*toplevelDirectory)) {
@@ -1108,55 +1109,68 @@ int cmCPackGenerator::DoPackage()
}
}
}
+
+ // Install the project (to the temporary install-directory).
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"About to install project " << std::endl);
-
if (!this->InstallProject()) {
return 0;
}
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Done install project " << std::endl);
- cmValue tempPackageFileName =
- this->GetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME");
+ // Determine the temporary directory whose content shall be packaged.
cmValue tempDirectory = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
+ // Determine and store internally the list of files to be installed.
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Find files" << std::endl);
- cmsys::Glob gl;
- std::string findExpr = cmStrCat(tempDirectory, "/*");
- gl.RecurseOn();
- gl.SetRecurseListDirs(true);
- gl.SetRecurseThroughSymlinks(false);
- if (!gl.FindFiles(findExpr)) {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Cannot find any files in the packaging tree" << std::endl);
- return 0;
+ {
+ cmsys::Glob gl;
+ std::string findExpr = cmStrCat(tempDirectory, "/*");
+ gl.RecurseOn();
+ gl.SetRecurseListDirs(true);
+ gl.SetRecurseThroughSymlinks(false);
+ if (!gl.FindFiles(findExpr)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot find any files in the packaging tree"
+ << std::endl);
+ return 0;
+ }
+ this->files = gl.GetFiles();
}
- cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Create package" << std::endl);
- cmCPackLogger(cmCPackLog::LOG_VERBOSE,
- "Package files to: "
- << (tempPackageFileName ? *tempPackageFileName : "(NULL)")
- << std::endl);
- if (tempPackageFileName && cmSystemTools::FileExists(*tempPackageFileName)) {
- cmCPackLogger(cmCPackLog::LOG_VERBOSE,
- "Remove old package file" << std::endl);
- cmSystemTools::RemoveFile(*tempPackageFileName);
- }
+ // Determine and store internally the directory that shall be packaged.
if (this->GetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY").IsOn()) {
tempDirectory = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
}
+ this->toplevel = *tempDirectory;
- // The files to be installed
- this->files = gl.GetFiles();
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Create package" << std::endl);
- this->packageFileNames.clear();
- /* Put at least one file name into the list of
- * wanted packageFileNames. The specific generator
- * may update this during PackageFiles.
- * (either putting several names or updating the provided one)
- */
- this->packageFileNames.emplace_back(tempPackageFileName);
- this->toplevel = *tempDirectory;
+ // Determine and store internally the list of packages to create.
+ // Note: Initially, this only contains a single package.
+ {
+ cmValue tempPackageFileName =
+ this->GetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME");
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "Package files to: "
+ << (tempPackageFileName ? *tempPackageFileName : "(NULL)")
+ << std::endl);
+ if (tempPackageFileName &&
+ cmSystemTools::FileExists(*tempPackageFileName)) {
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "Remove old package file" << std::endl);
+ cmSystemTools::RemoveFile(*tempPackageFileName);
+ }
+ this->packageFileNames.clear();
+ /* Put at least one file name into the list of
+ * wanted packageFileNames. The specific generator
+ * may update this during PackageFiles.
+ * (either putting several names or updating the provided one)
+ */
+ this->packageFileNames.emplace_back(tempPackageFileName);
+ }
+
+ // Do package the files (using the derived CPack generators.
{ // scope that enables package generators to run internal scripts with
// latest CMake policies enabled
cmMakefile::ScopePushPop pp{ this->MakefileMap };
@@ -1169,6 +1183,7 @@ int cmCPackGenerator::DoPackage()
return 0;
}
}
+
// Run post-build actions
cmValue postBuildScripts = this->GetOption("CPACK_POST_BUILD_SCRIPTS");
if (postBuildScripts) {