GNUInstallDirs.cmake 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file LICENSE.rst or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. GNUInstallDirs
  5. --------------
  6. Define GNU standard installation directories
  7. Provides install directory variables as defined by the
  8. `GNU Coding Standards`_.
  9. .. _`GNU Coding Standards`: https://www.gnu.org/prep/standards/html_node/Directory-Variables.html
  10. Result Variables
  11. ^^^^^^^^^^^^^^^^
  12. Inclusion of this module defines the following variables:
  13. ``CMAKE_INSTALL_<dir>``
  14. Destination for files of a given type. This value may be passed to
  15. the ``DESTINATION`` options of :command:`install` commands for the
  16. corresponding file type. It should be a path relative to the installation
  17. prefix so that it can be converted to an absolute path in a relocatable way.
  18. While absolute paths are allowed, they are not recommended as they
  19. do not work with the ``cmake --install`` command's
  20. :option:`--prefix <cmake--install --prefix>` option, or with the
  21. :manual:`cpack <cpack(1)>` installer generators. In particular, there is no
  22. need to make paths absolute by prepending :variable:`CMAKE_INSTALL_PREFIX`;
  23. this prefix is used by default if the DESTINATION is a relative path.
  24. ``CMAKE_INSTALL_FULL_<dir>``
  25. The absolute path generated from the corresponding ``CMAKE_INSTALL_<dir>``
  26. value. If the value is not already an absolute path, an absolute path
  27. is constructed typically by prepending the value of the
  28. :variable:`CMAKE_INSTALL_PREFIX` variable. However, there are some
  29. `special cases`_ as documented below.
  30. These variables shouldn't be used in :command:`install` commands
  31. as they do not work with the ``cmake --install`` command's
  32. :option:`--prefix <cmake--install --prefix>` option, or with the
  33. :manual:`cpack <cpack(1)>` installer generators.
  34. where ``<dir>`` is one of:
  35. ``BINDIR``
  36. user executables (``bin``)
  37. ``SBINDIR``
  38. system admin executables (``sbin``)
  39. ``LIBEXECDIR``
  40. program executables (``libexec``)
  41. ``SYSCONFDIR``
  42. read-only single-machine data (``etc``)
  43. ``SHAREDSTATEDIR``
  44. modifiable architecture-independent data (``com``)
  45. ``LOCALSTATEDIR``
  46. modifiable single-machine data (``var``)
  47. ``RUNSTATEDIR``
  48. .. versionadded:: 3.9
  49. run-time variable data (``LOCALSTATEDIR/run``)
  50. ``LIBDIR``
  51. object code libraries (``lib`` or ``lib64``)
  52. On Debian, this may be ``lib/<multiarch-tuple>`` when
  53. :variable:`CMAKE_INSTALL_PREFIX` is ``/usr``.
  54. ``INCLUDEDIR``
  55. C header files (``include``)
  56. ``OLDINCLUDEDIR``
  57. C header files for non-gcc (``/usr/include``)
  58. ``DATAROOTDIR``
  59. read-only architecture-independent data root (``share``)
  60. ``DATADIR``
  61. read-only architecture-independent data (``DATAROOTDIR``)
  62. ``INFODIR``
  63. info documentation (``DATAROOTDIR/info``)
  64. ``LOCALEDIR``
  65. locale-dependent data (``DATAROOTDIR/locale``)
  66. ``MANDIR``
  67. man documentation (``DATAROOTDIR/man``)
  68. ``DOCDIR``
  69. documentation root (``DATAROOTDIR/doc/PROJECT_NAME``)
  70. If the includer does not define a value the above-shown default will be
  71. used and the value will appear in the cache for editing by the user.
  72. Special Cases
  73. ^^^^^^^^^^^^^
  74. .. versionadded:: 3.4
  75. The following values of :variable:`CMAKE_INSTALL_PREFIX` are special:
  76. ``/``
  77. For ``<dir>`` other than the ``SYSCONFDIR``, ``LOCALSTATEDIR`` and
  78. ``RUNSTATEDIR``, the value of ``CMAKE_INSTALL_<dir>`` is prefixed
  79. with ``usr/`` if it is not user-specified as an absolute path.
  80. For example, the ``INCLUDEDIR`` value ``include`` becomes ``usr/include``.
  81. This is required by the `GNU Coding Standards`_, which state:
  82. When building the complete GNU system, the prefix will be empty
  83. and ``/usr`` will be a symbolic link to ``/``.
  84. ``/usr``
  85. For ``<dir>`` equal to ``SYSCONFDIR``, ``LOCALSTATEDIR`` or
  86. ``RUNSTATEDIR``, the ``CMAKE_INSTALL_FULL_<dir>`` is computed by
  87. prepending just ``/`` to the value of ``CMAKE_INSTALL_<dir>``
  88. if it is not user-specified as an absolute path.
  89. For example, the ``SYSCONFDIR`` value ``etc`` becomes ``/etc``.
  90. This is required by the `GNU Coding Standards`_.
  91. ``/opt/...``
  92. For ``<dir>`` equal to ``SYSCONFDIR``, ``LOCALSTATEDIR`` or
  93. ``RUNSTATEDIR``, the ``CMAKE_INSTALL_FULL_<dir>`` is computed by
  94. *appending* the prefix to the value of ``CMAKE_INSTALL_<dir>``
  95. if it is not user-specified as an absolute path.
  96. For example, the ``SYSCONFDIR`` value ``etc`` becomes ``/etc/opt/...``.
  97. This is defined by the `Filesystem Hierarchy Standard`_.
  98. This behavior does not apply to paths under ``/opt/homebrew/...``.
  99. .. _`Filesystem Hierarchy Standard`: https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html
  100. Macros
  101. ^^^^^^
  102. .. command:: GNUInstallDirs_get_absolute_install_dir
  103. .. code-block:: cmake
  104. GNUInstallDirs_get_absolute_install_dir(absvar var dirname)
  105. .. versionadded:: 3.7
  106. Set the given variable ``absvar`` to the absolute path contained
  107. within the variable ``var``. This is to allow the computation of an
  108. absolute path, accounting for all the special cases documented
  109. above. While this macro is used to compute the various
  110. ``CMAKE_INSTALL_FULL_<dir>`` variables, it is exposed publicly to
  111. allow users who create additional path variables to also compute
  112. absolute paths where necessary, using the same logic. ``dirname`` is
  113. the directory name to get, e.g. ``BINDIR``.
  114. .. versionchanged:: 3.20
  115. Added the ``<dirname>`` parameter. Previous versions of CMake passed
  116. this value through the variable ``${dir}``.
  117. #]=======================================================================]
  118. cmake_policy(SET CMP0140 NEW)
  119. # Convert a cache variable to PATH type
  120. function(_GNUInstallDirs_cache_convert_to_path var description)
  121. get_property(cache_type CACHE ${var} PROPERTY TYPE)
  122. if(cache_type STREQUAL "UNINITIALIZED")
  123. file(TO_CMAKE_PATH "${${var}}" cmakepath)
  124. set_property(CACHE ${var} PROPERTY TYPE PATH)
  125. set_property(CACHE ${var} PROPERTY VALUE "${cmakepath}")
  126. set_property(CACHE ${var} PROPERTY HELPSTRING "${description}")
  127. endif()
  128. endfunction()
  129. # Create a cache variable with default for a path.
  130. function(_GNUInstallDirs_cache_path var description)
  131. set(cmake_install_var "CMAKE_INSTALL_${var}")
  132. set(default "${_GNUInstallDirs_${var}_DEFAULT}")
  133. set(full_description "${description} (${default})")
  134. if(NOT DEFINED ${cmake_install_var})
  135. set(${cmake_install_var} "${default}" CACHE PATH "${full_description}")
  136. endif()
  137. _GNUInstallDirs_cache_convert_to_path("${cmake_install_var}" "${full_description}")
  138. endfunction()
  139. # Create a cache variable with not default for a path, with a fallback
  140. # when unset; used for entries slaved to other entries such as
  141. # DATAROOTDIR.
  142. function(_GNUInstallDirs_cache_path_fallback var description)
  143. set(cmake_install_var "CMAKE_INSTALL_${var}")
  144. set(default "${_GNUInstallDirs_${var}_DEFAULT}")
  145. if(NOT ${cmake_install_var})
  146. set(${cmake_install_var} "" CACHE PATH "${description}")
  147. set(${cmake_install_var} "${default}")
  148. endif()
  149. _GNUInstallDirs_cache_convert_to_path("${cmake_install_var}" "${description}")
  150. return(PROPAGATE ${cmake_install_var})
  151. endfunction()
  152. # Installation directories
  153. #
  154. # Set the standard default values before any special handling
  155. set(_GNUInstallDirs_BINDIR_DEFAULT "bin")
  156. set(_GNUInstallDirs_SBINDIR_DEFAULT "sbin")
  157. set(_GNUInstallDirs_LIBEXECDIR_DEFAULT "libexec")
  158. set(_GNUInstallDirs_SYSCONFDIR_DEFAULT "etc")
  159. set(_GNUInstallDirs_SHAREDSTATEDIR_DEFAULT "com")
  160. set(_GNUInstallDirs_LOCALSTATEDIR_DEFAULT "var")
  161. set(_GNUInstallDirs_LIBDIR_DEFAULT "lib")
  162. set(_GNUInstallDirs_INCLUDEDIR_DEFAULT "include")
  163. set(_GNUInstallDirs_OLDINCLUDEDIR_DEFAULT "/usr/include")
  164. set(_GNUInstallDirs_DATAROOTDIR_DEFAULT "share")
  165. # We check if the variable was manually set and not cached, in order to
  166. # allow projects to set the values as normal variables before including
  167. # GNUInstallDirs to avoid having the entries cached or user-editable. It
  168. # replaces the "if(NOT DEFINED CMAKE_INSTALL_XXX)" checks in all the
  169. # other cases.
  170. # If CMAKE_INSTALL_LIBDIR is defined, if _libdir_set is false, then the
  171. # variable is a normal one, otherwise it is a cache one.
  172. get_property(_libdir_set CACHE CMAKE_INSTALL_LIBDIR PROPERTY TYPE SET)
  173. if(NOT DEFINED CMAKE_INSTALL_LIBDIR OR (_libdir_set
  174. AND DEFINED _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX
  175. AND NOT "${_GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX}" STREQUAL "${CMAKE_INSTALL_PREFIX}"))
  176. # If CMAKE_INSTALL_LIBDIR is not defined, it is always executed.
  177. # Otherwise:
  178. # * if _libdir_set is false it is not executed (meaning that it is
  179. # not a cache variable)
  180. # * if _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX is not defined it is
  181. # not executed
  182. # * if _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX and
  183. # CMAKE_INSTALL_PREFIX are the same string it is not executed.
  184. # _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX is updated after the
  185. # execution, of this part of code, therefore at the next inclusion
  186. # of the file, CMAKE_INSTALL_LIBDIR is defined, and the 2 strings
  187. # are equal, meaning that the if is not executed the code the
  188. # second time.
  189. set(_LIBDIR_DEFAULT "lib")
  190. # Override this default 'lib' with 'lib64' iff:
  191. # - we are on Linux system but NOT cross-compiling
  192. # - we are NOT on debian
  193. # - we are NOT building for conda
  194. # - we are on a 64 bits system
  195. # reason is: amd64 ABI: https://github.com/hjl-tools/x86-psABI/wiki/X86-psABI
  196. # For Debian with multiarch, use 'lib/${CMAKE_LIBRARY_ARCHITECTURE}' if
  197. # CMAKE_LIBRARY_ARCHITECTURE is set (which contains e.g. "i386-linux-gnu"
  198. # and CMAKE_INSTALL_PREFIX is "/usr"
  199. # See http://wiki.debian.org/Multiarch
  200. if(DEFINED _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX)
  201. set(__LAST_LIBDIR_DEFAULT "lib")
  202. # __LAST_LIBDIR_DEFAULT is the default value that we compute from
  203. # _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX, not a cache entry for
  204. # the value that was last used as the default.
  205. # This value is used to figure out whether the user changed the
  206. # CMAKE_INSTALL_LIBDIR value manually, or if the value was the
  207. # default one. When CMAKE_INSTALL_PREFIX changes, the value is
  208. # updated to the new default, unless the user explicitly changed it.
  209. endif()
  210. if (NOT DEFINED CMAKE_SYSTEM_NAME OR NOT DEFINED CMAKE_SIZEOF_VOID_P)
  211. message(AUTHOR_WARNING
  212. "Unable to determine default CMAKE_INSTALL_LIBDIR directory because no target architecture is known. "
  213. "Please enable at least one language before including GNUInstallDirs.")
  214. endif()
  215. if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|GNU)$"
  216. AND NOT CMAKE_CROSSCOMPILING)
  217. unset(__system_type_for_install)
  218. if(DEFINED ENV{CONDA_BUILD} AND DEFINED ENV{PREFIX})
  219. set(conda_prefix "$ENV{PREFIX}")
  220. cmake_path(ABSOLUTE_PATH conda_prefix NORMALIZE)
  221. if("${CMAKE_INSTALL_PREFIX}" STREQUAL conda_prefix)
  222. set(__system_type_for_install "conda")
  223. endif()
  224. elseif(DEFINED ENV{CONDA_PREFIX})
  225. set(conda_prefix "$ENV{CONDA_PREFIX}")
  226. cmake_path(ABSOLUTE_PATH conda_prefix NORMALIZE)
  227. if("${CMAKE_INSTALL_PREFIX}" STREQUAL conda_prefix AND
  228. NOT ("${CMAKE_INSTALL_PREFIX}" MATCHES "^/usr/?$" OR
  229. "${CMAKE_INSTALL_PREFIX}" MATCHES "^/usr/local/?$"))
  230. set(__system_type_for_install "conda")
  231. endif()
  232. endif()
  233. if(NOT __system_type_for_install)
  234. if (EXISTS "/etc/alpine-release")
  235. set(__system_type_for_install "alpine")
  236. elseif (EXISTS "/etc/arch-release")
  237. set(__system_type_for_install "arch linux")
  238. elseif (EXISTS "/etc/debian_version")
  239. set(__system_type_for_install "debian")
  240. endif()
  241. endif()
  242. if(__system_type_for_install STREQUAL "debian")
  243. if(CMAKE_LIBRARY_ARCHITECTURE)
  244. if("${CMAKE_INSTALL_PREFIX}" MATCHES "^/usr/?$")
  245. set(_LIBDIR_DEFAULT "lib/${CMAKE_LIBRARY_ARCHITECTURE}")
  246. endif()
  247. if(DEFINED _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX
  248. AND "${_GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX}" MATCHES "^/usr/?$")
  249. set(__LAST_LIBDIR_DEFAULT "lib/${CMAKE_LIBRARY_ARCHITECTURE}")
  250. endif()
  251. endif()
  252. elseif(NOT DEFINED __system_type_for_install)
  253. # not debian, alpine, arch, or conda so rely on CMAKE_SIZEOF_VOID_P:
  254. if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
  255. set(_LIBDIR_DEFAULT "lib64")
  256. if(DEFINED _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX)
  257. set(__LAST_LIBDIR_DEFAULT "lib64")
  258. endif()
  259. endif()
  260. endif()
  261. endif()
  262. unset(__system_type_for_install)
  263. if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
  264. set(CMAKE_INSTALL_LIBDIR "${_LIBDIR_DEFAULT}" CACHE PATH "Object code libraries (${_LIBDIR_DEFAULT})")
  265. elseif(DEFINED __LAST_LIBDIR_DEFAULT
  266. AND "${__LAST_LIBDIR_DEFAULT}" STREQUAL "${CMAKE_INSTALL_LIBDIR}")
  267. set_property(CACHE CMAKE_INSTALL_LIBDIR PROPERTY VALUE "${_LIBDIR_DEFAULT}")
  268. endif()
  269. endif()
  270. _GNUInstallDirs_cache_convert_to_path(CMAKE_INSTALL_LIBDIR "Object code libraries (lib)")
  271. # Save for next run
  272. set(_GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE INTERNAL "CMAKE_INSTALL_PREFIX during last run")
  273. unset(_libdir_set)
  274. unset(__LAST_LIBDIR_DEFAULT)
  275. _GNUInstallDirs_cache_path(BINDIR
  276. "User executables")
  277. _GNUInstallDirs_cache_path(SBINDIR
  278. "System admin executables")
  279. _GNUInstallDirs_cache_path(LIBEXECDIR
  280. "Program executables")
  281. _GNUInstallDirs_cache_path(SYSCONFDIR
  282. "Read-only single-machine data")
  283. _GNUInstallDirs_cache_path(SHAREDSTATEDIR
  284. "Modifiable architecture-independent data")
  285. _GNUInstallDirs_cache_path(LOCALSTATEDIR
  286. "Modifiable single-machine data")
  287. _GNUInstallDirs_cache_path(INCLUDEDIR
  288. "C header files")
  289. _GNUInstallDirs_cache_path(OLDINCLUDEDIR
  290. "C header files for non-gcc")
  291. _GNUInstallDirs_cache_path(DATAROOTDIR
  292. "Read-only architecture-independent data root")
  293. #-----------------------------------------------------------------------------
  294. # Values whose defaults are relative to DATAROOTDIR. Store empty values in
  295. # the cache and store the defaults in local variables if the cache values are
  296. # not set explicitly. This auto-updates the defaults as DATAROOTDIR changes.
  297. if(CMAKE_SYSTEM_NAME MATCHES "^(([^kF].*)?BSD|DragonFly)$")
  298. set(_GNUInstallDirs_INFODIR_DEFAULT "info")
  299. _GNUInstallDirs_cache_path(INFODIR
  300. "Info documentation")
  301. else()
  302. set(_GNUInstallDirs_INFODIR_DEFAULT "${CMAKE_INSTALL_DATAROOTDIR}/info")
  303. _GNUInstallDirs_cache_path_fallback(INFODIR
  304. "Info documentation (DATAROOTDIR/info)")
  305. endif()
  306. if(CMAKE_SYSTEM_NAME MATCHES "^(([^k].*)?BSD|DragonFly)$" AND NOT CMAKE_SYSTEM_NAME MATCHES "^(FreeBSD)$")
  307. set(_GNUInstallDirs_MANDIR_DEFAULT "man")
  308. _GNUInstallDirs_cache_path(MANDIR
  309. "Man documentation")
  310. else()
  311. set(_GNUInstallDirs_MANDIR_DEFAULT "${CMAKE_INSTALL_DATAROOTDIR}/man")
  312. _GNUInstallDirs_cache_path_fallback(MANDIR
  313. "Man documentation (DATAROOTDIR/man)")
  314. endif()
  315. set(_GNUInstallDirs_DATADIR_DEFAULT "${CMAKE_INSTALL_DATAROOTDIR}")
  316. set(_GNUInstallDirs_LOCALEDIR_DEFAULT "${CMAKE_INSTALL_DATAROOTDIR}/locale")
  317. set(_GNUInstallDirs_DOCDIR_DEFAULT "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}")
  318. set(_GNUInstallDirs_RUNSTATEDIR_DEFAULT "${CMAKE_INSTALL_LOCALSTATEDIR}/run")
  319. _GNUInstallDirs_cache_path_fallback(DATADIR
  320. "Read-only architecture-independent data (DATAROOTDIR)")
  321. _GNUInstallDirs_cache_path_fallback(LOCALEDIR
  322. "Locale-dependent data (DATAROOTDIR/locale)")
  323. _GNUInstallDirs_cache_path_fallback(DOCDIR
  324. "Documentation root (DATAROOTDIR/doc/PROJECT_NAME)")
  325. _GNUInstallDirs_cache_path_fallback(RUNSTATEDIR
  326. "Run-time variable data (LOCALSTATEDIR/run)")
  327. # Unset all the defaults used
  328. foreach(dir IN ITEMS
  329. BINDIR
  330. SBINDIR
  331. LIBEXECDIR
  332. SYSCONFDIR
  333. SHAREDSTATEDIR
  334. LOCALSTATEDIR
  335. LIBDIR
  336. INCLUDEDIR
  337. OLDINCLUDEDIR
  338. DATAROOTDIR
  339. DATADIR
  340. INFODIR
  341. MANDIR
  342. LOCALEDIR
  343. DOCDIR
  344. RUNSTATEDIR
  345. )
  346. unset(_GNUInstallDirs_${dir}_DEFAULT)
  347. endforeach()
  348. #-----------------------------------------------------------------------------
  349. mark_as_advanced(
  350. CMAKE_INSTALL_BINDIR
  351. CMAKE_INSTALL_SBINDIR
  352. CMAKE_INSTALL_LIBEXECDIR
  353. CMAKE_INSTALL_SYSCONFDIR
  354. CMAKE_INSTALL_SHAREDSTATEDIR
  355. CMAKE_INSTALL_LOCALSTATEDIR
  356. CMAKE_INSTALL_RUNSTATEDIR
  357. CMAKE_INSTALL_LIBDIR
  358. CMAKE_INSTALL_INCLUDEDIR
  359. CMAKE_INSTALL_OLDINCLUDEDIR
  360. CMAKE_INSTALL_DATAROOTDIR
  361. CMAKE_INSTALL_DATADIR
  362. CMAKE_INSTALL_INFODIR
  363. CMAKE_INSTALL_LOCALEDIR
  364. CMAKE_INSTALL_MANDIR
  365. CMAKE_INSTALL_DOCDIR
  366. )
  367. macro(GNUInstallDirs_get_absolute_install_dir absvar var)
  368. set(GGAID_extra_args ${ARGN})
  369. list(LENGTH GGAID_extra_args GGAID_extra_arg_count)
  370. if(GGAID_extra_arg_count GREATER "0")
  371. list(GET GGAID_extra_args 0 GGAID_dir)
  372. else()
  373. # Historical behavior: use ${dir} from caller's scope
  374. set(GGAID_dir "${dir}")
  375. message(AUTHOR_WARNING
  376. "GNUInstallDirs_get_absolute_install_dir called without third argument. "
  377. "Using \${dir} from the caller's scope for compatibility with CMake 3.19 and below.")
  378. endif()
  379. if(NOT IS_ABSOLUTE "${${var}}")
  380. # Handle special cases:
  381. # - CMAKE_INSTALL_PREFIX == /
  382. # - CMAKE_INSTALL_PREFIX == /usr
  383. # - CMAKE_INSTALL_PREFIX == /opt/...
  384. if("${CMAKE_INSTALL_PREFIX}" STREQUAL "/")
  385. if("${GGAID_dir}" STREQUAL "SYSCONFDIR" OR "${GGAID_dir}" STREQUAL "LOCALSTATEDIR" OR "${GGAID_dir}" STREQUAL "RUNSTATEDIR")
  386. set(${absvar} "/${${var}}")
  387. else()
  388. if (NOT "${${var}}" MATCHES "^usr/")
  389. set(${var} "usr/${${var}}")
  390. endif()
  391. set(${absvar} "/${${var}}")
  392. endif()
  393. elseif("${CMAKE_INSTALL_PREFIX}" MATCHES "^/usr/?$")
  394. if("${GGAID_dir}" STREQUAL "SYSCONFDIR" OR "${GGAID_dir}" STREQUAL "LOCALSTATEDIR" OR "${GGAID_dir}" STREQUAL "RUNSTATEDIR")
  395. set(${absvar} "/${${var}}")
  396. else()
  397. set(${absvar} "${CMAKE_INSTALL_PREFIX}/${${var}}")
  398. endif()
  399. elseif("${CMAKE_INSTALL_PREFIX}" MATCHES "^/opt/" AND NOT "${CMAKE_INSTALL_PREFIX}" MATCHES "^/opt/homebrew/")
  400. if("${GGAID_dir}" STREQUAL "SYSCONFDIR" OR "${GGAID_dir}" STREQUAL "LOCALSTATEDIR" OR "${GGAID_dir}" STREQUAL "RUNSTATEDIR")
  401. set(${absvar} "/${${var}}${CMAKE_INSTALL_PREFIX}")
  402. else()
  403. set(${absvar} "${CMAKE_INSTALL_PREFIX}/${${var}}")
  404. endif()
  405. else()
  406. set(${absvar} "${CMAKE_INSTALL_PREFIX}/${${var}}")
  407. endif()
  408. else()
  409. set(${absvar} "${${var}}")
  410. endif()
  411. unset(GGAID_dir)
  412. unset(GGAID_extra_arg_count)
  413. unset(GGAID_extra_args)
  414. endmacro()
  415. # Result directories
  416. #
  417. foreach(dir
  418. BINDIR
  419. SBINDIR
  420. LIBEXECDIR
  421. SYSCONFDIR
  422. SHAREDSTATEDIR
  423. LOCALSTATEDIR
  424. RUNSTATEDIR
  425. LIBDIR
  426. INCLUDEDIR
  427. OLDINCLUDEDIR
  428. DATAROOTDIR
  429. DATADIR
  430. INFODIR
  431. LOCALEDIR
  432. MANDIR
  433. DOCDIR
  434. )
  435. GNUInstallDirs_get_absolute_install_dir(CMAKE_INSTALL_FULL_${dir} CMAKE_INSTALL_${dir} ${dir})
  436. endforeach()