Browse Source

install: Add TYPE LIBEXEC for FILES and DIRECTORY

Signed-off-by: Chen Linxuan <[email protected]>
Chen Linxuan 1 year ago
parent
commit
39603a7e5c

+ 8 - 0
Help/command/install.rst

@@ -568,6 +568,7 @@ Signatures
   ``LOCALE``              ``${CMAKE_INSTALL_LOCALEDIR}``     ``<DATAROOT dir>/locale``
   ``LOCALE``              ``${CMAKE_INSTALL_LOCALEDIR}``     ``<DATAROOT dir>/locale``
   ``MAN``                 ``${CMAKE_INSTALL_MANDIR}``        ``<DATAROOT dir>/man``
   ``MAN``                 ``${CMAKE_INSTALL_MANDIR}``        ``<DATAROOT dir>/man``
   ``DOC``                 ``${CMAKE_INSTALL_DOCDIR}``        ``<DATAROOT dir>/doc``
   ``DOC``                 ``${CMAKE_INSTALL_DOCDIR}``        ``<DATAROOT dir>/doc``
+  ``LIBEXEC``             ``${CMAKE_INSTALL_LIBEXECDIR}``    ``libexec``
   ======================= ================================== =========================
   ======================= ================================== =========================
 
 
   Projects wishing to follow the common practice of installing headers into a
   Projects wishing to follow the common practice of installing headers into a
@@ -606,6 +607,9 @@ Signatures
     use "generator expressions" with the syntax ``$<...>``.  See the
     use "generator expressions" with the syntax ``$<...>``.  See the
     :manual:`cmake-generator-expressions(7)` manual for available expressions.
     :manual:`cmake-generator-expressions(7)` manual for available expressions.
 
 
+  .. versionadded:: 3.31
+    The ``TYPE`` argument now supports type ``LIBEXEC``.
+
 .. signature::
 .. signature::
   install(DIRECTORY <dir>... [...])
   install(DIRECTORY <dir>... [...])
 
 
@@ -720,6 +724,7 @@ Signatures
   ``LOCALE``              ``${CMAKE_INSTALL_LOCALEDIR}``     ``<DATAROOT dir>/locale``
   ``LOCALE``              ``${CMAKE_INSTALL_LOCALEDIR}``     ``<DATAROOT dir>/locale``
   ``MAN``                 ``${CMAKE_INSTALL_MANDIR}``        ``<DATAROOT dir>/man``
   ``MAN``                 ``${CMAKE_INSTALL_MANDIR}``        ``<DATAROOT dir>/man``
   ``DOC``                 ``${CMAKE_INSTALL_DOCDIR}``        ``<DATAROOT dir>/doc``
   ``DOC``                 ``${CMAKE_INSTALL_DOCDIR}``        ``<DATAROOT dir>/doc``
+  ``LIBEXEC``             ``${CMAKE_INSTALL_LIBEXECDIR}``    ``libexec``
   ======================= ================================== =========================
   ======================= ================================== =========================
 
 
   Note that some of the types' built-in defaults use the ``DATAROOT`` directory as
   Note that some of the types' built-in defaults use the ``DATAROOT`` directory as
@@ -743,6 +748,9 @@ Signatures
     The list of ``dirs...`` given to ``DIRECTORY`` may use
     The list of ``dirs...`` given to ``DIRECTORY`` may use
     "generator expressions" too.
     "generator expressions" too.
 
 
+  .. versionadded:: 3.31
+    The ``TYPE`` argument now supports type ``LIBEXEC``.
+
 .. signature::
 .. signature::
   install(SCRIPT <file> [...])
   install(SCRIPT <file> [...])
   install(CODE <code> [...])
   install(CODE <code> [...])

+ 5 - 0
Help/release/dev/install-type-libexec.rst

@@ -0,0 +1,5 @@
+install-type-libexec
+--------------------
+
+* The :command:`install(FILES)` and :command:`install(DIRECTORY)` commands'
+  ``TYPE`` argument gained support for a ``LIBEXEC`` type.

+ 12 - 1
Source/cmInstallCommand.cxx

@@ -136,6 +136,8 @@ public:
     const cmInstallCommandArguments* args) const;
     const cmInstallCommandArguments* args) const;
   std::string GetManDestination(const cmInstallCommandArguments* args) const;
   std::string GetManDestination(const cmInstallCommandArguments* args) const;
   std::string GetDocDestination(const cmInstallCommandArguments* args) const;
   std::string GetDocDestination(const cmInstallCommandArguments* args) const;
+  std::string GetProgramExecutablesDestination(
+    const cmInstallCommandArguments* args) const;
   std::string GetDestinationForType(const cmInstallCommandArguments* args,
   std::string GetDestinationForType(const cmInstallCommandArguments* args,
                                     const std::string& type) const;
                                     const std::string& type) const;
 
 
@@ -291,7 +293,7 @@ void AddInstallRuntimeDependenciesGenerator(
 std::set<std::string> const allowedTypes{
 std::set<std::string> const allowedTypes{
   "BIN",         "SBIN",       "LIB",      "INCLUDE", "SYSCONF",
   "BIN",         "SBIN",       "LIB",      "INCLUDE", "SYSCONF",
   "SHAREDSTATE", "LOCALSTATE", "RUNSTATE", "DATA",    "INFO",
   "SHAREDSTATE", "LOCALSTATE", "RUNSTATE", "DATA",    "INFO",
-  "LOCALE",      "MAN",        "DOC",
+  "LOCALE",      "MAN",        "DOC",      "LIBEXEC",
 };
 };
 
 
 template <typename T>
 template <typename T>
@@ -2591,6 +2593,12 @@ std::string Helper::GetDocDestination(
                               this->GetDataRootDestination(nullptr) + "/doc");
                               this->GetDataRootDestination(nullptr) + "/doc");
 }
 }
 
 
+std::string Helper::GetProgramExecutablesDestination(
+  const cmInstallCommandArguments* args) const
+{
+  return this->GetDestination(args, "CMAKE_INSTALL_LIBEXECDIR", "libexec");
+}
+
 std::string Helper::GetDestinationForType(
 std::string Helper::GetDestinationForType(
   const cmInstallCommandArguments* args, const std::string& type) const
   const cmInstallCommandArguments* args, const std::string& type) const
 {
 {
@@ -2636,6 +2644,9 @@ std::string Helper::GetDestinationForType(
   if (type == "DOC") {
   if (type == "DOC") {
     return this->GetDocDestination(nullptr);
     return this->GetDocDestination(nullptr);
   }
   }
+  if (type == "LIBEXEC") {
+    return this->GetProgramExecutablesDestination(nullptr);
+  }
   return "";
   return "";
 }
 }
 
 

+ 3 - 0
Tests/RunCMake/install/DIRECTORY-TYPE-all-check.cmake

@@ -14,6 +14,9 @@ set(_check_files
   [[lib]]
   [[lib]]
   [[lib/dir]]
   [[lib/dir]]
   [[lib/dir/empty\.txt]]
   [[lib/dir/empty\.txt]]
+  [[libexec]]
+  [[libexec/dir]]
+  [[libexec/dir/empty\.txt]]
   [[sbin]]
   [[sbin]]
   [[sbin/dir]]
   [[sbin/dir]]
   [[sbin/dir/empty\.txt]]
   [[sbin/dir/empty\.txt]]

+ 1 - 0
Tests/RunCMake/install/DIRECTORY-TYPE.cmake

@@ -11,3 +11,4 @@ install(DIRECTORY dir TYPE INFO)
 install(DIRECTORY dir TYPE LOCALE)
 install(DIRECTORY dir TYPE LOCALE)
 install(DIRECTORY dir TYPE MAN)
 install(DIRECTORY dir TYPE MAN)
 install(DIRECTORY dir TYPE DOC)
 install(DIRECTORY dir TYPE DOC)
+install(DIRECTORY dir TYPE LIBEXEC)

+ 2 - 0
Tests/RunCMake/install/FILES-TYPE-all-check.cmake

@@ -9,6 +9,8 @@ set(_check_files
   [[include/main\.c]]
   [[include/main\.c]]
   [[lib]]
   [[lib]]
   [[lib/main\.c]]
   [[lib/main\.c]]
+  [[libexec]]
+  [[libexec/main\.c]]
   [[sbin]]
   [[sbin]]
   [[sbin/main\.c]]
   [[sbin/main\.c]]
   [[share]]
   [[share]]

+ 1 - 0
Tests/RunCMake/install/FILES-TYPE.cmake

@@ -11,3 +11,4 @@ install(FILES main.c TYPE INFO)
 install(FILES main.c TYPE LOCALE)
 install(FILES main.c TYPE LOCALE)
 install(FILES main.c TYPE MAN)
 install(FILES main.c TYPE MAN)
 install(FILES main.c TYPE DOC)
 install(FILES main.c TYPE DOC)
+install(FILES main.c TYPE LIBEXEC)