Browse Source

cmCPackGenerator::GetOption returns cmProp

Marc Chevrier 4 years ago
parent
commit
202a65759b

+ 1 - 1
Source/CPack/IFW/cmCPackIFWCommon.cxx

@@ -21,7 +21,7 @@ cmCPackIFWCommon::cmCPackIFWCommon()
 {
 }
 
-const char* cmCPackIFWCommon::GetOption(const std::string& op) const
+cmProp cmCPackIFWCommon::GetOption(const std::string& op) const
 {
   return this->Generator ? this->Generator->cmCPackGenerator::GetOption(op)
                          : nullptr;

+ 3 - 1
Source/CPack/IFW/cmCPackIFWCommon.h

@@ -7,6 +7,8 @@
 #include <map>
 #include <string>
 
+#include "cmProperty.h"
+
 class cmCPackIFWGenerator;
 class cmXMLWriter;
 
@@ -26,7 +28,7 @@ public:
 public:
   // Internal implementation
 
-  const char* GetOption(const std::string& op) const;
+  cmProp GetOption(const std::string& op) const;
   bool IsOn(const std::string& op) const;
   bool IsSetToOff(const std::string& op) const;
   bool IsSetToEmpty(const std::string& op) const;

+ 27 - 30
Source/CPack/IFW/cmCPackIFWGenerator.cxx

@@ -14,6 +14,7 @@
 #include "cmCPackLog.h" // IWYU pragma: keep
 #include "cmDuration.h"
 #include "cmGeneratedFileStream.h"
+#include "cmProperty.h"
 #include "cmStringAlgorithms.h"
 #include "cmSystemTools.h"
 
@@ -250,7 +251,7 @@ const char* cmCPackIFWGenerator::GetPackagingInstallPrefix()
 
   this->SetOption("CPACK_IFW_PACKAGING_INSTALL_PREFIX", tmpPref.c_str());
 
-  return this->GetOption("CPACK_IFW_PACKAGING_INSTALL_PREFIX");
+  return this->GetOption("CPACK_IFW_PACKAGING_INSTALL_PREFIX")->c_str();
 }
 
 const char* cmCPackIFWGenerator::GetOutputExtension()
@@ -273,11 +274,11 @@ int cmCPackIFWGenerator::InitializeInternal()
 
   // Look 'binarycreator' executable (needs)
 
-  const char* BinCreatorStr = this->GetOption(BinCreatorOpt);
+  cmProp BinCreatorStr = this->GetOption(BinCreatorOpt);
   if (!BinCreatorStr || cmIsNOTFOUND(BinCreatorStr)) {
     this->BinCreator.clear();
   } else {
-    this->BinCreator = BinCreatorStr;
+    this->BinCreator = *BinCreatorStr;
   }
 
   if (this->BinCreator.empty()) {
@@ -290,16 +291,16 @@ int cmCPackIFWGenerator::InitializeInternal()
 
   // Look 'repogen' executable (optional)
 
-  const char* RepoGenStr = this->GetOption(RepoGenOpt);
-  if (!RepoGenStr || cmIsNOTFOUND(RepoGenStr)) {
+  cmProp repoGen = this->GetOption(RepoGenOpt);
+  if (!repoGen || cmIsNOTFOUND(repoGen)) {
     this->RepoGen.clear();
   } else {
-    this->RepoGen = RepoGenStr;
+    this->RepoGen = *repoGen;
   }
 
   // Framework version
-  if (const char* FrameworkVersionSrt = this->GetOption(FrameworkVersionOpt)) {
-    this->FrameworkVersion = FrameworkVersionSrt;
+  if (cmProp frameworkVersion = this->GetOption(FrameworkVersionOpt)) {
+    this->FrameworkVersion = *frameworkVersion;
   } else {
     this->FrameworkVersion = "1.9.9";
   }
@@ -312,14 +313,13 @@ int cmCPackIFWGenerator::InitializeInternal()
 
   // Additional packages dirs
   this->PkgsDirsVector.clear();
-  if (const char* dirs = this->GetOption("CPACK_IFW_PACKAGES_DIRECTORIES")) {
+  if (cmProp dirs = this->GetOption("CPACK_IFW_PACKAGES_DIRECTORIES")) {
     cmExpandList(dirs, this->PkgsDirsVector);
   }
 
   // Additional repositories dirs
   this->RepoDirsVector.clear();
-  if (const char* dirs =
-        this->GetOption("CPACK_IFW_REPOSITORIES_DIRECTORIES")) {
+  if (cmProp dirs = this->GetOption("CPACK_IFW_REPOSITORIES_DIRECTORIES")) {
     cmExpandList(dirs, this->RepoDirsVector);
   }
 
@@ -330,23 +330,22 @@ int cmCPackIFWGenerator::InitializeInternal()
   // Repository
   this->Repository.Generator = this;
   this->Repository.Name = "Unspecified";
-  if (const char* site = this->GetOption("CPACK_DOWNLOAD_SITE")) {
-    this->Repository.Url = site;
+  if (cmProp site = this->GetOption("CPACK_DOWNLOAD_SITE")) {
+    this->Repository.Url = *site;
     this->Installer.RemoteRepositories.push_back(&this->Repository);
   }
 
   // Repositories
-  if (const char* RepoAllStr = this->GetOption("CPACK_IFW_REPOSITORIES_ALL")) {
+  if (cmProp RepoAllStr = this->GetOption("CPACK_IFW_REPOSITORIES_ALL")) {
     std::vector<std::string> RepoAllVector = cmExpandedList(RepoAllStr);
     for (std::string const& r : RepoAllVector) {
       this->GetRepository(r);
     }
   }
 
-  if (const char* ifwDownloadAll = this->GetOption("CPACK_IFW_DOWNLOAD_ALL")) {
+  if (cmProp ifwDownloadAll = this->GetOption("CPACK_IFW_DOWNLOAD_ALL")) {
     this->OnlineOnly = cmIsOn(ifwDownloadAll);
-  } else if (const char* cpackDownloadAll =
-               this->GetOption("CPACK_DOWNLOAD_ALL")) {
+  } else if (cmProp cpackDownloadAll = this->GetOption("CPACK_DOWNLOAD_ALL")) {
     this->OnlineOnly = cmIsOn(cpackDownloadAll);
   } else {
     this->OnlineOnly = false;
@@ -374,9 +373,8 @@ int cmCPackIFWGenerator::InitializeInternal()
   }
 
   // Output extension
-  if (const char* optOutExt =
-        this->GetOption("CPACK_IFW_PACKAGE_FILE_EXTENSION")) {
-    this->OutputExtension = optOutExt;
+  if (cmProp optOutExt = this->GetOption("CPACK_IFW_PACKAGE_FILE_EXTENSION")) {
+    this->OutputExtension = *optOutExt;
   } else if (sysName == "Darwin") {
     this->OutputExtension = ".dmg";
   } else {
@@ -508,21 +506,20 @@ std::string cmCPackIFWGenerator::GetRootPackageName()
 {
   // Default value
   std::string name = "root";
-  if (const char* optIFW_PACKAGE_GROUP =
+  if (cmProp optIFW_PACKAGE_GROUP =
         this->GetOption("CPACK_IFW_PACKAGE_GROUP")) {
     // Configure from root group
     cmCPackIFWPackage package;
     package.Generator = this;
     package.ConfigureFromGroup(optIFW_PACKAGE_GROUP);
     name = package.Name;
-  } else if (const char* optIFW_PACKAGE_NAME =
+  } else if (cmProp optIFW_PACKAGE_NAME =
                this->GetOption("CPACK_IFW_PACKAGE_NAME")) {
     // Configure from root package name
-    name = optIFW_PACKAGE_NAME;
-  } else if (const char* optPACKAGE_NAME =
-               this->GetOption("CPACK_PACKAGE_NAME")) {
+    name = *optIFW_PACKAGE_NAME;
+  } else if (cmProp optPACKAGE_NAME = this->GetOption("CPACK_PACKAGE_NAME")) {
     // Configure from package name
-    name = optPACKAGE_NAME;
+    name = *optPACKAGE_NAME;
   }
   return name;
 }
@@ -537,10 +534,10 @@ std::string cmCPackIFWGenerator::GetGroupPackageName(
   if (cmCPackIFWPackage* package = this->GetGroupPackage(group)) {
     return package->Name;
   }
-  const char* option =
+  cmProp option =
     this->GetOption("CPACK_IFW_COMPONENT_GROUP_" +
                     cmsys::SystemTools::UpperCase(group->Name) + "_NAME");
-  name = option ? option : group->Name;
+  name = option ? *option : group->Name;
   if (group->ParentGroup) {
     cmCPackIFWPackage* package = this->GetGroupPackage(group->ParentGroup);
     bool dot = !this->ResolveDuplicateNames;
@@ -563,8 +560,8 @@ std::string cmCPackIFWGenerator::GetComponentPackageName(
   }
   std::string prefix = "CPACK_IFW_COMPONENT_" +
     cmsys::SystemTools::UpperCase(component->Name) + "_";
-  const char* option = this->GetOption(prefix + "NAME");
-  name = option ? option : component->Name;
+  cmProp option = this->GetOption(prefix + "NAME");
+  name = option ? *option : component->Name;
   if (component->Group) {
     cmCPackIFWPackage* package = this->GetGroupPackage(component->Group);
     if ((this->componentPackageMethod ==

+ 55 - 57
Source/CPack/IFW/cmCPackIFWInstaller.cxx

@@ -12,6 +12,7 @@
 #include "cmCPackIFWRepository.h"
 #include "cmCPackLog.h" // IWYU pragma: keep
 #include "cmGeneratedFileStream.h"
+#include "cmProperty.h"
 #include "cmStringAlgorithms.h"
 #include "cmSystemTools.h"
 #include "cmXMLParser.h"
@@ -33,61 +34,59 @@ void cmCPackIFWInstaller::printSkippedOptionWarning(
 void cmCPackIFWInstaller::ConfigureFromOptions()
 {
   // Name;
-  if (const char* optIFW_PACKAGE_NAME =
-        this->GetOption("CPACK_IFW_PACKAGE_NAME")) {
-    this->Name = optIFW_PACKAGE_NAME;
-  } else if (const char* optPACKAGE_NAME =
-               this->GetOption("CPACK_PACKAGE_NAME")) {
-    this->Name = optPACKAGE_NAME;
+  if (cmProp optIFW_PACKAGE_NAME = this->GetOption("CPACK_IFW_PACKAGE_NAME")) {
+    this->Name = *optIFW_PACKAGE_NAME;
+  } else if (cmProp optPACKAGE_NAME = this->GetOption("CPACK_PACKAGE_NAME")) {
+    this->Name = *optPACKAGE_NAME;
   } else {
     this->Name = "Your package";
   }
 
   // Title;
-  if (const char* optIFW_PACKAGE_TITLE =
+  if (cmProp optIFW_PACKAGE_TITLE =
         this->GetOption("CPACK_IFW_PACKAGE_TITLE")) {
-    this->Title = optIFW_PACKAGE_TITLE;
-  } else if (const char* optPACKAGE_DESCRIPTION_SUMMARY =
+    this->Title = *optIFW_PACKAGE_TITLE;
+  } else if (cmProp optPACKAGE_DESCRIPTION_SUMMARY =
                this->GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY")) {
-    this->Title = optPACKAGE_DESCRIPTION_SUMMARY;
+    this->Title = *optPACKAGE_DESCRIPTION_SUMMARY;
   } else {
     this->Title = "Your package description";
   }
 
   // Version;
-  if (const char* option = this->GetOption("CPACK_PACKAGE_VERSION")) {
-    this->Version = option;
+  if (cmProp option = this->GetOption("CPACK_PACKAGE_VERSION")) {
+    this->Version = *option;
   } else {
     this->Version = "1.0.0";
   }
 
   // Publisher
-  if (const char* optIFW_PACKAGE_PUBLISHER =
+  if (cmProp optIFW_PACKAGE_PUBLISHER =
         this->GetOption("CPACK_IFW_PACKAGE_PUBLISHER")) {
-    this->Publisher = optIFW_PACKAGE_PUBLISHER;
-  } else if (const char* optPACKAGE_VENDOR =
+    this->Publisher = *optIFW_PACKAGE_PUBLISHER;
+  } else if (cmProp optPACKAGE_VENDOR =
                this->GetOption("CPACK_PACKAGE_VENDOR")) {
-    this->Publisher = optPACKAGE_VENDOR;
+    this->Publisher = *optPACKAGE_VENDOR;
   }
 
   // ProductUrl
-  if (const char* option = this->GetOption("CPACK_IFW_PRODUCT_URL")) {
-    this->ProductUrl = option;
+  if (cmProp option = this->GetOption("CPACK_IFW_PRODUCT_URL")) {
+    this->ProductUrl = *option;
   }
 
   // ApplicationIcon
-  if (const char* option = this->GetOption("CPACK_IFW_PACKAGE_ICON")) {
+  if (cmProp option = this->GetOption("CPACK_IFW_PACKAGE_ICON")) {
     if (cmSystemTools::FileExists(option)) {
-      this->InstallerApplicationIcon = option;
+      this->InstallerApplicationIcon = *option;
     } else {
       this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_ICON", option);
     }
   }
 
   // WindowIcon
-  if (const char* option = this->GetOption("CPACK_IFW_PACKAGE_WINDOW_ICON")) {
+  if (cmProp option = this->GetOption("CPACK_IFW_PACKAGE_WINDOW_ICON")) {
     if (cmSystemTools::FileExists(option)) {
-      this->InstallerWindowIcon = option;
+      this->InstallerWindowIcon = *option;
     } else {
       this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_WINDOW_ICON", option);
     }
@@ -103,45 +102,45 @@ void cmCPackIFWInstaller::ConfigureFromOptions()
   }
 
   // Logo
-  if (const char* option = this->GetOption("CPACK_IFW_PACKAGE_LOGO")) {
+  if (cmProp option = this->GetOption("CPACK_IFW_PACKAGE_LOGO")) {
     if (cmSystemTools::FileExists(option)) {
-      this->Logo = option;
+      this->Logo = *option;
     } else {
       this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_LOGO", option);
     }
   }
 
   // Watermark
-  if (const char* option = this->GetOption("CPACK_IFW_PACKAGE_WATERMARK")) {
+  if (cmProp option = this->GetOption("CPACK_IFW_PACKAGE_WATERMARK")) {
     if (cmSystemTools::FileExists(option)) {
-      this->Watermark = option;
+      this->Watermark = *option;
     } else {
       this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_WATERMARK", option);
     }
   }
 
   // Banner
-  if (const char* option = this->GetOption("CPACK_IFW_PACKAGE_BANNER")) {
+  if (cmProp option = this->GetOption("CPACK_IFW_PACKAGE_BANNER")) {
     if (cmSystemTools::FileExists(option)) {
-      this->Banner = option;
+      this->Banner = *option;
     } else {
       this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_BANNER", option);
     }
   }
 
   // Background
-  if (const char* option = this->GetOption("CPACK_IFW_PACKAGE_BACKGROUND")) {
+  if (cmProp option = this->GetOption("CPACK_IFW_PACKAGE_BACKGROUND")) {
     if (cmSystemTools::FileExists(option)) {
-      this->Background = option;
+      this->Background = *option;
     } else {
       this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_BACKGROUND", option);
     }
   }
 
   // WizardStyle
-  if (const char* option = this->GetOption("CPACK_IFW_PACKAGE_WIZARD_STYLE")) {
+  if (cmProp option = this->GetOption("CPACK_IFW_PACKAGE_WIZARD_STYLE")) {
     // Setting the user value in any case
-    this->WizardStyle = option;
+    this->WizardStyle = *option;
     // Check known values
     if (this->WizardStyle != "Modern" && this->WizardStyle != "Aero" &&
         this->WizardStyle != "Mac" && this->WizardStyle != "Classic") {
@@ -154,28 +153,28 @@ void cmCPackIFWInstaller::ConfigureFromOptions()
   }
 
   // StyleSheet
-  if (const char* option = this->GetOption("CPACK_IFW_PACKAGE_STYLE_SHEET")) {
+  if (cmProp option = this->GetOption("CPACK_IFW_PACKAGE_STYLE_SHEET")) {
     if (cmSystemTools::FileExists(option)) {
-      this->StyleSheet = option;
+      this->StyleSheet = *option;
     } else {
       this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_STYLE_SHEET", option);
     }
   }
 
   // WizardDefaultWidth
-  if (const char* option =
+  if (cmProp option =
         this->GetOption("CPACK_IFW_PACKAGE_WIZARD_DEFAULT_WIDTH")) {
-    this->WizardDefaultWidth = option;
+    this->WizardDefaultWidth = *option;
   }
 
   // WizardDefaultHeight
-  if (const char* option =
+  if (cmProp option =
         this->GetOption("CPACK_IFW_PACKAGE_WIZARD_DEFAULT_HEIGHT")) {
-    this->WizardDefaultHeight = option;
+    this->WizardDefaultHeight = *option;
   }
 
   // WizardShowPageList
-  if (const char* option =
+  if (cmProp option =
         this->GetOption("CPACK_IFW_PACKAGE_WIZARD_SHOW_PAGE_LIST")) {
     if (!this->IsVersionLess("4.0")) {
       if (this->IsSetToOff("CPACK_IFW_PACKAGE_WIZARD_SHOW_PAGE_LIST")) {
@@ -204,23 +203,23 @@ void cmCPackIFWInstaller::ConfigureFromOptions()
   }
 
   // TitleColor
-  if (const char* option = this->GetOption("CPACK_IFW_PACKAGE_TITLE_COLOR")) {
-    this->TitleColor = option;
+  if (cmProp option = this->GetOption("CPACK_IFW_PACKAGE_TITLE_COLOR")) {
+    this->TitleColor = *option;
   }
 
   // Start menu
-  if (const char* optIFW_START_MENU_DIR =
+  if (cmProp optIFW_START_MENU_DIR =
         this->GetOption("CPACK_IFW_PACKAGE_START_MENU_DIRECTORY")) {
-    this->StartMenuDir = optIFW_START_MENU_DIR;
+    this->StartMenuDir = *optIFW_START_MENU_DIR;
   } else {
     this->StartMenuDir = this->Name;
   }
 
   // Default target directory for installation
-  if (const char* optIFW_TARGET_DIRECTORY =
+  if (cmProp optIFW_TARGET_DIRECTORY =
         this->GetOption("CPACK_IFW_TARGET_DIRECTORY")) {
-    this->TargetDir = optIFW_TARGET_DIRECTORY;
-  } else if (const char* optPACKAGE_INSTALL_DIRECTORY =
+    this->TargetDir = *optIFW_TARGET_DIRECTORY;
+  } else if (cmProp optPACKAGE_INSTALL_DIRECTORY =
                this->GetOption("CPACK_PACKAGE_INSTALL_DIRECTORY")) {
     this->TargetDir =
       cmStrCat("@ApplicationsDir@/", optPACKAGE_INSTALL_DIRECTORY);
@@ -229,21 +228,20 @@ void cmCPackIFWInstaller::ConfigureFromOptions()
   }
 
   // Default target directory for installation with administrator rights
-  if (const char* option =
-        this->GetOption("CPACK_IFW_ADMIN_TARGET_DIRECTORY")) {
-    this->AdminTargetDir = option;
+  if (cmProp option = this->GetOption("CPACK_IFW_ADMIN_TARGET_DIRECTORY")) {
+    this->AdminTargetDir = *option;
   }
 
   // Maintenance tool
-  if (const char* optIFW_MAINTENANCE_TOOL =
+  if (cmProp optIFW_MAINTENANCE_TOOL =
         this->GetOption("CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_NAME")) {
-    this->MaintenanceToolName = optIFW_MAINTENANCE_TOOL;
+    this->MaintenanceToolName = *optIFW_MAINTENANCE_TOOL;
   }
 
   // Maintenance tool ini file
-  if (const char* optIFW_MAINTENANCE_TOOL_INI =
+  if (cmProp optIFW_MAINTENANCE_TOOL_INI =
         this->GetOption("CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_INI_FILE")) {
-    this->MaintenanceToolIniFile = optIFW_MAINTENANCE_TOOL_INI;
+    this->MaintenanceToolIniFile = *optIFW_MAINTENANCE_TOOL_INI;
   }
 
   // Allow non-ASCII characters
@@ -265,13 +263,13 @@ void cmCPackIFWInstaller::ConfigureFromOptions()
   }
 
   // Control script
-  if (const char* optIFW_CONTROL_SCRIPT =
+  if (cmProp optIFW_CONTROL_SCRIPT =
         this->GetOption("CPACK_IFW_PACKAGE_CONTROL_SCRIPT")) {
-    this->ControlScript = optIFW_CONTROL_SCRIPT;
+    this->ControlScript = *optIFW_CONTROL_SCRIPT;
   }
 
   // Resources
-  if (const char* optIFW_PACKAGE_RESOURCES =
+  if (cmProp optIFW_PACKAGE_RESOURCES =
         this->GetOption("CPACK_IFW_PACKAGE_RESOURCES")) {
     this->Resources.clear();
     cmExpandList(optIFW_PACKAGE_RESOURCES, this->Resources);
@@ -541,7 +539,7 @@ void cmCPackIFWInstaller::GeneratePackageFiles()
     package.Generator = this->Generator;
     package.Installer = this;
     // Check package group
-    if (const char* option = this->GetOption("CPACK_IFW_PACKAGE_GROUP")) {
+    if (cmProp option = this->GetOption("CPACK_IFW_PACKAGE_GROUP")) {
       package.ConfigureFromGroup(option);
       std::string forcedOption = "CPACK_IFW_COMPONENT_GROUP_" +
         cmsys::SystemTools::UpperCase(option) + "_FORCED_INSTALLATION";

+ 48 - 48
Source/CPack/IFW/cmCPackIFWPackage.cxx

@@ -15,6 +15,7 @@
 #include "cmCPackIFWInstaller.h"
 #include "cmCPackLog.h" // IWYU pragma: keep
 #include "cmGeneratedFileStream.h"
+#include "cmProperty.h"
 #include "cmStringAlgorithms.h"
 #include "cmSystemTools.h"
 #include "cmTimestamp.h"
@@ -124,10 +125,10 @@ std::string cmCPackIFWPackage::GetComponentName(cmCPackComponent* component)
   if (!component) {
     return "";
   }
-  const char* option =
+  cmProp option =
     this->GetOption("CPACK_IFW_COMPONENT_" +
                     cmsys::SystemTools::UpperCase(component->Name) + "_NAME");
-  return option ? option : component->Name;
+  return option ? *option : component->Name;
 }
 
 void cmCPackIFWPackage::DefaultConfiguration()
@@ -159,23 +160,22 @@ int cmCPackIFWPackage::ConfigureFromOptions()
   this->Name = this->Generator->GetRootPackageName();
 
   // Display name
-  if (const char* option = this->GetOption("CPACK_PACKAGE_NAME")) {
-    this->DisplayName[""] = option;
+  if (cmProp option = this->GetOption("CPACK_PACKAGE_NAME")) {
+    this->DisplayName[""] = *option;
   } else {
     this->DisplayName[""] = "Your package";
   }
 
   // Description
-  if (const char* option =
-        this->GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY")) {
-    this->Description[""] = option;
+  if (cmProp option = this->GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY")) {
+    this->Description[""] = *option;
   } else {
     this->Description[""] = "Your package description";
   }
 
   // Version
-  if (const char* option = this->GetOption("CPACK_PACKAGE_VERSION")) {
-    this->Version = option;
+  if (cmProp option = this->GetOption("CPACK_PACKAGE_VERSION")) {
+    this->Version = *option;
   } else {
     this->Version = "1.0.0";
   }
@@ -204,22 +204,22 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component)
   this->Description[""] = component->Description;
 
   // Version
-  if (const char* optVERSION = this->GetOption(prefix + "VERSION")) {
-    this->Version = optVERSION;
-  } else if (const char* optPACKAGE_VERSION =
+  if (cmProp optVERSION = this->GetOption(prefix + "VERSION")) {
+    this->Version = *optVERSION;
+  } else if (cmProp optPACKAGE_VERSION =
                this->GetOption("CPACK_PACKAGE_VERSION")) {
-    this->Version = optPACKAGE_VERSION;
+    this->Version = *optPACKAGE_VERSION;
   } else {
     this->Version = "1.0.0";
   }
 
   // Script
-  if (const char* option = this->GetOption(prefix + "SCRIPT")) {
-    this->Script = option;
+  if (cmProp option = this->GetOption(prefix + "SCRIPT")) {
+    this->Script = *option;
   }
 
   // User interfaces
-  if (const char* option = this->GetOption(prefix + "USER_INTERFACES")) {
+  if (cmProp option = this->GetOption(prefix + "USER_INTERFACES")) {
     this->UserInterfaces.clear();
     cmExpandList(option, this->UserInterfaces);
   }
@@ -232,7 +232,7 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component)
   }
 
   // Licenses
-  if (const char* option = this->GetOption(prefix + "LICENSES")) {
+  if (cmProp option = this->GetOption(prefix + "LICENSES")) {
     this->Licenses.clear();
     cmExpandList(option, this->Licenses);
     if (this->Licenses.size() % 2 != 0) {
@@ -246,8 +246,8 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component)
   }
 
   // Priority
-  if (const char* option = this->GetOption(prefix + "PRIORITY")) {
-    this->SortingPriority = option;
+  if (cmProp option = this->GetOption(prefix + "PRIORITY")) {
+    this->SortingPriority = *option;
     cmCPackIFWLogger(
       WARNING,
       "The \"PRIORITY\" option is set "
@@ -289,28 +289,28 @@ int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group)
   this->Description[""] = group->Description;
 
   // Version
-  if (const char* optVERSION = this->GetOption(prefix + "VERSION")) {
-    this->Version = optVERSION;
-  } else if (const char* optPACKAGE_VERSION =
+  if (cmProp optVERSION = this->GetOption(prefix + "VERSION")) {
+    this->Version = *optVERSION;
+  } else if (cmProp optPACKAGE_VERSION =
                this->GetOption("CPACK_PACKAGE_VERSION")) {
-    this->Version = optPACKAGE_VERSION;
+    this->Version = *optPACKAGE_VERSION;
   } else {
     this->Version = "1.0.0";
   }
 
   // Script
-  if (const char* option = this->GetOption(prefix + "SCRIPT")) {
-    this->Script = option;
+  if (cmProp option = this->GetOption(prefix + "SCRIPT")) {
+    this->Script = *option;
   }
 
   // User interfaces
-  if (const char* option = this->GetOption(prefix + "USER_INTERFACES")) {
+  if (cmProp option = this->GetOption(prefix + "USER_INTERFACES")) {
     this->UserInterfaces.clear();
     cmExpandList(option, this->UserInterfaces);
   }
 
   // Licenses
-  if (const char* option = this->GetOption(prefix + "LICENSES")) {
+  if (cmProp option = this->GetOption(prefix + "LICENSES")) {
     this->Licenses.clear();
     cmExpandList(option, this->Licenses);
     if (this->Licenses.size() % 2 != 0) {
@@ -324,8 +324,8 @@ int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group)
   }
 
   // Priority
-  if (const char* option = this->GetOption(prefix + "PRIORITY")) {
-    this->SortingPriority = option;
+  if (cmProp option = this->GetOption(prefix + "PRIORITY")) {
+    this->SortingPriority = *option;
     cmCPackIFWLogger(
       WARNING,
       "The \"PRIORITY\" option is set "
@@ -346,14 +346,14 @@ int cmCPackIFWPackage::ConfigureFromGroup(const std::string& groupName)
   std::string prefix =
     "CPACK_COMPONENT_GROUP_" + cmsys::SystemTools::UpperCase(groupName) + "_";
 
-  if (const char* option = this->GetOption(prefix + "DISPLAY_NAME")) {
-    group.DisplayName = option;
+  if (cmProp option = this->GetOption(prefix + "DISPLAY_NAME")) {
+    group.DisplayName = *option;
   } else {
     group.DisplayName = group.Name;
   }
 
-  if (const char* option = this->GetOption(prefix + "DESCRIPTION")) {
-    group.Description = option;
+  if (cmProp option = this->GetOption(prefix + "DESCRIPTION")) {
+    group.Description = *option;
   }
   group.IsBold = this->IsOn(prefix + "BOLD_TITLE");
   group.IsExpandedByDefault = this->IsOn(prefix + "EXPANDED");
@@ -381,7 +381,7 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix)
   option = prefix + "DISPLAY_NAME";
   if (this->IsSetToEmpty(option)) {
     this->DisplayName.clear();
-  } else if (const char* value = this->GetOption(option)) {
+  } else if (cmProp value = this->GetOption(option)) {
     cmCPackIFWPackage::ExpandListArgument(value, this->DisplayName);
   }
 
@@ -389,7 +389,7 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix)
   option = prefix + "DESCRIPTION";
   if (this->IsSetToEmpty(option)) {
     this->Description.clear();
-  } else if (const char* value = this->GetOption(option)) {
+  } else if (cmProp value = this->GetOption(option)) {
     cmCPackIFWPackage::ExpandListArgument(value, this->Description);
   }
 
@@ -397,31 +397,31 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix)
   option = prefix + "RELEASE_DATE";
   if (this->IsSetToEmpty(option)) {
     this->ReleaseDate.clear();
-  } else if (const char* value = this->GetOption(option)) {
-    this->ReleaseDate = value;
+  } else if (cmProp value = this->GetOption(option)) {
+    this->ReleaseDate = *value;
   }
 
   // Sorting priority
   option = prefix + "SORTING_PRIORITY";
   if (this->IsSetToEmpty(option)) {
     this->SortingPriority.clear();
-  } else if (const char* value = this->GetOption(option)) {
-    this->SortingPriority = value;
+  } else if (cmProp value = this->GetOption(option)) {
+    this->SortingPriority = *value;
   }
 
   // Update text
   option = prefix + "UPDATE_TEXT";
   if (this->IsSetToEmpty(option)) {
     this->UpdateText.clear();
-  } else if (const char* value = this->GetOption(option)) {
-    this->UpdateText = value;
+  } else if (cmProp value = this->GetOption(option)) {
+    this->UpdateText = *value;
   }
 
   // Translations
   option = prefix + "TRANSLATIONS";
   if (this->IsSetToEmpty(option)) {
     this->Translations.clear();
-  } else if (const char* value = this->GetOption(option)) {
+  } else if (cmProp value = this->GetOption(option)) {
     this->Translations.clear();
     cmExpandList(value, this->Translations);
   }
@@ -429,11 +429,11 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix)
   // QtIFW dependencies
   std::vector<std::string> deps;
   option = prefix + "DEPENDS";
-  if (const char* value = this->GetOption(option)) {
+  if (cmProp value = this->GetOption(option)) {
     cmExpandList(value, deps);
   }
   option = prefix + "DEPENDENCIES";
-  if (const char* value = this->GetOption(option)) {
+  if (cmProp value = this->GetOption(option)) {
     cmExpandList(value, deps);
   }
   for (std::string const& d : deps) {
@@ -454,7 +454,7 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix)
   option = prefix + "AUTO_DEPEND_ON";
   if (this->IsSetToEmpty(option)) {
     this->AlienAutoDependOn.clear();
-  } else if (const char* value = this->GetOption(option)) {
+  } else if (cmProp value = this->GetOption(option)) {
     std::vector<std::string> depsOn = cmExpandedList(value);
     for (std::string const& d : depsOn) {
       DependenceStruct dep(d);
@@ -483,7 +483,7 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix)
   option = prefix + "DEFAULT";
   if (this->IsSetToEmpty(option)) {
     this->Default.clear();
-  } else if (const char* value = this->GetOption(option)) {
+  } else if (cmProp value = this->GetOption(option)) {
     std::string lowerValue = cmsys::SystemTools::LowerCase(value);
     if (lowerValue == "true") {
       this->Default = "true";
@@ -492,7 +492,7 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix)
     } else if (lowerValue == "script") {
       this->Default = "script";
     } else {
-      this->Default = value;
+      this->Default = *value;
     }
   }
 
@@ -510,7 +510,7 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix)
   option = prefix + "REPLACES";
   if (this->IsSetToEmpty(option)) {
     this->Replaces.clear();
-  } else if (const char* value = this->GetOption(option)) {
+  } else if (cmProp value = this->GetOption(option)) {
     this->Replaces.clear();
     cmExpandList(value, this->Replaces);
   }

+ 13 - 12
Source/CPack/IFW/cmCPackIFWRepository.cxx

@@ -6,6 +6,7 @@
 
 #include "cmCPackIFWGenerator.h"
 #include "cmGeneratedFileStream.h"
+#include "cmProperty.h"
 #include "cmSystemTools.h"
 #include "cmXMLParser.h"
 #include "cmXMLWriter.h"
@@ -55,22 +56,22 @@ bool cmCPackIFWRepository::ConfigureFromOptions()
   }
 
   // Url
-  if (const char* url = this->GetOption(prefix + "URL")) {
-    this->Url = url;
+  if (cmProp url = this->GetOption(prefix + "URL")) {
+    this->Url = *url;
   } else {
     this->Url.clear();
   }
 
   // Old url
-  if (const char* oldUrl = this->GetOption(prefix + "OLD_URL")) {
-    this->OldUrl = oldUrl;
+  if (cmProp oldUrl = this->GetOption(prefix + "OLD_URL")) {
+    this->OldUrl = *oldUrl;
   } else {
     this->OldUrl.clear();
   }
 
   // New url
-  if (const char* newUrl = this->GetOption(prefix + "NEW_URL")) {
-    this->NewUrl = newUrl;
+  if (cmProp newUrl = this->GetOption(prefix + "NEW_URL")) {
+    this->NewUrl = *newUrl;
   } else {
     this->NewUrl.clear();
   }
@@ -83,22 +84,22 @@ bool cmCPackIFWRepository::ConfigureFromOptions()
   }
 
   // Username
-  if (const char* username = this->GetOption(prefix + "USERNAME")) {
-    this->Username = username;
+  if (cmProp username = this->GetOption(prefix + "USERNAME")) {
+    this->Username = *username;
   } else {
     this->Username.clear();
   }
 
   // Password
-  if (const char* password = this->GetOption(prefix + "PASSWORD")) {
-    this->Password = password;
+  if (cmProp password = this->GetOption(prefix + "PASSWORD")) {
+    this->Password = *password;
   } else {
     this->Password.clear();
   }
 
   // DisplayName
-  if (const char* displayName = this->GetOption(prefix + "DISPLAY_NAME")) {
-    this->DisplayName = displayName;
+  if (cmProp displayName = this->GetOption(prefix + "DISPLAY_NAME")) {
+    this->DisplayName = *displayName;
   } else {
     this->DisplayName.clear();
   }

+ 38 - 41
Source/CPack/WiX/cmCPackWIXGenerator.cxx

@@ -18,6 +18,7 @@
 #include "cmCryptoHash.h"
 #include "cmGeneratedFileStream.h"
 #include "cmInstalledFile.h"
+#include "cmProperty.h"
 #include "cmStringAlgorithms.h"
 #include "cmSystemTools.h"
 #include "cmUuid.h"
@@ -125,7 +126,7 @@ bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles)
     command << " -ext " << QuotePath(ext);
   }
 
-  const char* const cultures = GetOption("CPACK_WIX_CULTURES");
+  cmProp const cultures = GetOption("CPACK_WIX_CULTURES");
   if (cultures) {
     command << " -cultures:" << cultures;
   }
@@ -156,7 +157,7 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
     return false;
   }
 
-  if (GetOption("CPACK_WIX_PRODUCT_GUID") == 0) {
+  if (!GetOption("CPACK_WIX_PRODUCT_GUID")) {
     std::string guid = GenerateGUID();
     SetOption("CPACK_WIX_PRODUCT_GUID", guid.c_str());
 
@@ -165,7 +166,7 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
                                                               << std::endl);
   }
 
-  if (GetOption("CPACK_WIX_UPGRADE_GUID") == 0) {
+  if (!GetOption("CPACK_WIX_UPGRADE_GUID")) {
     std::string guid = GenerateGUID();
     SetOption("CPACK_WIX_UPGRADE_GUID", guid.c_str());
 
@@ -182,7 +183,7 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
     return false;
   }
 
-  if (GetOption("CPACK_WIX_LICENSE_RTF") == 0) {
+  if (!GetOption("CPACK_WIX_LICENSE_RTF")) {
     std::string licenseFilename = this->CPackTopLevel + "/License.rtf";
     SetOption("CPACK_WIX_LICENSE_RTF", licenseFilename.c_str());
 
@@ -191,7 +192,7 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
     }
   }
 
-  if (GetOption("CPACK_PACKAGE_VENDOR") == 0) {
+  if (!GetOption("CPACK_PACKAGE_VENDOR")) {
     std::string defaultVendor = "Humanity";
     SetOption("CPACK_PACKAGE_VENDOR", defaultVendor.c_str());
 
@@ -200,7 +201,7 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
                     << defaultVendor << " . " << std::endl);
   }
 
-  if (GetOption("CPACK_WIX_UI_REF") == 0) {
+  if (!GetOption("CPACK_WIX_UI_REF")) {
     std::string defaultRef = "WixUI_InstallDir";
 
     if (!this->Components.empty()) {
@@ -210,9 +211,9 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
     SetOption("CPACK_WIX_UI_REF", defaultRef.c_str());
   }
 
-  const char* packageContact = GetOption("CPACK_PACKAGE_CONTACT");
-  if (packageContact != 0 && GetOption("CPACK_WIX_PROPERTY_ARPCONTACT") == 0) {
-    SetOption("CPACK_WIX_PROPERTY_ARPCONTACT", packageContact);
+  cmProp packageContact = GetOption("CPACK_PACKAGE_CONTACT");
+  if (packageContact && !GetOption("CPACK_WIX_PROPERTY_ARPCONTACT")) {
+    SetOption("CPACK_WIX_PROPERTY_ARPCONTACT", packageContact->c_str());
   }
 
   CollectExtensions("CPACK_WIX_EXTENSIONS", this->CandleExtensions);
@@ -223,7 +224,7 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
   CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", this->LightExtensions);
   CollectXmlNamespaces("CPACK_WIX_CUSTOM_XMLNS", this->CustomXmlNamespaces);
 
-  const char* patchFilePath = GetOption("CPACK_WIX_PATCH_FILE");
+  cmProp patchFilePath = GetOption("CPACK_WIX_PATCH_FILE");
   if (patchFilePath) {
     std::vector<std::string> patchFilePaths = cmExpandedList(patchFilePath);
 
@@ -295,7 +296,7 @@ bool cmCPackWIXGenerator::PackageFilesImpl()
 
 void cmCPackWIXGenerator::AppendUserSuppliedExtraSources()
 {
-  const char* cpackWixExtraSources = GetOption("CPACK_WIX_EXTRA_SOURCES");
+  cmProp cpackWixExtraSources = GetOption("CPACK_WIX_EXTRA_SOURCES");
   if (!cpackWixExtraSources)
     return;
 
@@ -304,7 +305,7 @@ void cmCPackWIXGenerator::AppendUserSuppliedExtraSources()
 
 void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream)
 {
-  const char* cpackWixExtraObjects = GetOption("CPACK_WIX_EXTRA_OBJECTS");
+  cmProp cpackWixExtraObjects = GetOption("CPACK_WIX_EXTRA_OBJECTS");
   if (!cpackWixExtraObjects)
     return;
 
@@ -335,7 +336,7 @@ void cmCPackWIXGenerator::CreateWiXVariablesIncludeFile()
   CopyDefinition(includeFile, "CPACK_WIX_UI_BANNER", DefinitionType::PATH);
   CopyDefinition(includeFile, "CPACK_WIX_UI_DIALOG", DefinitionType::PATH);
   SetOptionIfNotSet("CPACK_WIX_PROGRAM_MENU_FOLDER",
-                    GetOption("CPACK_PACKAGE_NAME"));
+                    GetOption("CPACK_PACKAGE_NAME").GetCStr());
   CopyDefinition(includeFile, "CPACK_WIX_PROGRAM_MENU_FOLDER");
   CopyDefinition(includeFile, "CPACK_WIX_UI_REF");
 }
@@ -355,7 +356,7 @@ void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile()
   for (std::string const& name : options) {
     if (cmHasPrefix(name, prefix)) {
       std::string id = name.substr(prefix.length());
-      std::string value = GetOption(name.c_str());
+      std::string value = GetOption(name);
 
       includeFile.BeginElement("Property");
       includeFile.AddAttribute("Id", id);
@@ -364,7 +365,7 @@ void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile()
     }
   }
 
-  if (GetOption("CPACK_WIX_PROPERTY_ARPINSTALLLOCATION") == 0) {
+  if (!GetOption("CPACK_WIX_PROPERTY_ARPINSTALLLOCATION")) {
     includeFile.BeginElement("Property");
     includeFile.AddAttribute("Id", "INSTALL_ROOT");
     includeFile.AddAttribute("Secure", "yes");
@@ -405,7 +406,7 @@ void cmCPackWIXGenerator::CopyDefinition(cmWIXSourceWriter& source,
                                          std::string const& name,
                                          DefinitionType type)
 {
-  const char* value = GetOption(name.c_str());
+  cmProp value = GetOption(name);
   if (value) {
     if (type == DefinitionType::PATH) {
       AddDefinition(source, name, CMakeToWixPath(value));
@@ -485,17 +486,17 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
   }
 
   std::string featureTitle = cpackPackageName;
-  if (const char* title = GetOption("CPACK_WIX_ROOT_FEATURE_TITLE")) {
-    featureTitle = title;
+  if (cmProp title = GetOption("CPACK_WIX_ROOT_FEATURE_TITLE")) {
+    featureTitle = *title;
   }
   featureDefinitions.AddAttribute("Title", featureTitle);
-  if (const char* desc = GetOption("CPACK_WIX_ROOT_FEATURE_DESCRIPTION")) {
+  if (cmProp desc = GetOption("CPACK_WIX_ROOT_FEATURE_DESCRIPTION")) {
     featureDefinitions.AddAttribute("Description", desc);
   }
   featureDefinitions.AddAttribute("Level", "1");
   this->Patch->ApplyFragment("#PRODUCTFEATURE", featureDefinitions);
 
-  const char* package = GetOption("CPACK_WIX_CMAKE_PACKAGE_REGISTRY");
+  cmProp package = GetOption("CPACK_WIX_CMAKE_PACKAGE_REGISTRY");
   if (package) {
     featureDefinitions.CreateCMakePackageRegistryEntry(
       package, GetOption("CPACK_WIX_UPGRADE_GUID"));
@@ -540,10 +541,9 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
   }
 
   bool emitUninstallShortcut = true;
-  const char* cpackWixProgramMenuFolder =
+  cmProp cpackWixProgramMenuFolder =
     GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER");
-  if (cpackWixProgramMenuFolder &&
-      cm::string_view(cpackWixProgramMenuFolder) == ".") {
+  if (cpackWixProgramMenuFolder && cpackWixProgramMenuFolder == ".") {
     emitUninstallShortcut = false;
   } else if (emittedShortcutTypes.find(cmWIXShortcuts::START_MENU) ==
              emittedShortcutTypes.end()) {
@@ -595,9 +595,9 @@ std::string cmCPackWIXGenerator::GetRootFolderId() const
 
   std::string result = "ProgramFiles<64>Folder";
 
-  const char* rootFolderId = GetOption("CPACK_WIX_ROOT_FOLDER_ID");
+  cmProp rootFolderId = GetOption("CPACK_WIX_ROOT_FOLDER_ID");
   if (rootFolderId) {
-    result = rootFolderId;
+    result = *rootFolderId;
   }
 
   if (GetArchitecture() == "x86") {
@@ -612,8 +612,8 @@ std::string cmCPackWIXGenerator::GetRootFolderId() const
 bool cmCPackWIXGenerator::GenerateMainSourceFileFromTemplate()
 {
   std::string wixTemplate = FindTemplate("WIX.template.in");
-  if (GetOption("CPACK_WIX_TEMPLATE") != 0) {
-    wixTemplate = GetOption("CPACK_WIX_TEMPLATE");
+  if (cmProp wixtpl = GetOption("CPACK_WIX_TEMPLATE")) {
+    wixTemplate = *wixtpl;
   }
 
   if (wixTemplate.empty()) {
@@ -669,7 +669,7 @@ bool cmCPackWIXGenerator::AddComponentsToFeature(
   featureDefinitions.AddAttribute("Id", featureId);
 
   std::vector<std::string> cpackPackageExecutablesList;
-  const char* cpackPackageExecutables = GetOption("CPACK_PACKAGE_EXECUTABLES");
+  cmProp cpackPackageExecutables = GetOption("CPACK_PACKAGE_EXECUTABLES");
   if (cpackPackageExecutables) {
     cmExpandList(cpackPackageExecutables, cpackPackageExecutablesList);
     if (cpackPackageExecutablesList.size() % 2 != 0) {
@@ -683,8 +683,7 @@ bool cmCPackWIXGenerator::AddComponentsToFeature(
   }
 
   std::vector<std::string> cpackPackageDesktopLinksList;
-  const char* cpackPackageDesktopLinks =
-    GetOption("CPACK_CREATE_DESKTOP_LINKS");
+  cmProp cpackPackageDesktopLinks = GetOption("CPACK_CREATE_DESKTOP_LINKS");
   if (cpackPackageDesktopLinks) {
     cmExpandList(cpackPackageDesktopLinks, cpackPackageDesktopLinksList);
   }
@@ -743,10 +742,9 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
   std::string directoryId;
   switch (type) {
     case cmWIXShortcuts::START_MENU: {
-      const char* cpackWixProgramMenuFolder =
+      cmProp cpackWixProgramMenuFolder =
         GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER");
-      if (cpackWixProgramMenuFolder &&
-          cm::string_view(cpackWixProgramMenuFolder) == ".") {
+      if (cpackWixProgramMenuFolder && cpackWixProgramMenuFolder == ".") {
         directoryId = "ProgramMenuFolder";
       } else {
         directoryId = "PROGRAM_MENU_FOLDER";
@@ -805,10 +803,9 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
                           fileDefinitions);
 
   if (type == cmWIXShortcuts::START_MENU) {
-    const char* cpackWixProgramMenuFolder =
+    cmProp cpackWixProgramMenuFolder =
       GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER");
-    if (cpackWixProgramMenuFolder &&
-        cm::string_view(cpackWixProgramMenuFolder) != ".") {
+    if (cpackWixProgramMenuFolder && cpackWixProgramMenuFolder != ".") {
       fileDefinitions.EmitRemoveFolder("CM_REMOVE_PROGRAM_MENU_FOLDER" +
                                        idSuffix);
     }
@@ -973,9 +970,9 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitions(
 bool cmCPackWIXGenerator::RequireOption(std::string const& name,
                                         std::string& value) const
 {
-  const char* tmp = GetOption(name.c_str());
+  cmProp tmp = GetOption(name);
   if (tmp) {
-    value = tmp;
+    value = *tmp;
 
     return true;
   } else {
@@ -1146,7 +1143,7 @@ bool cmCPackWIXGenerator::IsLegalIdCharacter(char c)
 void cmCPackWIXGenerator::CollectExtensions(std::string const& variableName,
                                             extension_set_t& extensions)
 {
-  const char* variableContent = GetOption(variableName.c_str());
+  cmProp variableContent = GetOption(variableName);
   if (!variableContent)
     return;
 
@@ -1157,7 +1154,7 @@ void cmCPackWIXGenerator::CollectExtensions(std::string const& variableName,
 void cmCPackWIXGenerator::CollectXmlNamespaces(std::string const& variableName,
                                                xmlns_map_t& namespaces)
 {
-  const char* variableContent = GetOption(variableName.c_str());
+  cmProp variableContent = GetOption(variableName);
   if (!variableContent) {
     return;
   }
@@ -1186,7 +1183,7 @@ void cmCPackWIXGenerator::CollectXmlNamespaces(std::string const& variableName,
 void cmCPackWIXGenerator::AddCustomFlags(std::string const& variableName,
                                          std::ostream& stream)
 {
-  const char* variableContent = GetOption(variableName.c_str());
+  cmProp variableContent = GetOption(variableName);
   if (!variableContent)
     return;
 

+ 10 - 10
Source/CPack/cmCPackArchiveGenerator.cxx

@@ -2,7 +2,6 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmCPackArchiveGenerator.h"
 
-#include <cstdlib>
 #include <cstring>
 #include <map>
 #include <ostream>
@@ -13,6 +12,7 @@
 #include "cmCPackGenerator.h"
 #include "cmCPackLog.h"
 #include "cmGeneratedFileStream.h"
+#include "cmProperty.h"
 #include "cmStringAlgorithms.h"
 #include "cmSystemTools.h"
 #include "cmWorkingDirectory.h"
@@ -77,7 +77,7 @@ std::string cmCPackArchiveGenerator::GetArchiveComponentFileName(
 
   if (this->IsSet("CPACK_ARCHIVE_" + componentUpper + "_FILE_NAME")) {
     packageFileName +=
-      this->GetOption("CPACK_ARCHIVE_" + componentUpper + "_FILE_NAME");
+      *this->GetOption("CPACK_ARCHIVE_" + componentUpper + "_FILE_NAME");
   } else if (this->IsSet("CPACK_ARCHIVE_FILE_NAME")) {
     packageFileName += this->GetComponentPackageFileName(
       this->GetOption("CPACK_ARCHIVE_FILE_NAME"), component, isGroupName);
@@ -118,11 +118,11 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(
   if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")) {
     filePrefix = cmStrCat(this->GetOption("CPACK_PACKAGE_FILE_NAME"), '/');
   }
-  const char* installPrefix =
-    this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX");
-  if (installPrefix && installPrefix[0] == '/' && installPrefix[1] != 0) {
+  cmProp installPrefix = this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX");
+  if (installPrefix && installPrefix->size() > 1 &&
+      (*installPrefix)[0] == '/') {
     // add to file prefix and remove the leading '/'
-    filePrefix += installPrefix + 1;
+    filePrefix += installPrefix->substr(1);
     filePrefix += "/";
   }
   for (std::string const& file : component->Files) {
@@ -257,9 +257,9 @@ int cmCPackArchiveGenerator::PackageComponentsAllInOne()
   this->packageFileNames[0] += "/";
 
   if (this->IsSet("CPACK_ARCHIVE_FILE_NAME")) {
-    this->packageFileNames[0] += this->GetOption("CPACK_ARCHIVE_FILE_NAME");
+    this->packageFileNames[0] += *this->GetOption("CPACK_ARCHIVE_FILE_NAME");
   } else {
-    this->packageFileNames[0] += this->GetOption("CPACK_PACKAGE_FILE_NAME");
+    this->packageFileNames[0] += *this->GetOption("CPACK_PACKAGE_FILE_NAME");
   }
 
   this->packageFileNames[0] += this->GetOutputExtension();
@@ -345,9 +345,9 @@ int cmCPackArchiveGenerator::GetThreadCount() const
 
   // CPACK_ARCHIVE_THREADS overrides CPACK_THREADS
   if (this->IsSet("CPACK_ARCHIVE_THREADS")) {
-    threads = std::atoi(this->GetOption("CPACK_ARCHIVE_THREADS"));
+    threads = std::stoi(this->GetOption("CPACK_ARCHIVE_THREADS"));
   } else if (this->IsSet("CPACK_THREADS")) {
-    threads = std::atoi(this->GetOption("CPACK_THREADS"));
+    threads = std::stoi(this->GetOption("CPACK_THREADS"));
   }
 
   return threads;

+ 16 - 29
Source/CPack/cmCPackBundleGenerator.cxx

@@ -6,6 +6,7 @@
 #include <vector>
 
 #include "cmCPackLog.h"
+#include "cmProperty.h"
 #include "cmStringAlgorithms.h"
 #include "cmSystemTools.h"
 
@@ -15,8 +16,8 @@ cmCPackBundleGenerator::~cmCPackBundleGenerator() = default;
 
 int cmCPackBundleGenerator::InitializeInternal()
 {
-  const char* name = this->GetOption("CPACK_BUNDLE_NAME");
-  if (nullptr == name) {
+  cmProp name = this->GetOption("CPACK_BUNDLE_NAME");
+  if (!name) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
                   "CPACK_BUNDLE_NAME must be set to use the Bundle generator."
                     << std::endl);
@@ -51,30 +52,24 @@ int cmCPackBundleGenerator::ConstructBundle()
 {
 
   // Get required arguments ...
-  const std::string cpack_bundle_name = this->GetOption("CPACK_BUNDLE_NAME")
-    ? this->GetOption("CPACK_BUNDLE_NAME")
-    : "";
-  if (cpack_bundle_name.empty()) {
+  cmProp cpack_bundle_name = this->GetOption("CPACK_BUNDLE_NAME");
+  if (cpack_bundle_name->empty()) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
                   "CPACK_BUNDLE_NAME must be set." << std::endl);
 
     return 0;
   }
 
-  const std::string cpack_bundle_plist = this->GetOption("CPACK_BUNDLE_PLIST")
-    ? this->GetOption("CPACK_BUNDLE_PLIST")
-    : "";
-  if (cpack_bundle_plist.empty()) {
+  cmProp cpack_bundle_plist = this->GetOption("CPACK_BUNDLE_PLIST");
+  if (cpack_bundle_plist->empty()) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
                   "CPACK_BUNDLE_PLIST must be set." << std::endl);
 
     return 0;
   }
 
-  const std::string cpack_bundle_icon = this->GetOption("CPACK_BUNDLE_ICON")
-    ? this->GetOption("CPACK_BUNDLE_ICON")
-    : "";
-  if (cpack_bundle_icon.empty()) {
+  cmProp cpack_bundle_icon = this->GetOption("CPACK_BUNDLE_ICON");
+  if (cpack_bundle_icon->empty()) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
                   "CPACK_BUNDLE_ICON must be set." << std::endl);
 
@@ -82,10 +77,8 @@ int cmCPackBundleGenerator::ConstructBundle()
   }
 
   // Get optional arguments ...
-  const std::string cpack_bundle_startup_command =
-    this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND")
-    ? this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND")
-    : "";
+  cmProp cpack_bundle_startup_command =
+    this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND");
 
   // The staging directory contains everything that will end-up inside the
   // final disk image ...
@@ -138,7 +131,7 @@ int cmCPackBundleGenerator::ConstructBundle()
 
   // Optionally a user-provided startup command (could be an
   // executable or a script) ...
-  if (!cpack_bundle_startup_command.empty()) {
+  if (!cpack_bundle_startup_command->empty()) {
     std::ostringstream command_source;
     command_source << cpack_bundle_startup_command;
 
@@ -180,13 +173,10 @@ bool cmCPackBundleGenerator::SupportsComponentInstallation() const
 
 int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
 {
-  const std::string cpack_apple_cert_app =
-    this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP")
-    ? this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP")
-    : "";
+  cmProp cpack_apple_cert_app = this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP");
 
   // codesign the application.
-  if (!cpack_apple_cert_app.empty()) {
+  if (!cpack_apple_cert_app->empty()) {
     std::string output;
     std::string bundle_path;
     bundle_path =
@@ -195,13 +185,10 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
     // A list of additional files to sign, ie. frameworks and plugins.
     const std::string sign_parameter =
       this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_PARAMETER")
-      ? this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_PARAMETER")
+      ? *this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_PARAMETER")
       : "--deep -f";
 
-    const std::string sign_files =
-      this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_FILES")
-      ? this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_FILES")
-      : "";
+    cmProp sign_files = this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_FILES");
 
     std::vector<std::string> relFiles = cmExpandedList(sign_files);
 

+ 5 - 3
Source/CPack/cmCPackCygwinBinaryGenerator.cxx

@@ -8,6 +8,7 @@
 #include "cmGeneratedFileStream.h"
 #include "cmGlobalGenerator.h"
 #include "cmMakefile.h"
+#include "cmProperty.h"
 #include "cmSystemTools.h"
 #include "cmake.h"
 
@@ -59,14 +60,15 @@ int cmCPackCygwinBinaryGenerator::PackageFiles()
 const char* cmCPackCygwinBinaryGenerator::GetOutputExtension()
 {
   this->OutputExtension = "-";
-  const char* patchNumber = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
+  cmProp patchNumber = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
   if (!patchNumber) {
-    patchNumber = "1";
+    this->OutputExtension += "1";
     cmCPackLogger(cmCPackLog::LOG_WARNING,
                   "CPACK_CYGWIN_PATCH_NUMBER not specified using 1"
                     << std::endl);
+  } else {
+    this->OutputExtension += patchNumber;
   }
-  this->OutputExtension += patchNumber;
   this->OutputExtension += ".tar.bz2";
   return this->OutputExtension.c_str();
 }

+ 9 - 6
Source/CPack/cmCPackCygwinSourceGenerator.cxx

@@ -8,6 +8,7 @@
 #include "cmGeneratedFileStream.h"
 #include "cmGlobalGenerator.h"
 #include "cmMakefile.h"
+#include "cmProperty.h"
 #include "cmSystemTools.h"
 #include "cmake.h"
 
@@ -94,14 +95,15 @@ int cmCPackCygwinSourceGenerator::PackageFiles()
   }
   std::string outerTarFile =
     cmStrCat(this->GetOption("CPACK_TEMPORARY_DIRECTORY"), '-');
-  const char* patch = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
+  cmProp patch = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
   if (!patch) {
     cmCPackLogger(cmCPackLog::LOG_WARNING,
                   "CPACK_CYGWIN_PATCH_NUMBER"
                     << " not specified, defaulting to 1\n");
-    patch = "1";
+    outerTarFile += "1";
+  } else {
+    outerTarFile += patch;
   }
-  outerTarFile += patch;
   outerTarFile += "-src.tar.bz2";
   std::string tmpDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
   std::string buildScript =
@@ -145,14 +147,15 @@ const char* cmCPackCygwinSourceGenerator::GetPackagingInstallPrefix()
 const char* cmCPackCygwinSourceGenerator::GetOutputExtension()
 {
   this->OutputExtension = "-";
-  const char* patch = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
+  cmProp patch = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
   if (!patch) {
     cmCPackLogger(cmCPackLog::LOG_WARNING,
                   "CPACK_CYGWIN_PATCH_NUMBER"
                     << " not specified, defaulting to 1\n");
-    patch = "1";
+    this->OutputExtension += "1";
+  } else {
+    this->OutputExtension += patch;
   }
-  this->OutputExtension += patch;
   this->OutputExtension += "-src.tar.bz2";
   return this->OutputExtension.c_str();
 }

+ 73 - 74
Source/CPack/cmCPackDebGenerator.cxx

@@ -20,6 +20,7 @@
 #include "cmCPackLog.h"
 #include "cmCryptoHash.h"
 #include "cmGeneratedFileStream.h"
+#include "cmProperty.h"
 #include "cmStringAlgorithms.h"
 #include "cmSystemTools.h"
 
@@ -30,12 +31,12 @@ class DebGenerator
 public:
   DebGenerator(cmCPackLog* logger, std::string outputName, std::string workDir,
                std::string topLevelDir, std::string temporaryDir,
-               const char* debianCompressionType, const char* numThreads,
-               const char* debianArchiveType,
+               cmProp debianCompressionType, cmProp numThreads,
+               cmProp debianArchiveType,
                std::map<std::string, std::string> controlValues,
                bool genShLibs, std::string shLibsFilename, bool genPostInst,
                std::string postInst, bool genPostRm, std::string postRm,
-               const char* controlExtra, bool permissionStrctPolicy,
+               cmProp controlExtra, bool permissionStrctPolicy,
                std::vector<std::string> packageFiles);
 
   bool generate() const;
@@ -54,7 +55,7 @@ private:
   std::string CompressionSuffix;
   const std::string TopLevelDir;
   const std::string TemporaryDir;
-  const char* DebianArchiveType;
+  const std::string DebianArchiveType;
   long NumThreads;
   const std::map<std::string, std::string> ControlValues;
   const bool GenShLibs;
@@ -63,27 +64,28 @@ private:
   const std::string PostInst;
   const bool GenPostRm;
   const std::string PostRm;
-  const char* ControlExtra;
+  cmProp ControlExtra;
   const bool PermissionStrictPolicy;
   const std::vector<std::string> PackageFiles;
   cmArchiveWrite::Compress TarCompressionType;
 };
 
-DebGenerator::DebGenerator(
-  cmCPackLog* logger, std::string outputName, std::string workDir,
-  std::string topLevelDir, std::string temporaryDir,
-  const char* debianCompressionType, const char* numThreads,
-  const char* debianArchiveType,
-  std::map<std::string, std::string> controlValues, bool genShLibs,
-  std::string shLibsFilename, bool genPostInst, std::string postInst,
-  bool genPostRm, std::string postRm, const char* controlExtra,
-  bool permissionStrictPolicy, std::vector<std::string> packageFiles)
+DebGenerator::DebGenerator(cmCPackLog* logger, std::string outputName,
+                           std::string workDir, std::string topLevelDir,
+                           std::string temporaryDir, cmProp debCompressionType,
+                           cmProp numThreads, cmProp debianArchiveType,
+                           std::map<std::string, std::string> controlValues,
+                           bool genShLibs, std::string shLibsFilename,
+                           bool genPostInst, std::string postInst,
+                           bool genPostRm, std::string postRm,
+                           cmProp controlExtra, bool permissionStrictPolicy,
+                           std::vector<std::string> packageFiles)
   : Logger(logger)
   , OutputName(std::move(outputName))
   , WorkDir(std::move(workDir))
   , TopLevelDir(std::move(topLevelDir))
   , TemporaryDir(std::move(temporaryDir))
-  , DebianArchiveType(debianArchiveType ? debianArchiveType : "gnutar")
+  , DebianArchiveType(debianArchiveType ? *debianArchiveType : "gnutar")
   , ControlValues(std::move(controlValues))
   , GenShLibs(genShLibs)
   , ShLibsFilename(std::move(shLibsFilename))
@@ -95,26 +97,27 @@ DebGenerator::DebGenerator(
   , PermissionStrictPolicy(permissionStrictPolicy)
   , PackageFiles(std::move(packageFiles))
 {
-  if (!debianCompressionType) {
-    debianCompressionType = "gzip";
+  std::string debianCompressionType = "gzip";
+  if (debCompressionType) {
+    debianCompressionType = *debCompressionType;
   }
 
-  if (!std::strcmp(debianCompressionType, "lzma")) {
+  if (debianCompressionType == "lzma") {
     this->CompressionSuffix = ".lzma";
     this->TarCompressionType = cmArchiveWrite::CompressLZMA;
-  } else if (!std::strcmp(debianCompressionType, "xz")) {
+  } else if (debianCompressionType == "xz") {
     this->CompressionSuffix = ".xz";
     this->TarCompressionType = cmArchiveWrite::CompressXZ;
-  } else if (!std::strcmp(debianCompressionType, "bzip2")) {
+  } else if (debianCompressionType == "bzip2") {
     this->CompressionSuffix = ".bz2";
     this->TarCompressionType = cmArchiveWrite::CompressBZip2;
-  } else if (!std::strcmp(debianCompressionType, "gzip")) {
+  } else if (debianCompressionType == "gzip") {
     this->CompressionSuffix = ".gz";
     this->TarCompressionType = cmArchiveWrite::CompressGZip;
-  } else if (!std::strcmp(debianCompressionType, "zstd")) {
+  } else if (debianCompressionType == "zstd") {
     this->CompressionSuffix = ".zst";
     this->TarCompressionType = cmArchiveWrite::CompressZstd;
-  } else if (!std::strcmp(debianCompressionType, "none")) {
+  } else if (debianCompressionType == "none") {
     this->CompressionSuffix.clear();
     this->TarCompressionType = cmArchiveWrite::CompressNone;
   } else {
@@ -539,9 +542,8 @@ int cmCPackDebGenerator::PackageOnePack(std::string const& initialTopLevel,
   std::string localToplevel(initialTopLevel);
   std::string packageFileName(
     cmSystemTools::GetParentDirectory(this->toplevel));
-  std::string outputFileName(
-    std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) + "-" +
-    packageName + this->GetOutputExtension());
+  std::string outputFileName(*this->GetOption("CPACK_PACKAGE_FILE_NAME") +
+                             "-" + packageName + this->GetOutputExtension());
 
   localToplevel += "/" + packageName;
   /* replace the TEMP DIRECTORY with the component one */
@@ -627,9 +629,8 @@ int cmCPackDebGenerator::PackageComponentsAllInOne(
   std::string localToplevel(initialTopLevel);
   std::string packageFileName(
     cmSystemTools::GetParentDirectory(this->toplevel));
-  std::string outputFileName(
-    std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) +
-    this->GetOutputExtension());
+  std::string outputFileName(*this->GetOption("CPACK_PACKAGE_FILE_NAME") +
+                             this->GetOutputExtension());
   // all GROUP in one vs all COMPONENT in one
   // if must be here otherwise non component paths have a trailing / while
   // components don't
@@ -684,7 +685,7 @@ int cmCPackDebGenerator::PackageFiles()
 
 bool cmCPackDebGenerator::createDebPackages()
 {
-  auto make_package = [this](const char* const path,
+  auto make_package = [this](const std::string& path,
                              const char* const output_var,
                              bool (cmCPackDebGenerator::*creator)()) -> bool {
     try {
@@ -706,7 +707,7 @@ bool cmCPackDebGenerator::createDebPackages()
   bool retval =
     make_package(this->GetOption("GEN_WDIR"), "GEN_CPACK_OUTPUT_FILE_NAME",
                  &cmCPackDebGenerator::createDeb);
-  const char* const dbgsymdir_path = this->GetOption("GEN_DBGSYMDIR");
+  cmProp 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) &&
@@ -723,78 +724,75 @@ bool cmCPackDebGenerator::createDeb()
   controlValues["Package"] = cmsys::SystemTools::LowerCase(
     this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_NAME"));
   controlValues["Version"] =
-    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_VERSION");
+    *this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_VERSION");
   controlValues["Section"] =
-    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SECTION");
+    *this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SECTION");
   controlValues["Priority"] =
-    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PRIORITY");
+    *this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PRIORITY");
   controlValues["Architecture"] =
-    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ARCHITECTURE");
+    *this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ARCHITECTURE");
   controlValues["Maintainer"] =
-    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_MAINTAINER");
+    *this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_MAINTAINER");
   controlValues["Description"] =
-    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DESCRIPTION");
+    *this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DESCRIPTION");
 
-  const char* debian_pkg_source =
+  cmProp debian_pkg_source =
     this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SOURCE");
   if (cmNonempty(debian_pkg_source)) {
-    controlValues["Source"] = debian_pkg_source;
+    controlValues["Source"] = *debian_pkg_source;
   }
-  const char* debian_pkg_dep =
-    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DEPENDS");
+  cmProp debian_pkg_dep = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DEPENDS");
   if (cmNonempty(debian_pkg_dep)) {
-    controlValues["Depends"] = debian_pkg_dep;
+    controlValues["Depends"] = *debian_pkg_dep;
   }
-  const char* debian_pkg_rec =
+  cmProp debian_pkg_rec =
     this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_RECOMMENDS");
   if (cmNonempty(debian_pkg_rec)) {
-    controlValues["Recommends"] = debian_pkg_rec;
+    controlValues["Recommends"] = *debian_pkg_rec;
   }
-  const char* debian_pkg_sug =
-    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SUGGESTS");
+  cmProp debian_pkg_sug = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SUGGESTS");
   if (cmNonempty(debian_pkg_sug)) {
-    controlValues["Suggests"] = debian_pkg_sug;
+    controlValues["Suggests"] = *debian_pkg_sug;
   }
-  const char* debian_pkg_url =
-    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_HOMEPAGE");
+  cmProp debian_pkg_url = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_HOMEPAGE");
   if (cmNonempty(debian_pkg_url)) {
-    controlValues["Homepage"] = debian_pkg_url;
+    controlValues["Homepage"] = *debian_pkg_url;
   }
-  const char* debian_pkg_predep =
+  cmProp debian_pkg_predep =
     this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PREDEPENDS");
   if (cmNonempty(debian_pkg_predep)) {
-    controlValues["Pre-Depends"] = debian_pkg_predep;
+    controlValues["Pre-Depends"] = *debian_pkg_predep;
   }
-  const char* debian_pkg_enhances =
+  cmProp debian_pkg_enhances =
     this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ENHANCES");
   if (cmNonempty(debian_pkg_enhances)) {
-    controlValues["Enhances"] = debian_pkg_enhances;
+    controlValues["Enhances"] = *debian_pkg_enhances;
   }
-  const char* debian_pkg_breaks =
+  cmProp debian_pkg_breaks =
     this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_BREAKS");
   if (cmNonempty(debian_pkg_breaks)) {
-    controlValues["Breaks"] = debian_pkg_breaks;
+    controlValues["Breaks"] = *debian_pkg_breaks;
   }
-  const char* debian_pkg_conflicts =
+  cmProp debian_pkg_conflicts =
     this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_CONFLICTS");
   if (cmNonempty(debian_pkg_conflicts)) {
-    controlValues["Conflicts"] = debian_pkg_conflicts;
+    controlValues["Conflicts"] = *debian_pkg_conflicts;
   }
-  const char* debian_pkg_provides =
+  cmProp debian_pkg_provides =
     this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PROVIDES");
   if (cmNonempty(debian_pkg_provides)) {
-    controlValues["Provides"] = debian_pkg_provides;
+    controlValues["Provides"] = *debian_pkg_provides;
   }
-  const char* debian_pkg_replaces =
+  cmProp debian_pkg_replaces =
     this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_REPLACES");
   if (cmNonempty(debian_pkg_replaces)) {
-    controlValues["Replaces"] = debian_pkg_replaces;
+    controlValues["Replaces"] = *debian_pkg_replaces;
   }
 
   const std::string strGenWDIR(this->GetOption("GEN_WDIR"));
   const std::string shlibsfilename = strGenWDIR + "/shlibs";
 
-  const char* debian_pkg_shlibs =
+  cmProp debian_pkg_shlibs =
     this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SHLIBS");
   const bool gen_shibs = this->IsOn("CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS") &&
     cmNonempty(debian_pkg_shlibs);
@@ -851,32 +849,33 @@ bool cmCPackDebGenerator::createDbgsymDDeb()
   // debian policy enforce lower case for package name
   std::string packageNameLower = cmsys::SystemTools::LowerCase(
     this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_NAME"));
-  const char* debian_pkg_version =
+  cmProp debian_pkg_version =
     this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_VERSION");
 
   controlValues["Package"] = packageNameLower + "-dbgsym";
   controlValues["Package-Type"] = "ddeb";
-  controlValues["Version"] = debian_pkg_version;
+  controlValues["Version"] = *debian_pkg_version;
   controlValues["Auto-Built-Package"] = "debug-symbols";
-  controlValues["Depends"] = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_NAME") +
-    std::string(" (= ") + debian_pkg_version + ")";
+  controlValues["Depends"] =
+    *this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_NAME") + std::string(" (= ") +
+    *debian_pkg_version + ")";
   controlValues["Section"] = "debug";
   controlValues["Priority"] = "optional";
   controlValues["Architecture"] =
-    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ARCHITECTURE");
+    *this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ARCHITECTURE");
   controlValues["Maintainer"] =
-    this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_MAINTAINER");
+    *this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_MAINTAINER");
   controlValues["Description"] =
     std::string("debug symbols for ") + packageNameLower;
 
-  const char* debian_pkg_source =
+  cmProp debian_pkg_source =
     this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SOURCE");
   if (cmNonempty(debian_pkg_source)) {
-    controlValues["Source"] = debian_pkg_source;
+    controlValues["Source"] = *debian_pkg_source;
   }
-  const char* debian_build_ids = this->GetOption("GEN_BUILD_IDS");
+  cmProp debian_build_ids = this->GetOption("GEN_BUILD_IDS");
   if (cmNonempty(debian_build_ids)) {
-    controlValues["Build-Ids"] = debian_build_ids;
+    controlValues["Build-Ids"] = *debian_build_ids;
   }
 
   DebGenerator gen(
@@ -914,7 +913,7 @@ std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix(
   std::string groupVar =
     "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
   if (nullptr != this->GetOption(groupVar)) {
-    return std::string(this->GetOption(groupVar));
+    return *this->GetOption(groupVar);
   }
   return componentName;
 }

+ 20 - 32
Source/CPack/cmCPackDragNDropGenerator.cxx

@@ -18,6 +18,7 @@
 #include "cmCPackLog.h"
 #include "cmDuration.h"
 #include "cmGeneratedFileStream.h"
+#include "cmProperty.h"
 #include "cmStringAlgorithms.h"
 #include "cmSystemTools.h"
 #include "cmXMLWriter.h"
@@ -260,48 +261,35 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
                                          const std::string& output_file)
 {
   // Get optional arguments ...
-  const std::string cpack_package_icon = this->GetOption("CPACK_PACKAGE_ICON")
-    ? this->GetOption("CPACK_PACKAGE_ICON")
-    : "";
+  cmProp cpack_package_icon = this->GetOption("CPACK_PACKAGE_ICON");
 
   const std::string cpack_dmg_volume_name =
     this->GetOption("CPACK_DMG_VOLUME_NAME")
-    ? this->GetOption("CPACK_DMG_VOLUME_NAME")
-    : this->GetOption("CPACK_PACKAGE_FILE_NAME");
+    ? *this->GetOption("CPACK_DMG_VOLUME_NAME")
+    : *this->GetOption("CPACK_PACKAGE_FILE_NAME");
 
   const std::string cpack_dmg_format = this->GetOption("CPACK_DMG_FORMAT")
-    ? this->GetOption("CPACK_DMG_FORMAT")
+    ? *this->GetOption("CPACK_DMG_FORMAT")
     : "UDZO";
 
   const std::string cpack_dmg_filesystem =
     this->GetOption("CPACK_DMG_FILESYSTEM")
-    ? this->GetOption("CPACK_DMG_FILESYSTEM")
+    ? *this->GetOption("CPACK_DMG_FILESYSTEM")
     : "HFS+";
 
   // Get optional arguments ...
   std::string cpack_license_file =
-    this->GetOption("CPACK_RESOURCE_FILE_LICENSE")
-    ? this->GetOption("CPACK_RESOURCE_FILE_LICENSE")
-    : "";
+    *this->GetOption("CPACK_RESOURCE_FILE_LICENSE");
 
-  const std::string cpack_dmg_background_image =
-    this->GetOption("CPACK_DMG_BACKGROUND_IMAGE")
-    ? this->GetOption("CPACK_DMG_BACKGROUND_IMAGE")
-    : "";
+  cmProp cpack_dmg_background_image =
+    this->GetOption("CPACK_DMG_BACKGROUND_IMAGE");
 
-  const std::string cpack_dmg_ds_store = this->GetOption("CPACK_DMG_DS_STORE")
-    ? this->GetOption("CPACK_DMG_DS_STORE")
-    : "";
+  cmProp cpack_dmg_ds_store = this->GetOption("CPACK_DMG_DS_STORE");
 
-  const std::string cpack_dmg_languages =
-    this->GetOption("CPACK_DMG_SLA_LANGUAGES")
-    ? this->GetOption("CPACK_DMG_SLA_LANGUAGES")
-    : "";
+  cmProp cpack_dmg_languages = this->GetOption("CPACK_DMG_SLA_LANGUAGES");
 
-  const std::string cpack_dmg_ds_store_setup_script =
-    this->GetOption("CPACK_DMG_DS_STORE_SETUP_SCRIPT")
-    ? this->GetOption("CPACK_DMG_DS_STORE_SETUP_SCRIPT")
-    : "";
+  cmProp cpack_dmg_ds_store_setup_script =
+    this->GetOption("CPACK_DMG_DS_STORE_SETUP_SCRIPT");
 
   const bool cpack_dmg_disable_applications_symlink =
     this->IsOn("CPACK_DMG_DISABLE_APPLICATIONS_SYMLINK");
@@ -332,7 +320,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
   }
 
   // Optionally add a custom volume icon ...
-  if (!cpack_package_icon.empty()) {
+  if (!cpack_package_icon->empty()) {
     std::ostringstream package_icon_source;
     package_icon_source << cpack_package_icon;
 
@@ -351,7 +339,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
 
   // Optionally add a custom .DS_Store file
   // (e.g. for setting background/layout) ...
-  if (!cpack_dmg_ds_store.empty()) {
+  if (!cpack_dmg_ds_store->empty()) {
     std::ostringstream package_settings_source;
     package_settings_source << cpack_dmg_ds_store;
 
@@ -372,7 +360,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
   // Optionally add a custom background image ...
   // Make sure the background file type is the same as the custom image
   // and that the file is hidden so it doesn't show up.
-  if (!cpack_dmg_background_image.empty()) {
+  if (!cpack_dmg_background_image->empty()) {
     const std::string extension =
       cmSystemTools::GetFilenameLastExtension(cpack_dmg_background_image);
     std::ostringstream package_background_source;
@@ -394,7 +382,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
   }
 
   bool remount_image =
-    !cpack_package_icon.empty() || !cpack_dmg_ds_store_setup_script.empty();
+    !cpack_package_icon->empty() || !cpack_dmg_ds_store_setup_script->empty();
 
   std::string temp_image_format = "UDZO";
 
@@ -471,7 +459,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
     }
 
     // Optionally set the custom icon flag for the image ...
-    if (!had_error && !cpack_package_icon.empty()) {
+    if (!had_error && !cpack_package_icon->empty()) {
       std::string error;
       std::ostringstream setfile_command;
       setfile_command << this->GetOption("CPACK_COMMAND_SETFILE");
@@ -490,7 +478,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
 
     // Optionally we can execute a custom apple script to generate
     // the .DS_Store for the volume folder ...
-    if (!had_error && !cpack_dmg_ds_store_setup_script.empty()) {
+    if (!had_error && !cpack_dmg_ds_store_setup_script->empty()) {
       std::ostringstream setup_script_command;
       setup_script_command << "osascript"
                            << " \"" << cpack_dmg_ds_store_setup_script << "\""
@@ -718,7 +706,7 @@ std::string cmCPackDragNDropGenerator::GetComponentInstallDirNameSuffix(
     // the current COMPONENT belongs to.
     std::string groupVar =
       "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
-    const char* _groupName = GetOption(groupVar);
+    cmProp _groupName = this->GetOption(groupVar);
     if (_groupName) {
       std::string groupName = _groupName;
 

+ 18 - 19
Source/CPack/cmCPackExternalGenerator.cxx

@@ -16,6 +16,7 @@
 #include "cmCPackComponentGroup.h"
 #include "cmCPackLog.h"
 #include "cmMakefile.h"
+#include "cmProperty.h"
 #include "cmStringAlgorithms.h"
 #include "cmSystemTools.h"
 
@@ -60,7 +61,7 @@ int cmCPackExternalGenerator::PackageFiles()
     return 0;
   }
 
-  const char* packageScript = this->GetOption("CPACK_EXTERNAL_PACKAGE_SCRIPT");
+  cmProp packageScript = this->GetOption("CPACK_EXTERNAL_PACKAGE_SCRIPT");
   if (cmNonempty(packageScript)) {
     if (!cmSystemTools::FileIsFullPath(packageScript)) {
       cmCPackLogger(
@@ -76,10 +77,9 @@ int cmCPackExternalGenerator::PackageFiles()
       return 0;
     }
 
-    const char* builtPackagesStr =
-      this->GetOption("CPACK_EXTERNAL_BUILT_PACKAGES");
-    if (builtPackagesStr) {
-      cmExpandList(builtPackagesStr, this->packageFileNames, false);
+    cmProp builtPackages = this->GetOption("CPACK_EXTERNAL_BUILT_PACKAGES");
+    if (builtPackages) {
+      cmExpandList(builtPackages, this->packageFileNames, false);
     }
   }
 
@@ -181,43 +181,42 @@ int cmCPackExternalGenerator::cmCPackExternalVersionGenerator::WriteToJSON(
     return 0;
   }
 
-  const char* packageName = this->Parent->GetOption("CPACK_PACKAGE_NAME");
+  cmProp packageName = this->Parent->GetOption("CPACK_PACKAGE_NAME");
   if (packageName) {
-    root["packageName"] = packageName;
+    root["packageName"] = *packageName;
   }
 
-  const char* packageVersion =
-    this->Parent->GetOption("CPACK_PACKAGE_VERSION");
+  cmProp packageVersion = this->Parent->GetOption("CPACK_PACKAGE_VERSION");
   if (packageVersion) {
-    root["packageVersion"] = packageVersion;
+    root["packageVersion"] = *packageVersion;
   }
 
-  const char* packageDescriptionFile =
+  cmProp packageDescriptionFile =
     this->Parent->GetOption("CPACK_PACKAGE_DESCRIPTION_FILE");
   if (packageDescriptionFile) {
-    root["packageDescriptionFile"] = packageDescriptionFile;
+    root["packageDescriptionFile"] = *packageDescriptionFile;
   }
 
-  const char* packageDescriptionSummary =
+  cmProp packageDescriptionSummary =
     this->Parent->GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY");
   if (packageDescriptionSummary) {
-    root["packageDescriptionSummary"] = packageDescriptionSummary;
+    root["packageDescriptionSummary"] = *packageDescriptionSummary;
   }
 
-  const char* buildConfigCstr = this->Parent->GetOption("CPACK_BUILD_CONFIG");
+  cmProp buildConfigCstr = this->Parent->GetOption("CPACK_BUILD_CONFIG");
   if (buildConfigCstr) {
-    root["buildConfig"] = buildConfigCstr;
+    root["buildConfig"] = *buildConfigCstr;
   }
 
-  const char* defaultDirectoryPermissions =
+  cmProp defaultDirectoryPermissions =
     this->Parent->GetOption("CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS");
   if (cmNonempty(defaultDirectoryPermissions)) {
-    root["defaultDirectoryPermissions"] = defaultDirectoryPermissions;
+    root["defaultDirectoryPermissions"] = *defaultDirectoryPermissions;
   }
   if (cmIsInternallyOn(this->Parent->GetOption("CPACK_SET_DESTDIR"))) {
     root["setDestdir"] = true;
     root["packagingInstallPrefix"] =
-      this->Parent->GetOption("CPACK_PACKAGING_INSTALL_PREFIX");
+      *this->Parent->GetOption("CPACK_PACKAGING_INSTALL_PREFIX");
   } else {
     root["setDestdir"] = false;
   }

+ 2 - 2
Source/CPack/cmCPackFreeBSDGenerator.cxx

@@ -203,11 +203,11 @@ cmGeneratedFileStream& operator<<(cmGeneratedFileStream& s,
 // basically a wrapper that handles the NULL-ptr return from GetOption().
 std::string cmCPackFreeBSDGenerator::var_lookup(const char* var_name)
 {
-  const char* pv = this->GetOption(var_name);
+  cmProp pv = this->GetOption(var_name);
   if (!pv) {
     return std::string();
   }
-  return pv;
+  return *pv;
 }
 
 // Produce UCL in the given @p manifest file for the common

+ 70 - 83
Source/CPack/cmCPackGenerator.cxx

@@ -78,14 +78,14 @@ int cmCPackGenerator::PrepareNames()
 
   std::string tempDirectory =
     cmStrCat(this->GetOption("CPACK_PACKAGE_DIRECTORY"), "/_CPack_Packages/");
-  const char* toplevelTag = this->GetOption("CPACK_TOPLEVEL_TAG");
+  cmProp toplevelTag = this->GetOption("CPACK_TOPLEVEL_TAG");
   if (toplevelTag) {
-    tempDirectory += toplevelTag;
+    tempDirectory += *toplevelTag;
     tempDirectory += "/";
   }
-  tempDirectory += this->GetOption("CPACK_GENERATOR");
+  tempDirectory += *this->GetOption("CPACK_GENERATOR");
   std::string topDirectory = tempDirectory;
-  const char* pfname = this->GetOption("CPACK_PACKAGE_FILE_NAME");
+  cmProp pfname = this->GetOption("CPACK_PACKAGE_FILE_NAME");
   if (!pfname) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
                   "CPACK_PACKAGE_FILE_NAME not specified" << std::endl);
@@ -99,7 +99,7 @@ int cmCPackGenerator::PrepareNames()
     return 0;
   }
   outName += this->GetOutputExtension();
-  const char* pdir = this->GetOption("CPACK_PACKAGE_DIRECTORY");
+  cmProp pdir = this->GetOption("CPACK_PACKAGE_DIRECTORY");
   if (!pdir) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
                   "CPACK_PACKAGE_DIRECTORY not specified" << std::endl);
@@ -125,7 +125,7 @@ int cmCPackGenerator::PrepareNames()
 
   cmCPackLogger(cmCPackLog::LOG_DEBUG,
                 "Look for: CPACK_PACKAGE_DESCRIPTION_FILE" << std::endl);
-  const char* descFileName = this->GetOption("CPACK_PACKAGE_DESCRIPTION_FILE");
+  cmProp descFileName = this->GetOption("CPACK_PACKAGE_DESCRIPTION_FILE");
   if (descFileName && !this->GetOption("CPACK_PACKAGE_DESCRIPTION")) {
     cmCPackLogger(cmCPackLog::LOG_DEBUG,
                   "Look for: " << descFileName << std::endl);
@@ -135,7 +135,7 @@ int cmCPackGenerator::PrepareNames()
                       << descFileName << "]" << std::endl);
       return 0;
     }
-    cmsys::ifstream ifs(descFileName);
+    cmsys::ifstream ifs(descFileName->c_str());
     if (!ifs) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
                     "Cannot open description file name: " << descFileName
@@ -151,9 +151,9 @@ int cmCPackGenerator::PrepareNames()
       ostr << cmXMLSafe(line) << std::endl;
     }
     this->SetOption("CPACK_PACKAGE_DESCRIPTION", ostr.str().c_str());
-    const char* defFileName =
+    cmProp defFileName =
       this->GetOption("CPACK_DEFAULT_PACKAGE_DESCRIPTION_FILE");
-    if (defFileName && !strcmp(defFileName, descFileName)) {
+    if (defFileName && (defFileName == descFileName)) {
       this->SetOption("CPACK_USED_DEFAULT_PACKAGE_DESCRIPTION_FILE", "ON");
     }
   }
@@ -165,7 +165,7 @@ int cmCPackGenerator::PrepareNames()
         << std::endl);
     return 0;
   }
-  const char* algoSignature = this->GetOption("CPACK_PACKAGE_CHECKSUM");
+  cmProp algoSignature = this->GetOption("CPACK_PACKAGE_CHECKSUM");
   if (algoSignature) {
     if (!cmCryptoHash::New(algoSignature)) {
       cmCPackLogger(cmCPackLog::LOG_ERROR,
@@ -215,7 +215,7 @@ int cmCPackGenerator::InstallProject()
   // prepare default created directory permissions
   mode_t default_dir_mode_v = 0;
   mode_t* default_dir_mode = nullptr;
-  const char* default_dir_install_permissions =
+  cmProp default_dir_install_permissions =
     this->GetOption("CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS");
   if (cmNonempty(default_dir_install_permissions)) {
     std::vector<std::string> items =
@@ -266,7 +266,7 @@ int cmCPackGenerator::InstallProject()
   }
 
   // Run pre-build actions
-  const char* preBuildScripts = this->GetOption("CPACK_PRE_BUILD_SCRIPTS");
+  cmProp preBuildScripts = this->GetOption("CPACK_PRE_BUILD_SCRIPTS");
   if (preBuildScripts) {
     const auto scripts = cmExpandedList(preBuildScripts, false);
     for (const auto& script : scripts) {
@@ -293,7 +293,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands(
   bool setDestDir, const std::string& tempInstallDirectory)
 {
   (void)setDestDir;
-  const char* installCommands = this->GetOption("CPACK_INSTALL_COMMANDS");
+  cmProp installCommands = this->GetOption("CPACK_INSTALL_COMMANDS");
   if (cmNonempty(installCommands)) {
     std::string tempInstallDirectoryEnv =
       cmStrCat("CMAKE_INSTALL_PREFIX=", tempInstallDirectory);
@@ -333,7 +333,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
   (void)setDestDir;
   (void)tempInstallDirectory;
   std::vector<cmsys::RegularExpression> ignoreFilesRegex;
-  const char* cpackIgnoreFiles = this->GetOption("CPACK_IGNORE_FILES");
+  cmProp cpackIgnoreFiles = this->GetOption("CPACK_IGNORE_FILES");
   if (cpackIgnoreFiles) {
     std::vector<std::string> ignoreFilesRegexString =
       cmExpandedList(cpackIgnoreFiles);
@@ -343,8 +343,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
       ignoreFilesRegex.emplace_back(ifr);
     }
   }
-  const char* installDirectories =
-    this->GetOption("CPACK_INSTALLED_DIRECTORIES");
+  cmProp installDirectories = this->GetOption("CPACK_INSTALLED_DIRECTORIES");
   if (cmNonempty(installDirectories)) {
     std::vector<std::string> installDirectoriesVector =
       cmExpandedList(installDirectories);
@@ -472,9 +471,9 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
 int cmCPackGenerator::InstallProjectViaInstallScript(
   bool setDestDir, const std::string& tempInstallDirectory)
 {
-  const char* cmakeScripts = this->GetOption("CPACK_INSTALL_SCRIPTS");
+  cmProp cmakeScripts = this->GetOption("CPACK_INSTALL_SCRIPTS");
   {
-    const char* const cmakeScript = this->GetOption("CPACK_INSTALL_SCRIPT");
+    cmProp const cmakeScript = this->GetOption("CPACK_INSTALL_SCRIPT");
     if (cmakeScript && cmakeScripts) {
       cmCPackLogger(
         cmCPackLog::LOG_WARNING,
@@ -485,7 +484,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript(
       cmakeScripts = cmakeScript;
     }
   }
-  if (cmakeScripts && *cmakeScripts) {
+  if (cmakeScripts && !cmakeScripts->empty()) {
     cmCPackLogger(cmCPackLog::LOG_OUTPUT,
                   "- Install scripts: " << cmakeScripts << std::endl);
     std::vector<std::string> cmakeScriptsVector = cmExpandedList(cmakeScripts);
@@ -502,7 +501,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript(
 
         std::string dir;
         if (this->GetOption("CPACK_INSTALL_PREFIX")) {
-          dir += this->GetOption("CPACK_INSTALL_PREFIX");
+          dir += *this->GetOption("CPACK_INSTALL_PREFIX");
         }
         this->SetOption("CMAKE_INSTALL_PREFIX", dir.c_str());
         cmCPackLogger(
@@ -540,8 +539,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
   bool setDestDir, const std::string& baseTempInstallDirectory,
   const mode_t* default_dir_mode)
 {
-  const char* cmakeProjects = this->GetOption("CPACK_INSTALL_CMAKE_PROJECTS");
-  const char* cmakeGenerator = this->GetOption("CPACK_CMAKE_GENERATOR");
+  cmProp cmakeProjects = this->GetOption("CPACK_INSTALL_CMAKE_PROJECTS");
+  cmProp cmakeGenerator = this->GetOption("CPACK_CMAKE_GENERATOR");
   std::string absoluteDestFiles;
   if (cmNonempty(cmakeProjects)) {
     if (!cmakeGenerator) {
@@ -595,7 +594,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
         // Determine the installation types for this project (if provided).
         std::string installTypesVar = "CPACK_" +
           cmSystemTools::UpperCase(project.Component) + "_INSTALL_TYPES";
-        const char* installTypes = this->GetOption(installTypesVar);
+        cmProp installTypes = this->GetOption(installTypesVar);
         if (cmNonempty(installTypes)) {
           std::vector<std::string> installTypesVector =
             cmExpandedList(installTypes);
@@ -608,7 +607,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
         // Determine the set of components that will be used in this project
         std::string componentsVar =
           "CPACK_COMPONENTS_" + cmSystemTools::UpperCase(project.Component);
-        const char* components = this->GetOption(componentsVar);
+        cmProp components = this->GetOption(componentsVar);
         if (cmNonempty(components)) {
           cmExpandList(components, componentsVector);
           for (std::string const& comp : componentsVector) {
@@ -625,12 +624,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
       std::vector<std::string> buildConfigs;
 
       // Try get configuration names given via `-C` CLI option
-      {
-        const char* const buildConfigCstr =
-          this->GetOption("CPACK_BUILD_CONFIG");
-        auto buildConfig = buildConfigCstr ? buildConfigCstr : std::string{};
-        cmExpandList(buildConfig, buildConfigs);
-      }
+      cmExpandList(this->GetOption("CPACK_BUILD_CONFIG"), buildConfigs);
 
       // Remove duplicates
       std::sort(buildConfigs.begin(), buildConfigs.end());
@@ -767,11 +761,11 @@ int cmCPackGenerator::InstallCMakeProject(
     tempInstallDirectory += this->GetComponentInstallDirNameSuffix(component);
     if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")) {
       tempInstallDirectory += "/";
-      tempInstallDirectory += this->GetOption("CPACK_PACKAGE_FILE_NAME");
+      tempInstallDirectory += *this->GetOption("CPACK_PACKAGE_FILE_NAME");
     }
   }
 
-  const char* default_dir_inst_permissions =
+  cmProp default_dir_inst_permissions =
     this->GetOption("CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS");
   if (cmNonempty(default_dir_inst_permissions)) {
     mf.AddDefinition("CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS",
@@ -795,12 +789,13 @@ int cmCPackGenerator::InstallCMakeProject(
     // I know this is tricky and awkward but it's the price for
     // CPACK_SET_DESTDIR backward compatibility.
     if (cmIsInternallyOn(this->GetOption("CPACK_SET_DESTDIR"))) {
-      this->SetOption("CPACK_INSTALL_PREFIX",
-                      this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX"));
+      this->SetOption(
+        "CPACK_INSTALL_PREFIX",
+        this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX").GetCStr());
     }
     std::string dir;
     if (this->GetOption("CPACK_INSTALL_PREFIX")) {
-      dir += this->GetOption("CPACK_INSTALL_PREFIX");
+      dir += *this->GetOption("CPACK_INSTALL_PREFIX");
     }
     mf.AddDefinition("CMAKE_INSTALL_PREFIX", dir);
 
@@ -979,7 +974,7 @@ int cmCPackGenerator::InstallCMakeProject(
       } else {
         this->SetOption(
           absoluteDestFileComponent,
-          cmToCStr(mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")));
+          mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES").GetCStr());
       }
     }
   }
@@ -1038,8 +1033,7 @@ int cmCPackGenerator::DoPackage()
   }
 
   if (cmIsOn(this->GetOption("CPACK_REMOVE_TOPLEVEL_DIRECTORY"))) {
-    const char* toplevelDirectory =
-      this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
+    cmProp toplevelDirectory = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
     if (cmSystemTools::FileExists(toplevelDirectory)) {
       cmCPackLogger(cmCPackLog::LOG_VERBOSE,
                     "Remove toplevel directory: " << toplevelDirectory
@@ -1060,9 +1054,9 @@ int cmCPackGenerator::DoPackage()
   }
   cmCPackLogger(cmCPackLog::LOG_DEBUG, "Done install project " << std::endl);
 
-  const char* tempPackageFileName =
+  cmProp tempPackageFileName =
     this->GetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME");
-  const char* tempDirectory = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
+  cmProp tempDirectory = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
 
   cmCPackLogger(cmCPackLog::LOG_DEBUG, "Find files" << std::endl);
   cmsys::Glob gl;
@@ -1079,7 +1073,7 @@ int cmCPackGenerator::DoPackage()
   cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Create package" << std::endl);
   cmCPackLogger(cmCPackLog::LOG_VERBOSE,
                 "Package files to: "
-                  << (tempPackageFileName ? tempPackageFileName : "(NULL)")
+                  << (tempPackageFileName ? *tempPackageFileName : "(NULL)")
                   << std::endl);
   if (cmSystemTools::FileExists(tempPackageFileName)) {
     cmCPackLogger(cmCPackLog::LOG_VERBOSE,
@@ -1099,9 +1093,8 @@ int cmCPackGenerator::DoPackage()
    * may update this during PackageFiles.
    * (either putting several names or updating the provided one)
    */
-  this->packageFileNames.emplace_back(tempPackageFileName ? tempPackageFileName
-                                                          : "");
-  this->toplevel = tempDirectory;
+  this->packageFileNames.emplace_back(tempPackageFileName);
+  this->toplevel = *tempDirectory;
   { // scope that enables package generators to run internal scripts with
     // latest CMake policies enabled
     cmMakefile::ScopePushPop pp{ this->MakefileMap };
@@ -1115,7 +1108,7 @@ int cmCPackGenerator::DoPackage()
     }
   }
   // Run post-build actions
-  const char* postBuildScripts = this->GetOption("CPACK_POST_BUILD_SCRIPTS");
+  cmProp postBuildScripts = this->GetOption("CPACK_POST_BUILD_SCRIPTS");
   if (postBuildScripts) {
     this->MakefileMap->AddDefinition("CPACK_PACKAGE_FILES",
                                      cmJoin(this->packageFileNames, ";"));
@@ -1135,8 +1128,8 @@ int cmCPackGenerator::DoPackage()
   }
 
   /* Prepare checksum algorithm*/
-  const char* algo = this->GetOption("CPACK_PACKAGE_CHECKSUM");
-  std::unique_ptr<cmCryptoHash> crypto = cmCryptoHash::New(algo ? algo : "");
+  cmProp algo = this->GetOption("CPACK_PACKAGE_CHECKSUM");
+  std::unique_ptr<cmCryptoHash> crypto = cmCryptoHash::New(algo);
 
   /*
    * Copy the generated packages to final destination
@@ -1151,19 +1144,19 @@ int cmCPackGenerator::DoPackage()
   for (std::string const& pkgFileName : this->packageFileNames) {
     std::string tmpPF(this->GetOption("CPACK_OUTPUT_FILE_PREFIX"));
     std::string filename(cmSystemTools::GetFilenameName(pkgFileName));
-    tempPackageFileName = pkgFileName.c_str();
+    tempPackageFileName = cmProp(pkgFileName);
     tmpPF += "/" + filename;
     const char* packageFileName = tmpPF.c_str();
     cmCPackLogger(cmCPackLog::LOG_DEBUG,
                   "Copy final package(s): "
-                    << (tempPackageFileName ? tempPackageFileName : "(NULL)")
+                    << (tempPackageFileName ? *tempPackageFileName : "(NULL)")
                     << " to " << (packageFileName ? packageFileName : "(NULL)")
                     << std::endl);
     if (!cmSystemTools::CopyFileIfDifferent(pkgFileName, tmpPF)) {
       cmCPackLogger(
         cmCPackLog::LOG_ERROR,
         "Problem copying the package: "
-          << (tempPackageFileName ? tempPackageFileName : "(NULL)") << " to "
+          << (tempPackageFileName ? *tempPackageFileName : "(NULL)") << " to "
           << (packageFileName ? packageFileName : "(NULL)") << std::endl);
       return 0;
     }
@@ -1200,7 +1193,7 @@ int cmCPackGenerator::Initialize(const std::string& name, cmMakefile* mf)
   // set the running generator name
   this->SetOption("CPACK_GENERATOR", this->Name.c_str());
   // Load the project specific config file
-  const char* config = this->GetOption("CPACK_PROJECT_CONFIG_FILE");
+  cmProp config = this->GetOption("CPACK_PROJECT_CONFIG_FILE");
   if (config) {
     mf->ReadListFile(config);
   }
@@ -1250,15 +1243,14 @@ bool cmCPackGenerator::IsSetToEmpty(const std::string& op) const
   return false;
 }
 
-const char* cmCPackGenerator::GetOption(const std::string& op) const
+cmProp cmCPackGenerator::GetOption(const std::string& op) const
 {
   cmProp ret = this->MakefileMap->GetDefinition(op);
   if (!ret) {
     cmCPackLogger(cmCPackLog::LOG_DEBUG,
                   "Warning, GetOption return NULL for: " << op << std::endl);
-    return nullptr;
   }
-  return ret->c_str();
+  return ret;
 }
 
 std::vector<std::string> cmCPackGenerator::GetOptions() const
@@ -1311,7 +1303,7 @@ const char* cmCPackGenerator::GetPackagingInstallPrefix()
                   << this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX") << "'"
                   << std::endl);
 
-  return this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX");
+  return this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX")->c_str();
 }
 
 std::string cmCPackGenerator::FindTemplate(const char* name)
@@ -1391,12 +1383,8 @@ int cmCPackGenerator::PrepareGroupingKind()
     method = ONE_PACKAGE_PER_GROUP;
   }
 
-  std::string groupingType;
-
   // Second way to specify grouping
-  if (nullptr != this->GetOption("CPACK_COMPONENTS_GROUPING")) {
-    groupingType = this->GetOption("CPACK_COMPONENTS_GROUPING");
-  }
+  std::string groupingType = *this->GetOption("CPACK_COMPONENTS_GROUPING");
 
   if (!groupingType.empty()) {
     cmCPackLogger(cmCPackLog::LOG_VERBOSE,
@@ -1477,18 +1465,18 @@ std::string cmCPackGenerator::GetComponentPackageFileName(
     if (isGroupName) {
       std::string groupDispVar = "CPACK_COMPONENT_GROUP_" +
         cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME";
-      const char* groupDispName = this->GetOption(groupDispVar);
+      cmProp groupDispName = this->GetOption(groupDispVar);
       if (groupDispName) {
-        suffix = "-" + std::string(groupDispName);
+        suffix = "-" + *groupDispName;
       }
     }
     /* the [single] component case */
     else {
       std::string dispVar = "CPACK_COMPONENT_" +
         cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME";
-      const char* dispName = this->GetOption(dispVar);
+      cmProp dispName = this->GetOption(dispVar);
       if (dispName) {
-        suffix = "-" + std::string(dispName);
+        suffix = "-" + *dispName;
       }
     }
   }
@@ -1531,9 +1519,9 @@ cmCPackInstallationType* cmCPackGenerator::GetInstallationType(
       "CPACK_INSTALL_TYPE_" + cmsys::SystemTools::UpperCase(name);
     installType->Name = name;
 
-    const char* displayName = this->GetOption(macroPrefix + "_DISPLAY_NAME");
+    cmProp displayName = this->GetOption(macroPrefix + "_DISPLAY_NAME");
     if (cmNonempty(displayName)) {
-      installType->DisplayName = displayName;
+      installType->DisplayName = *displayName;
     } else {
       installType->DisplayName = installType->Name;
     }
@@ -1553,9 +1541,9 @@ cmCPackComponent* cmCPackGenerator::GetComponent(
     std::string macroPrefix =
       "CPACK_COMPONENT_" + cmsys::SystemTools::UpperCase(name);
     component->Name = name;
-    const char* displayName = this->GetOption(macroPrefix + "_DISPLAY_NAME");
+    cmProp displayName = this->GetOption(macroPrefix + "_DISPLAY_NAME");
     if (cmNonempty(displayName)) {
-      component->DisplayName = displayName;
+      component->DisplayName = *displayName;
     } else {
       component->DisplayName = component->Name;
     }
@@ -1565,17 +1553,17 @@ cmCPackComponent* cmCPackGenerator::GetComponent(
     component->IsDownloaded = this->IsOn(macroPrefix + "_DOWNLOADED") ||
       cmIsOn(this->GetOption("CPACK_DOWNLOAD_ALL"));
 
-    const char* archiveFile = this->GetOption(macroPrefix + "_ARCHIVE_FILE");
+    cmProp archiveFile = this->GetOption(macroPrefix + "_ARCHIVE_FILE");
     if (cmNonempty(archiveFile)) {
-      component->ArchiveFile = archiveFile;
+      component->ArchiveFile = *archiveFile;
     }
 
-    const char* plist = this->GetOption(macroPrefix + "_PLIST");
+    cmProp plist = this->GetOption(macroPrefix + "_PLIST");
     if (cmNonempty(plist)) {
-      component->Plist = plist;
+      component->Plist = *plist;
     }
 
-    const char* groupName = this->GetOption(macroPrefix + "_GROUP");
+    cmProp groupName = this->GetOption(macroPrefix + "_GROUP");
     if (cmNonempty(groupName)) {
       component->Group = this->GetComponentGroup(projectName, groupName);
       component->Group->Components.push_back(component);
@@ -1583,13 +1571,13 @@ cmCPackComponent* cmCPackGenerator::GetComponent(
       component->Group = nullptr;
     }
 
-    const char* description = this->GetOption(macroPrefix + "_DESCRIPTION");
+    cmProp description = this->GetOption(macroPrefix + "_DESCRIPTION");
     if (cmNonempty(description)) {
-      component->Description = description;
+      component->Description = *description;
     }
 
     // Determine the installation types.
-    const char* installTypes = this->GetOption(macroPrefix + "_INSTALL_TYPES");
+    cmProp installTypes = this->GetOption(macroPrefix + "_INSTALL_TYPES");
     if (cmNonempty(installTypes)) {
       std::vector<std::string> installTypesVector =
         cmExpandedList(installTypes);
@@ -1600,7 +1588,7 @@ cmCPackComponent* cmCPackGenerator::GetComponent(
     }
 
     // Determine the component dependencies.
-    const char* depends = this->GetOption(macroPrefix + "_DEPENDS");
+    cmProp depends = this->GetOption(macroPrefix + "_DEPENDS");
     if (cmNonempty(depends)) {
       std::vector<std::string> dependsVector = cmExpandedList(depends);
       for (std::string const& depend : dependsVector) {
@@ -1624,21 +1612,20 @@ cmCPackComponentGroup* cmCPackGenerator::GetComponentGroup(
   if (!hasGroup) {
     // Define the group
     group->Name = name;
-    const char* displayName = this->GetOption(macroPrefix + "_DISPLAY_NAME");
+    cmProp displayName = this->GetOption(macroPrefix + "_DISPLAY_NAME");
     if (cmNonempty(displayName)) {
-      group->DisplayName = displayName;
+      group->DisplayName = *displayName;
     } else {
       group->DisplayName = group->Name;
     }
 
-    const char* description = this->GetOption(macroPrefix + "_DESCRIPTION");
+    cmProp description = this->GetOption(macroPrefix + "_DESCRIPTION");
     if (cmNonempty(description)) {
-      group->Description = description;
+      group->Description = *description;
     }
     group->IsBold = this->IsOn(macroPrefix + "_BOLD_TITLE");
     group->IsExpandedByDefault = this->IsOn(macroPrefix + "_EXPANDED");
-    const char* parentGroupName =
-      this->GetOption(macroPrefix + "_PARENT_GROUP");
+    cmProp parentGroupName = this->GetOption(macroPrefix + "_PARENT_GROUP");
     if (cmNonempty(parentGroupName)) {
       group->ParentGroup =
         this->GetComponentGroup(projectName, parentGroupName);

+ 2 - 1
Source/CPack/cmCPackGenerator.h

@@ -12,6 +12,7 @@
 #include "cm_sys_stat.h"
 
 #include "cmCPackComponentGroup.h"
+#include "cmProperty.h"
 #include "cmSystemTools.h"
 
 class cmCPackLog;
@@ -85,7 +86,7 @@ public:
   //! Set and get the options
   void SetOption(const std::string& op, const char* value);
   void SetOptionIfNotSet(const std::string& op, const char* value);
-  const char* GetOption(const std::string& op) const;
+  cmProp GetOption(const std::string& op) const;
   std::vector<std::string> GetOptions() const;
   bool IsSet(const std::string& name) const;
   bool IsOn(const std::string& name) const;

+ 13 - 13
Source/CPack/cmCPackNSISGenerator.cxx

@@ -19,6 +19,7 @@
 #include "cmCPackLog.h"
 #include "cmDuration.h"
 #include "cmGeneratedFileStream.h"
+#include "cmProperty.h"
 #include "cmStringAlgorithms.h"
 #include "cmSystemTools.h"
 
@@ -142,9 +143,9 @@ int cmCPackNSISGenerator::PackageFiles()
   }
   std::string installerHeaderImage;
   if (this->IsSet("CPACK_NSIS_MUI_HEADERIMAGE")) {
-    installerHeaderImage = this->GetOption("CPACK_NSIS_MUI_HEADERIMAGE");
+    installerHeaderImage = *this->GetOption("CPACK_NSIS_MUI_HEADERIMAGE");
   } else if (this->IsSet("CPACK_PACKAGE_ICON")) {
-    installerHeaderImage = this->GetOption("CPACK_PACKAGE_ICON");
+    installerHeaderImage = *this->GetOption("CPACK_PACKAGE_ICON");
   }
   if (!installerHeaderImage.empty()) {
     std::string installerIconCode = cmStrCat(
@@ -479,8 +480,8 @@ int cmCPackNSISGenerator::InitializeInternal()
   cmsys::RegularExpression versionRexCVS("v(.*)\\.cvs");
   if (!resS || retVal ||
       (!versionRex.find(output) && !versionRexCVS.find(output))) {
-    const char* topDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
-    std::string tmpFile = cmStrCat(topDir ? topDir : ".", "/NSISOutput.log");
+    cmProp topDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
+    std::string tmpFile = cmStrCat(topDir ? *topDir : ".", "/NSISOutput.log");
     cmGeneratedFileStream ofs(tmpFile);
     ofs << "# Run command: " << nsisCmd << std::endl
         << "# Output:" << std::endl
@@ -512,11 +513,11 @@ int cmCPackNSISGenerator::InitializeInternal()
   }
   this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", nsisPath.c_str());
   this->SetOptionIfNotSet("CPACK_NSIS_EXECUTABLES_DIRECTORY", "bin");
-  const char* cpackPackageExecutables =
+  cmProp cpackPackageExecutables =
     this->GetOption("CPACK_PACKAGE_EXECUTABLES");
-  const char* cpackPackageDeskTopLinks =
+  cmProp cpackPackageDeskTopLinks =
     this->GetOption("CPACK_CREATE_DESKTOP_LINKS");
-  const char* cpackNsisExecutablesDirectory =
+  cmProp cpackNsisExecutablesDirectory =
     this->GetOption("CPACK_NSIS_EXECUTABLES_DIRECTORY");
   std::vector<std::string> cpackPackageDesktopLinksVector;
   if (cpackPackageDeskTopLinks) {
@@ -589,7 +590,7 @@ int cmCPackNSISGenerator::InitializeInternal()
 void cmCPackNSISGenerator::CreateMenuLinks(std::ostream& str,
                                            std::ostream& deleteStr)
 {
-  const char* cpackMenuLinks = this->GetOption("CPACK_NSIS_MENU_LINKS");
+  cmProp cpackMenuLinks = this->GetOption("CPACK_NSIS_MENU_LINKS");
   if (!cpackMenuLinks) {
     return;
   }
@@ -728,11 +729,10 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
     }
 
     // Create the directory for the upload area
-    const char* userUploadDirectory =
-      this->GetOption("CPACK_UPLOAD_DIRECTORY");
+    cmProp userUploadDirectory = this->GetOption("CPACK_UPLOAD_DIRECTORY");
     std::string uploadDirectory;
     if (cmNonempty(userUploadDirectory)) {
-      uploadDirectory = userUploadDirectory;
+      uploadDirectory = *userUploadDirectory;
     } else {
       uploadDirectory =
         cmStrCat(this->GetOption("CPACK_PACKAGE_DIRECTORY"), "/CPackUploads");
@@ -968,9 +968,9 @@ std::string cmCPackNSISGenerator::CreateComponentGroupDescription(
 std::string cmCPackNSISGenerator::CustomComponentInstallDirectory(
   cm::string_view componentName)
 {
-  const char* outputDir = this->GetOption(
+  cmProp outputDir = this->GetOption(
     cmStrCat("CPACK_NSIS_", componentName, "_INSTALL_DIRECTORY"));
-  return outputDir ? outputDir : "$INSTDIR";
+  return outputDir ? *outputDir : "$INSTDIR";
 }
 
 std::string cmCPackNSISGenerator::TranslateNewlines(std::string str)

+ 3 - 2
Source/CPack/cmCPackNuGetGenerator.cxx

@@ -12,6 +12,7 @@
 
 #include "cmCPackComponentGroup.h"
 #include "cmCPackLog.h"
+#include "cmProperty.h"
 #include "cmStringAlgorithms.h"
 #include "cmSystemTools.h"
 
@@ -120,7 +121,7 @@ void cmCPackNuGetGenerator::SetupGroupComponentVariables(bool ignoreGroup)
 
 void cmCPackNuGetGenerator::AddGeneratedPackageNames()
 {
-  const char* const files_list = this->GetOption("GEN_CPACK_OUTPUT_FILES");
+  cmProp const files_list = this->GetOption("GEN_CPACK_OUTPUT_FILES");
   if (!files_list) {
     cmCPackLogger(
       cmCPackLog::LOG_ERROR,
@@ -129,7 +130,7 @@ void cmCPackNuGetGenerator::AddGeneratedPackageNames()
     return;
   }
   // add the generated packages to package file names list
-  std::string fileNames{ files_list };
+  const std::string& fileNames = *files_list;
   const char sep = ';';
   std::string::size_type pos1 = 0;
   std::string::size_type pos2 = fileNames.find(sep, pos1 + 1);

+ 6 - 5
Source/CPack/cmCPackOSXX11Generator.cxx

@@ -10,6 +10,7 @@
 #include "cmCPackLog.h"
 #include "cmDuration.h"
 #include "cmGeneratedFileStream.h"
+#include "cmProperty.h"
 #include "cmStringAlgorithms.h"
 #include "cmSystemTools.h"
 
@@ -22,7 +23,7 @@ int cmCPackOSXX11Generator::PackageFiles()
   // TODO: Use toplevel ?
   //       It is used! Is this an obsolete comment?
 
-  const char* cpackPackageExecutables =
+  cmProp cpackPackageExecutables =
     this->GetOption("CPACK_PACKAGE_EXECUTABLES");
   if (cpackPackageExecutables) {
     cmCPackLogger(cmCPackLog::LOG_DEBUG,
@@ -70,7 +71,7 @@ int cmCPackOSXX11Generator::PackageFiles()
   const char* scrDir = scriptDirectory.c_str();
   const char* contDir = contentsDirectory.c_str();
   const char* rsrcFile = resourceFileName.c_str();
-  const char* iconFile = this->GetOption("CPACK_PACKAGE_ICON");
+  cmProp iconFile = this->GetOption("CPACK_PACKAGE_ICON");
   if (iconFile) {
     std::string iconFileName = cmsys::SystemTools::GetFilenameName(iconFile);
     if (!cmSystemTools::FileExists(iconFile)) {
@@ -103,9 +104,9 @@ int cmCPackOSXX11Generator::PackageFiles()
                                    true) ||
       !this->CopyResourcePlistFile("OSXScriptLauncher.rsrc", dir, rsrcFile,
                                    true) ||
-      !this->CopyResourcePlistFile("OSXScriptLauncher", appdir,
-                                   this->GetOption("CPACK_PACKAGE_FILE_NAME"),
-                                   true)) {
+      !this->CopyResourcePlistFile(
+        "OSXScriptLauncher", appdir,
+        this->GetOption("CPACK_PACKAGE_FILE_NAME").GetCStr(), true)) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
                   "Problem copying the resource files" << std::endl);
     return 0;

+ 5 - 4
Source/CPack/cmCPackPKGGenerator.cxx

@@ -7,6 +7,7 @@
 #include "cmCPackComponentGroup.h"
 #include "cmCPackGenerator.h"
 #include "cmCPackLog.h"
+#include "cmProperty.h"
 #include "cmStringAlgorithms.h"
 #include "cmSystemTools.h"
 #include "cmXMLWriter.h"
@@ -56,7 +57,7 @@ void cmCPackPKGGenerator::CreateBackground(const char* themeName,
   std::string opt = (themeName == nullptr)
     ? cmStrCat("CPACK_", genName, "_BACKGROUND")
     : cmStrCat("CPACK_", genName, "_BACKGROUND_", paramSuffix);
-  const char* bgFileName = this->GetOption(opt);
+  cmProp bgFileName = this->GetOption(opt);
   if (bgFileName == nullptr) {
     return;
   }
@@ -78,7 +79,7 @@ void cmCPackPKGGenerator::CreateBackground(const char* themeName,
 
   xout.Attribute("file", bgFileName);
 
-  const char* param = this->GetOption(cmStrCat(opt, "_ALIGNMENT"));
+  cmProp param = this->GetOption(cmStrCat(opt, "_ALIGNMENT"));
   if (param != nullptr) {
     xout.Attribute("alignment", param);
   }
@@ -315,7 +316,7 @@ bool cmCPackPKGGenerator::CopyCreateResourceFile(const std::string& name,
 {
   std::string uname = cmSystemTools::UpperCase(name);
   std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname;
-  const char* inFileName = this->GetOption(cpackVar);
+  cmProp inFileName = this->GetOption(cpackVar);
   if (!inFileName) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
                   "CPack option: " << cpackVar.c_str()
@@ -351,7 +352,7 @@ bool cmCPackPKGGenerator::CopyCreateResourceFile(const std::string& name,
                   (name + ext).c_str());
 
   cmCPackLogger(cmCPackLog::LOG_VERBOSE,
-                "Configure file: " << (inFileName ? inFileName : "(NULL)")
+                "Configure file: " << (inFileName ? *inFileName : "(NULL)")
                                    << " to " << destFileName << std::endl);
   this->ConfigureFile(inFileName, destFileName);
   return true;

+ 12 - 11
Source/CPack/cmCPackPackageMakerGenerator.cxx

@@ -16,6 +16,7 @@
 #include "cmCPackLog.h"
 #include "cmDuration.h"
 #include "cmGeneratedFileStream.h"
+#include "cmProperty.h"
 #include "cmStringAlgorithms.h"
 #include "cmSystemTools.h"
 #include "cmXMLWriter.h"
@@ -79,9 +80,9 @@ int cmCPackPackageMakerGenerator::PackageFiles()
     resDir += "/en.lproj";
   }
 
-  const char* preflight = this->GetOption("CPACK_PREFLIGHT_SCRIPT");
-  const char* postflight = this->GetOption("CPACK_POSTFLIGHT_SCRIPT");
-  const char* postupgrade = this->GetOption("CPACK_POSTUPGRADE_SCRIPT");
+  cmProp preflight = this->GetOption("CPACK_PREFLIGHT_SCRIPT");
+  cmProp postflight = this->GetOption("CPACK_POSTFLIGHT_SCRIPT");
+  cmProp postupgrade = this->GetOption("CPACK_POSTUPGRADE_SCRIPT");
 
   if (this->Components.empty()) {
     // Create directory structure
@@ -167,10 +168,9 @@ int cmCPackPackageMakerGenerator::PackageFiles()
 
     // Create the directory where downloaded component packages will
     // be placed.
-    const char* userUploadDirectory =
-      this->GetOption("CPACK_UPLOAD_DIRECTORY");
+    cmProp userUploadDirectory = this->GetOption("CPACK_UPLOAD_DIRECTORY");
     std::string uploadDirectory;
-    if (userUploadDirectory && *userUploadDirectory) {
+    if (userUploadDirectory && !userUploadDirectory->empty()) {
       uploadDirectory = userUploadDirectory;
     } else {
       uploadDirectory =
@@ -352,8 +352,8 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
                      "/PackageMaker.app/Contents/MacOS");
 
   std::string pkgPath;
-  const char* inst_program = this->GetOption("CPACK_INSTALLER_PROGRAM");
-  if (inst_program && *inst_program) {
+  cmProp inst_program = this->GetOption("CPACK_INSTALLER_PROGRAM");
+  if (inst_program && !inst_program->empty()) {
     pkgPath = inst_program;
   } else {
     pkgPath = cmSystemTools::FindProgram("PackageMaker", paths, false);
@@ -427,11 +427,12 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
   // Determine the package compatibility version. If it wasn't
   // specified by the user, we define it based on which features the
   // user requested.
-  const char* packageCompat = this->GetOption("CPACK_OSX_PACKAGE_VERSION");
-  if (packageCompat && *packageCompat) {
+  cmProp packageCompat = this->GetOption("CPACK_OSX_PACKAGE_VERSION");
+  if (packageCompat && !packageCompat->empty()) {
     unsigned int majorVersion = 10;
     unsigned int minorVersion = 5;
-    int res = sscanf(packageCompat, "%u.%u", &majorVersion, &minorVersion);
+    int res =
+      sscanf(packageCompat->c_str(), "%u.%u", &majorVersion, &minorVersion);
     if (res == 2) {
       this->PackageCompatibilityVersion =
         getVersion(majorVersion, minorVersion);

+ 8 - 7
Source/CPack/cmCPackProductBuildGenerator.cxx

@@ -10,6 +10,7 @@
 #include "cmCPackLog.h"
 #include "cmDuration.h"
 #include "cmGeneratedFileStream.h"
+#include "cmProperty.h"
 #include "cmStringAlgorithms.h"
 #include "cmSystemTools.h"
 
@@ -87,11 +88,11 @@ int cmCPackProductBuildGenerator::PackageFiles()
   std::string version = this->GetOption("CPACK_PACKAGE_VERSION");
   std::string productbuild = this->GetOption("CPACK_COMMAND_PRODUCTBUILD");
   std::string identityName;
-  if (const char* n = this->GetOption("CPACK_PRODUCTBUILD_IDENTITY_NAME")) {
+  if (cmProp n = this->GetOption("CPACK_PRODUCTBUILD_IDENTITY_NAME")) {
     identityName = n;
   }
   std::string keychainPath;
-  if (const char* p = this->GetOption("CPACK_PRODUCTBUILD_KEYCHAIN_PATH")) {
+  if (cmProp p = this->GetOption("CPACK_PRODUCTBUILD_KEYCHAIN_PATH")) {
     keychainPath = p;
   }
 
@@ -173,8 +174,8 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage(
 
   const char* comp_name = component ? component->Name.c_str() : nullptr;
 
-  const char* preflight = this->GetComponentScript("PREFLIGHT", comp_name);
-  const char* postflight = this->GetComponentScript("POSTFLIGHT", comp_name);
+  cmProp preflight = this->GetComponentScript("PREFLIGHT", comp_name);
+  cmProp postflight = this->GetComponentScript("POSTFLIGHT", comp_name);
 
   std::string resDir = packageFileDir;
   if (component) {
@@ -213,11 +214,11 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage(
   std::string version = this->GetOption("CPACK_PACKAGE_VERSION");
   std::string pkgbuild = this->GetOption("CPACK_COMMAND_PKGBUILD");
   std::string identityName;
-  if (const char* n = this->GetOption("CPACK_PKGBUILD_IDENTITY_NAME")) {
+  if (cmProp n = this->GetOption("CPACK_PKGBUILD_IDENTITY_NAME")) {
     identityName = n;
   }
   std::string keychainPath;
-  if (const char* p = this->GetOption("CPACK_PKGBUILD_KEYCHAIN_PATH")) {
+  if (cmProp p = this->GetOption("CPACK_PKGBUILD_KEYCHAIN_PATH")) {
     keychainPath = p;
   }
 
@@ -239,7 +240,7 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage(
   return RunProductBuild(pkgCmd.str());
 }
 
-const char* cmCPackProductBuildGenerator::GetComponentScript(
+cmProp cmCPackProductBuildGenerator::GetComponentScript(
   const char* script, const char* component_name)
 {
   std::string scriptname = std::string("CPACK_") + script + "_";

+ 2 - 2
Source/CPack/cmCPackProductBuildGenerator.h

@@ -8,6 +8,7 @@
 
 #include "cmCPackGenerator.h"
 #include "cmCPackPKGGenerator.h"
+#include "cmProperty.h"
 
 class cmCPackComponent;
 
@@ -45,6 +46,5 @@ protected:
                                 const std::string& packageDir,
                                 const cmCPackComponent* component);
 
-  const char* GetComponentScript(const char* script,
-                                 const char* script_component);
+  cmProp GetComponentScript(const char* script, const char* script_component);
 };

+ 2 - 1
Source/CPack/cmCPackRPMGenerator.cxx

@@ -12,6 +12,7 @@
 #include "cmCPackComponentGroup.h"
 #include "cmCPackGenerator.h"
 #include "cmCPackLog.h"
+#include "cmProperty.h"
 #include "cmStringAlgorithms.h"
 #include "cmSystemTools.h"
 
@@ -103,7 +104,7 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
   this->packageFileNames.clear();
   std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
 
-  const char* mainComponent = this->GetOption("CPACK_RPM_MAIN_COMPONENT");
+  cmProp mainComponent = this->GetOption("CPACK_RPM_MAIN_COMPONENT");
 
   if (this->IsOn("CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE") &&
       !this->IsOn("CPACK_RPM_DEBUGINFO_PACKAGE")) {

+ 1 - 0
Source/CPack/cmCPackSTGZGenerator.cxx

@@ -14,6 +14,7 @@
 #include "cmArchiveWrite.h"
 #include "cmCPackGenerator.h"
 #include "cmCPackLog.h"
+#include "cmProperty.h"
 #include "cmSystemTools.h"
 
 cmCPackSTGZGenerator::cmCPackSTGZGenerator()