Source: Avoid duplicate calls

This commit is contained in:
Vitaly Stakhovsky
2025-04-29 06:46:39 -04:00
parent d85041c830
commit e991145430
5 changed files with 14 additions and 17 deletions
+2 -2
View File
@@ -928,8 +928,8 @@ std::string cmCPackDebGenerator::GetComponentInstallSuffix(
// the current COMPONENT belongs to. // the current COMPONENT belongs to.
std::string groupVar = std::string groupVar =
"CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP"; "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
if (this->GetOption(groupVar)) { if (cmValue v = this->GetOption(groupVar)) {
return *this->GetOption(groupVar); return *v;
} }
return componentName; return componentName;
} }
+4 -5
View File
@@ -196,8 +196,8 @@ int cmCPackGenerator::InstallProject()
std::string bareTempInstallDirectory = std::string bareTempInstallDirectory =
this->GetOption("CPACK_TEMPORARY_DIRECTORY"); this->GetOption("CPACK_TEMPORARY_DIRECTORY");
std::string tempInstallDirectory = bareTempInstallDirectory; std::string tempInstallDirectory = bareTempInstallDirectory;
bool setDestDir = this->GetOption("CPACK_SET_DESTDIR").IsOn() || cmValue v = this->GetOption("CPACK_SET_DESTDIR");
cmIsInternallyOn(this->GetOption("CPACK_SET_DESTDIR")); bool setDestDir = v.IsOn() || cmIsInternallyOn(v);
if (!setDestDir) { if (!setDestDir) {
tempInstallDirectory += this->GetPackagingInstallPrefix(); tempInstallDirectory += this->GetPackagingInstallPrefix();
} }
@@ -962,9 +962,8 @@ int cmCPackGenerator::InstallCMakeProject(
std::string absoluteDestFileComponent = std::string absoluteDestFileComponent =
std::string("CPACK_ABSOLUTE_DESTINATION_FILES") + "_" + std::string("CPACK_ABSOLUTE_DESTINATION_FILES") + "_" +
this->GetComponentInstallSuffix(component); this->GetComponentInstallSuffix(component);
if (this->GetOption(absoluteDestFileComponent)) { if (cmValue v = this->GetOption(absoluteDestFileComponent)) {
std::string absoluteDestFilesListComponent = std::string absoluteDestFilesListComponent = cmStrCat(*v, ';', *d);
cmStrCat(this->GetOption(absoluteDestFileComponent), ';', *d);
this->SetOption(absoluteDestFileComponent, this->SetOption(absoluteDestFileComponent,
absoluteDestFilesListComponent); absoluteDestFilesListComponent);
} else { } else {
+3 -4
View File
@@ -662,12 +662,11 @@ bool cmCPackInnoSetupGenerator::ProcessComponents()
if (cmNonempty(userUploadDirectory)) { if (cmNonempty(userUploadDirectory)) {
uploadDirectory = *userUploadDirectory; uploadDirectory = *userUploadDirectory;
} else { } else {
if (!RequireOption("CPACK_PACKAGE_DIRECTORY")) { cmValue pkgDirectory = RequireOption("CPACK_PACKAGE_DIRECTORY");
if (!pkgDirectory) {
return false; return false;
} }
uploadDirectory = cmStrCat(*pkgDirectory, "/CPackUploads");
uploadDirectory =
cmStrCat(GetOption("CPACK_PACKAGE_DIRECTORY"), "/CPackUploads");
} }
if (!cmSystemTools::FileExists(uploadDirectory)) { if (!cmSystemTools::FileExists(uploadDirectory)) {
+2 -2
View File
@@ -458,8 +458,8 @@ std::string cmCPackRPMGenerator::GetComponentInstallSuffix(
// the current COMPONENT belongs to. // the current COMPONENT belongs to.
std::string groupVar = std::string groupVar =
"CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP"; "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
if (this->GetOption(groupVar)) { if (cmValue v = this->GetOption(groupVar)) {
return *this->GetOption(groupVar); return *v;
} }
return componentName; return componentName;
} }
+3 -4
View File
@@ -2244,10 +2244,9 @@ int cmake::DoPreConfigureChecks()
} }
// do a sanity check on some values // do a sanity check on some values
if (this->State->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY")) { if (cmValue dir =
std::string cacheStart = this->State->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY")) {
cmStrCat(*this->State->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY"), std::string cacheStart = cmStrCat(*dir, '/', this->CMakeListName);
"/", this->CMakeListName);
if (!cmSystemTools::SameFile(cacheStart, srcList)) { if (!cmSystemTools::SameFile(cacheStart, srcList)) {
std::string message = std::string message =
cmStrCat("The source \"", srcList, "\" does not match the source \"", cmStrCat("The source \"", srcList, "\" does not match the source \"",