Ver Fonte

CPackIFW: Add some options

New options is: DEFAULT, VIRTUAL, FORCED_INSTALLATION,
DISPLAY_NAME, DESCRIPTION and RELEASE_DATE.

Options added for both cpack_ifw_configure_component and
cpack_ifw_configure_component_group command.
Konstantin Podsvirov há 9 anos atrás
pai
commit
88ecfd8ba1

+ 7 - 0
Help/release/dev/cpack-ifw-options.rst

@@ -0,0 +1,7 @@
+cpack-ifw-options
+-----------------
+
+* The :module:`CPackIFW` module :command:`cpack_ifw_configure_component` and
+  :command:`cpack_ifw_configure_component_group` commands gained a new
+  ``DEFAULT``, ``VIRTUAL``, ``FORCED_INSTALLATION``, ``DISPLAY_NAME``,
+  ``DESCRIPTION`` and ``RELEASE_DATE`` options to more specific configuration.

+ 68 - 6
Modules/CPackIFW.cmake

@@ -198,13 +198,18 @@
 #
 #   ::
 #
-#     cpack_ifw_configure_component(<compname> [COMMON] [ESSENTIAL]
+#     cpack_ifw_configure_component(<compname> [COMMON] [ESSENTIAL] [VIRTUAL]
+#                         [FORCED_INSTALLATION]
 #                         [NAME <name>]
+#                         [DISPLAY_NAME <display_name>]
+#                         [DESCRIPTION <description>]
 #                         [VERSION <version>]
+#                         [RELEASE_DATE <release_date>]
 #                         [SCRIPT <script>]
 #                         [PRIORITY <priority>]
 #                         [DEPENDS <com_id> ...]
 #                         [LICENSES <display_name> <file_path> ...]
+#                         [DEFAULT <value>]
 #                         [USER_INTERFACES <file_path> <file_path> ...])
 #
 #   This command should be called after :command:`cpack_add_component` command.
@@ -217,14 +222,35 @@
 #     if set, then the package manager stays disabled until that
 #     component is updated.
 #
+#   ``VIRTUAL``
+#     if set, then the component will be hidden from the installer.
+#     It is a equivalent of the ``HIDDEN`` option from the
+#     :command:`cpack_add_component` command.
+#
+#   ``FORCED_INSTALLATION``
+#     if set, then the component must always be installed.
+#     It is a equivalent of the ``REQUARED`` option from the
+#     :command:`cpack_add_component` command.
+#
 #   ``NAME``
 #     is used to create domain-like identification for this component.
 #     By default used origin component name.
 #
+#   ``DISPLAY_NAME``
+#     set to rewrite original name configured by
+#     :command:`cpack_add_component` command.
+#
+#   ``DESCRIPTION``
+#     set to rewrite original description configured by
+#     :command:`cpack_add_component` command.
+#
 #   ``VERSION``
 #     is version of component.
 #     By default used :variable:`CPACK_PACKAGE_VERSION`.
 #
+#   ``RELEASE_DATE``
+#     keep empty to auto generate.
+#
 #   ``SCRIPT``
 #     is a relative or absolute path to operations script
 #     for this component.
@@ -239,6 +265,12 @@
 #     pair of <display_name> and <file_path> of license text for this
 #     component. You can specify more then one license.
 #
+#   ``DEFAULT``
+#     Possible values are: TRUE, FALSE, and SCRIPT.
+#     Set to FALSE to disable the component in the installer or to SCRIPT
+#     to resolved during runtime (don't forget add the file of the script
+#     as a value of the ``SCRIPT`` option).
+#
 #   ``USER_INTERFACES``
 #     a list of <file_path> representing pages to load
 #
@@ -249,25 +281,48 @@
 #
 #   ::
 #
-#     cpack_ifw_configure_component_group(<groupname>
+#     cpack_ifw_configure_component_group(<groupname> [VIRTUAL]
+#                         [FORCED_INSTALLATION]
 #                         [NAME <name>]
+#                         [DISPLAY_NAME <display_name>]
+#                         [DESCRIPTION <description>]
 #                         [VERSION <version>]
+#                         [RELEASE_DATE <release_date>]
 #                         [SCRIPT <script>]
 #                         [PRIORITY <priority>]
 #                         [LICENSES <display_name> <file_path> ...]
+#                         [DEFAULT <value>]
 #                         [USER_INTERFACES <file_path> <file_path> ...])
 #
 #   This command should be called after :command:`cpack_add_component_group`
 #   command.
 #
+#   ``VIRTUAL``
+#     if set, then the group will be hidden from the installer.
+#     Note that setting this on a root component does not work.
+#
+#   ``FORCED_INSTALLATION``
+#     if set, then the group must always be installed.
+#
 #   ``NAME``
 #     is used to create domain-like identification for this component group.
 #     By default used origin component group name.
 #
+#   ``DISPLAY_NAME``
+#     set to rewrite original name configured by
+#     :command:`cpack_add_component_group` command.
+#
+#   ``DESCRIPTION``
+#     set to rewrite original description configured by
+#     :command:`cpack_add_component_group` command.
+#
 #   ``VERSION``
 #     is version of component group.
 #     By default used :variable:`CPACK_PACKAGE_VERSION`.
 #
+#   ``RELEASE_DATE``
+#     keep empty to auto generate.
+#
 #   ``SCRIPT``
 #     is a relative or absolute path to operations script
 #     for this component group.
@@ -279,6 +334,13 @@
 #     pair of <display_name> and <file_path> of license text for this
 #     component group. You can specify more then one license.
 #
+#   ``DEFAULT``
+#     Possible values are: TRUE, FALSE, and SCRIPT.
+#     Set to TRUE to preselect the group in the installer
+#     (this takes effect only on groups that have no visible child components)
+#     or to SCRIPT to resolved during runtime (don't forget add the file of
+#     the script as a value of the ``SCRIPT`` option).
+#
 #   ``USER_INTERFACES``
 #     a list of <file_path> representing pages to load
 #
@@ -625,8 +687,8 @@ macro(cpack_ifw_configure_component compname)
 
   string(TOUPPER ${compname} _CPACK_IFWCOMP_UNAME)
 
-  set(_IFW_OPT COMMON ESSENTIAL)
-  set(_IFW_ARGS NAME VERSION SCRIPT PRIORITY)
+  set(_IFW_OPT COMMON ESSENTIAL VIRTUAL FORCED_INSTALLATION)
+  set(_IFW_ARGS NAME DISPLAY_NAME DESCRIPTION VERSION RELEASE_DATE SCRIPT PRIORITY DEFAULT)
   set(_IFW_MULTI_ARGS DEPENDS LICENSES USER_INTERFACES)
   cmake_parse_arguments(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME} "${_IFW_OPT}" "${_IFW_ARGS}" "${_IFW_MULTI_ARGS}" ${ARGN})
 
@@ -665,8 +727,8 @@ macro(cpack_ifw_configure_component_group grpname)
 
   string(TOUPPER ${grpname} _CPACK_IFWGRP_UNAME)
 
-  set(_IFW_OPT)
-  set(_IFW_ARGS NAME VERSION SCRIPT PRIORITY)
+  set(_IFW_OPT VIRTUAL FORCED_INSTALLATION)
+  set(_IFW_ARGS NAME DISPLAY_NAME DESCRIPTION VERSION RELEASE_DATE SCRIPT PRIORITY DEFAULT)
   set(_IFW_MULTI_ARGS LICENSES USER_INTERFACES)
   cmake_parse_arguments(CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME} "${_IFW_OPT}" "${_IFW_ARGS}" "${_IFW_MULTI_ARGS}" ${ARGN})
 

+ 5 - 1
Source/CPack/IFW/cmCPackIFWInstaller.cxx

@@ -403,7 +403,11 @@ void cmCPackIFWInstaller::GeneratePackageFiles()
     // Check package group
     if (const char* option = GetOption("CPACK_IFW_PACKAGE_GROUP")) {
       package.ConfigureFromGroup(option);
-      package.ForcedInstallation = "true";
+      std::string forcedOption = "CPACK_IFW_COMPONENT_GROUP_" +
+        cmsys::SystemTools::UpperCase(option) + "_FORCED_INSTALLATION";
+      if (!GetOption(forcedOption)) {
+        package.ForcedInstallation = "true";
+      }
     } else {
       package.ConfigureFromOptions();
     }

+ 80 - 2
Source/CPack/IFW/cmCPackIFWPackage.cxx

@@ -109,6 +109,16 @@ bool cmCPackIFWPackage::IsOn(const std::string& op) const
   return Generator ? Generator->IsOn(op) : false;
 }
 
+bool cmCPackIFWPackage::IsSetToOff(const std::string& op) const
+{
+  return Generator ? Generator->IsSetToOff(op) : false;
+}
+
+bool cmCPackIFWPackage::IsSetToEmpty(const std::string& op) const
+{
+  return Generator ? Generator->IsSetToEmpty(op) : false;
+}
+
 bool cmCPackIFWPackage::IsVersionLess(const char* version)
 {
   return Generator ? Generator->IsVersionLess(version) : false;
@@ -286,7 +296,7 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component)
   // ForcedInstallation
   ForcedInstallation = component->IsRequired ? "true" : "false";
 
-  return 1;
+  return ConfigureFromPrefix(prefix);
 }
 
 int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group)
@@ -344,7 +354,7 @@ int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group)
     SortingPriority = option;
   }
 
-  return 1;
+  return ConfigureFromPrefix(prefix);
 }
 
 int cmCPackIFWPackage::ConfigureFromGroup(const std::string& groupName)
@@ -380,6 +390,74 @@ int cmCPackIFWPackage::ConfigureFromGroup(const std::string& groupName)
   return ConfigureFromGroup(&group);
 }
 
+// Common options for components and groups
+int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix)
+{
+  // Temporary variable for full option name
+  std::string option;
+
+  // Display name
+  option = prefix + "DISPLAY_NAME";
+  if (IsSetToEmpty(option)) {
+    DisplayName.clear();
+  } else if (const char* value = GetOption(option)) {
+    DisplayName = value;
+  }
+
+  // Description
+  option = prefix + "DESCRIPTION";
+  if (IsSetToEmpty(option)) {
+    Description.clear();
+  } else if (const char* value = GetOption(option)) {
+    Description = value;
+  }
+
+  // Release date
+  option = prefix + "RELEASE_DATE";
+  if (IsSetToEmpty(option)) {
+    ReleaseDate.clear();
+  } else if (const char* value = GetOption(option)) {
+    ReleaseDate = value;
+  }
+
+  // Visibility
+  option = prefix + "VIRTUAL";
+  if (IsSetToEmpty(option)) {
+    Virtual.clear();
+  } else if (IsOn(option)) {
+    Virtual = "true";
+  }
+
+  // Default selection
+  option = prefix + "DEFAULT";
+  if (IsSetToEmpty(option)) {
+    Default.clear();
+  } else if (const char* value = GetOption(option)) {
+    std::string lowerValue = cmsys::SystemTools::LowerCase(value);
+    if (lowerValue.compare("true") == 0) {
+      Default = "true";
+    } else if (lowerValue.compare("false") == 0) {
+      Default = "false";
+    } else if (lowerValue.compare("script") == 0) {
+      Default = "script";
+    } else {
+      Default = value;
+    }
+  }
+
+  // Forsed installation
+  option = prefix + "FORCED_INSTALLATION";
+  if (IsSetToEmpty(option)) {
+    ForcedInstallation.clear();
+  } else if (IsOn(option)) {
+    ForcedInstallation = "true";
+  } else if (IsSetToOff(option)) {
+    ForcedInstallation = "false";
+  }
+
+  return 1;
+}
+
 void cmCPackIFWPackage::GeneratePackageFile()
 {
   // Lazy directory initialization

+ 3 - 0
Source/CPack/IFW/cmCPackIFWPackage.h

@@ -112,6 +112,8 @@ public:
 
   const char* 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;
 
   bool IsVersionLess(const char* version);
   bool IsVersionGreater(const char* version);
@@ -125,6 +127,7 @@ public:
   int ConfigureFromComponent(cmCPackComponent* component);
   int ConfigureFromGroup(cmCPackComponentGroup* group);
   int ConfigureFromGroup(const std::string& groupName);
+  int ConfigureFromPrefix(const std::string& prefix);
 
   void GeneratePackageFile();
 

+ 18 - 0
Source/CPack/cmCPackGenerator.cxx

@@ -1074,6 +1074,24 @@ bool cmCPackGenerator::IsOn(const std::string& name) const
   return cmSystemTools::IsOn(GetOption(name));
 }
 
+bool cmCPackGenerator::IsSetToOff(const std::string& op) const
+{
+  const char* ret = this->MakefileMap->GetDefinition(op);
+  if (ret && *ret) {
+    return cmSystemTools::IsOff(ret);
+  }
+  return false;
+}
+
+bool cmCPackGenerator::IsSetToEmpty(const std::string& op) const
+{
+  const char* ret = this->MakefileMap->GetDefinition(op);
+  if (ret) {
+    return !*ret;
+  }
+  return false;
+}
+
 const char* cmCPackGenerator::GetOption(const std::string& op) const
 {
   const char* ret = this->MakefileMap->GetDefinition(op);

+ 2 - 0
Source/CPack/cmCPackGenerator.h

@@ -91,6 +91,8 @@ public:
   std::vector<std::string> GetOptions() const;
   bool IsSet(const std::string& name) const;
   bool IsOn(const std::string& name) const;
+  bool IsSetToOff(const std::string& op) const;
+  bool IsSetToEmpty(const std::string& op) const;
 
   //! Set the logger
   void SetLogger(cmCPackLog* log) { this->Logger = log; }