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

View File

@@ -928,8 +928,8 @@ std::string cmCPackDebGenerator::GetComponentInstallSuffix(
// the current COMPONENT belongs to.
std::string groupVar =
"CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
if (this->GetOption(groupVar)) {
return *this->GetOption(groupVar);
if (cmValue v = this->GetOption(groupVar)) {
return *v;
}
return componentName;
}

View File

@@ -196,8 +196,8 @@ int cmCPackGenerator::InstallProject()
std::string bareTempInstallDirectory =
this->GetOption("CPACK_TEMPORARY_DIRECTORY");
std::string tempInstallDirectory = bareTempInstallDirectory;
bool setDestDir = this->GetOption("CPACK_SET_DESTDIR").IsOn() ||
cmIsInternallyOn(this->GetOption("CPACK_SET_DESTDIR"));
cmValue v = this->GetOption("CPACK_SET_DESTDIR");
bool setDestDir = v.IsOn() || cmIsInternallyOn(v);
if (!setDestDir) {
tempInstallDirectory += this->GetPackagingInstallPrefix();
}
@@ -962,9 +962,8 @@ int cmCPackGenerator::InstallCMakeProject(
std::string absoluteDestFileComponent =
std::string("CPACK_ABSOLUTE_DESTINATION_FILES") + "_" +
this->GetComponentInstallSuffix(component);
if (this->GetOption(absoluteDestFileComponent)) {
std::string absoluteDestFilesListComponent =
cmStrCat(this->GetOption(absoluteDestFileComponent), ';', *d);
if (cmValue v = this->GetOption(absoluteDestFileComponent)) {
std::string absoluteDestFilesListComponent = cmStrCat(*v, ';', *d);
this->SetOption(absoluteDestFileComponent,
absoluteDestFilesListComponent);
} else {

View File

@@ -662,12 +662,11 @@ bool cmCPackInnoSetupGenerator::ProcessComponents()
if (cmNonempty(userUploadDirectory)) {
uploadDirectory = *userUploadDirectory;
} else {
if (!RequireOption("CPACK_PACKAGE_DIRECTORY")) {
cmValue pkgDirectory = RequireOption("CPACK_PACKAGE_DIRECTORY");
if (!pkgDirectory) {
return false;
}
uploadDirectory =
cmStrCat(GetOption("CPACK_PACKAGE_DIRECTORY"), "/CPackUploads");
uploadDirectory = cmStrCat(*pkgDirectory, "/CPackUploads");
}
if (!cmSystemTools::FileExists(uploadDirectory)) {

View File

@@ -458,8 +458,8 @@ std::string cmCPackRPMGenerator::GetComponentInstallSuffix(
// the current COMPONENT belongs to.
std::string groupVar =
"CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
if (this->GetOption(groupVar)) {
return *this->GetOption(groupVar);
if (cmValue v = this->GetOption(groupVar)) {
return *v;
}
return componentName;
}

View File

@@ -2244,10 +2244,9 @@ int cmake::DoPreConfigureChecks()
}
// do a sanity check on some values
if (this->State->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY")) {
std::string cacheStart =
cmStrCat(*this->State->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY"),
"/", this->CMakeListName);
if (cmValue dir =
this->State->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY")) {
std::string cacheStart = cmStrCat(*dir, '/', this->CMakeListName);
if (!cmSystemTools::SameFile(cacheStart, srcList)) {
std::string message =
cmStrCat("The source \"", srcList, "\" does not match the source \"",