summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Turbov <i.zaufi@gmail.com>2021-07-13 02:03:54 (GMT)
committerBrad King <brad.king@kitware.com>2021-07-13 12:36:12 (GMT)
commit13549674cc8f2b72380aa4a367fef3bce26a5131 (patch)
treebe6a8b0a9b95627742ee23019ed6b0566eaf7f65
parent7add10f288e956d45781726784867847c268efa4 (diff)
downloadCMake-13549674cc8f2b72380aa4a367fef3bce26a5131.zip
CMake-13549674cc8f2b72380aa4a367fef3bce26a5131.tar.gz
CMake-13549674cc8f2b72380aa4a367fef3bce26a5131.tar.bz2
Refactor: Avoid duplicate calls to `GetOption("GEN_DBGSYMDIR")`
-rw-r--r--Source/CPack/cmCPackDebGenerator.cxx20
1 files changed, 11 insertions, 9 deletions
diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx
index 210ef64..675f6f8 100644
--- a/Source/CPack/cmCPackDebGenerator.cxx
+++ b/Source/CPack/cmCPackDebGenerator.cxx
@@ -648,29 +648,31 @@ int cmCPackDebGenerator::PackageFiles()
bool cmCPackDebGenerator::createDebPackages()
{
- auto make_package = [this](const char* const path, const char* const output,
+ auto make_package = [this](const char* const path,
+ const char* const output_var,
bool (cmCPackDebGenerator::*creator)()) -> bool {
try {
- this->packageFiles = findFilesIn(this->GetOption(path));
+ this->packageFiles = findFilesIn(path);
} catch (const std::runtime_error& ex) {
cmCPackLogger(cmCPackLog::LOG_ERROR, ex.what() << std::endl);
- return 0;
+ return false;
}
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)));
+ this->GetOption(output_var)));
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",
+ bool retval =
+ make_package(this->GetOption("GEN_WDIR"), "GEN_CPACK_OUTPUT_FILE_NAME",
+ &cmCPackDebGenerator::createDeb);
+ const char* const dbgsymdir_path = this->GetOption("GEN_DBGSYMDIR");
+ if (this->IsOn("GEN_CPACK_DEBIAN_DEBUGINFO_PACKAGE") && dbgsymdir_path) {
+ retval = make_package(dbgsymdir_path, "GEN_CPACK_DBGSYM_OUTPUT_FILE_NAME",
&cmCPackDebGenerator::createDbgsymDDeb) &&
retval;
}