diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index fd85b7c425..1822feb192 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -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; } diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index fac06bfcf6..80547ad7e0 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -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 { diff --git a/Source/CPack/cmCPackInnoSetupGenerator.cxx b/Source/CPack/cmCPackInnoSetupGenerator.cxx index ed0b2c4e6b..93641b5471 100644 --- a/Source/CPack/cmCPackInnoSetupGenerator.cxx +++ b/Source/CPack/cmCPackInnoSetupGenerator.cxx @@ -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)) { diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx index 2356d93ccc..8c2eecd1ba 100644 --- a/Source/CPack/cmCPackRPMGenerator.cxx +++ b/Source/CPack/cmCPackRPMGenerator.cxx @@ -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; } diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 1f424ab25b..2cbbd2a381 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -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 \"",