summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorAlex Turbov <i.zaufi@gmail.com>2021-07-13 01:50:32 (GMT)
committerBrad King <brad.king@kitware.com>2021-07-13 12:36:12 (GMT)
commit7add10f288e956d45781726784867847c268efa4 (patch)
treeed5f8b06ba73e5b055f1f7664fc9fd2b506fa96c /Source
parent593ff734b08779bc2ac3f7d5975c2d12dfa5614b (diff)
downloadCMake-7add10f288e956d45781726784867847c268efa4.zip
CMake-7add10f288e956d45781726784867847c268efa4.tar.gz
CMake-7add10f288e956d45781726784867847c268efa4.tar.bz2
Refactor: Deduplicate code of `createDebPackages()`
Also, fix incorrect `retval` accumulation.
Diffstat (limited to 'Source')
-rw-r--r--Source/CPack/cmCPackDebGenerator.cxx41
1 files changed, 19 insertions, 22 deletions
diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx
index cbdcf49..210ef64 100644
--- a/Source/CPack/cmCPackDebGenerator.cxx
+++ b/Source/CPack/cmCPackDebGenerator.cxx
@@ -648,35 +648,32 @@ int cmCPackDebGenerator::PackageFiles()
bool cmCPackDebGenerator::createDebPackages()
{
- try {
- this->packageFiles = findFilesIn(this->GetOption("GEN_WDIR"));
- } catch (const std::runtime_error& ex) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, ex.what() << std::endl);
- return 0;
- }
-
- bool retval = this->createDeb();
- // add the generated package to package file names list
- this->packageFileNames.emplace_back(
- cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), '/',
- this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME")));
-
- if (this->IsOn("GEN_CPACK_DEBIAN_DEBUGINFO_PACKAGE") &&
- this->GetOption("GEN_DBGSYMDIR")) {
+ auto make_package = [this](const char* const path, const char* const output,
+ bool (cmCPackDebGenerator::*creator)()) -> bool {
try {
- this->packageFiles = findFilesIn(this->GetOption("GEN_DBGSYMDIR"));
+ this->packageFiles = findFilesIn(this->GetOption(path));
} catch (const std::runtime_error& ex) {
cmCPackLogger(cmCPackLog::LOG_ERROR, ex.what() << std::endl);
return 0;
}
- retval = this->createDbgsymDDeb() || retval;
- // add the generated package to package file names list
- this->packageFileNames.emplace_back(
- cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), '/',
- this->GetOption("GEN_CPACK_DBGSYM_OUTPUT_FILE_NAME")));
+ if ((this->*creator)()) {
+ // add the generated package to package file names list
+ this->packageFileNames.emplace_back(
+ cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), '/',
+ this->GetOption(output)));
+ return true;
+ }
+ return false;
+ };
+ bool retval = make_package("GEN_WDIR", "GEN_CPACK_OUTPUT_FILE_NAME",
+ &cmCPackDebGenerator::createDeb);
+ if (this->IsOn("GEN_CPACK_DEBIAN_DEBUGINFO_PACKAGE") &&
+ this->GetOption("GEN_DBGSYMDIR")) {
+ retval = make_package("GEN_DBGSYMDIR", "GEN_CPACK_DBGSYM_OUTPUT_FILE_NAME",
+ &cmCPackDebGenerator::createDbgsymDDeb) &&
+ retval;
}
-
return int(retval);
}