GNUInstallDirs.cmake 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. #.rst:
  2. # GNUInstallDirs
  3. # --------------
  4. #
  5. # Define GNU standard installation directories
  6. #
  7. # Provides install directory variables as defined for GNU software:
  8. #
  9. # ::
  10. #
  11. # http://www.gnu.org/prep/standards/html_node/Directory-Variables.html
  12. #
  13. # Inclusion of this module defines the following variables:
  14. #
  15. # ::
  16. #
  17. # CMAKE_INSTALL_<dir> - destination for files of a given type
  18. # CMAKE_INSTALL_FULL_<dir> - corresponding absolute path
  19. #
  20. # where <dir> is one of:
  21. #
  22. # ::
  23. #
  24. # BINDIR - user executables (bin)
  25. # SBINDIR - system admin executables (sbin)
  26. # LIBEXECDIR - program executables (libexec)
  27. # SYSCONFDIR - read-only single-machine data (etc)
  28. # SHAREDSTATEDIR - modifiable architecture-independent data (com)
  29. # LOCALSTATEDIR - modifiable single-machine data (var)
  30. # LIBDIR - object code libraries (lib or lib64 or lib/<multiarch-tuple> on Debian)
  31. # INCLUDEDIR - C header files (include)
  32. # OLDINCLUDEDIR - C header files for non-gcc (/usr/include)
  33. # DATAROOTDIR - read-only architecture-independent data root (share)
  34. # DATADIR - read-only architecture-independent data (DATAROOTDIR)
  35. # INFODIR - info documentation (DATAROOTDIR/info)
  36. # LOCALEDIR - locale-dependent data (DATAROOTDIR/locale)
  37. # MANDIR - man documentation (DATAROOTDIR/man)
  38. # DOCDIR - documentation root (DATAROOTDIR/doc/PROJECT_NAME)
  39. #
  40. # Each CMAKE_INSTALL_<dir> value may be passed to the DESTINATION
  41. # options of install() commands for the corresponding file type. If the
  42. # includer does not define a value the above-shown default will be used
  43. # and the value will appear in the cache for editing by the user. Each
  44. # CMAKE_INSTALL_FULL_<dir> value contains an absolute path constructed
  45. # from the corresponding destination by prepending (if necessary) the
  46. # value of CMAKE_INSTALL_PREFIX.
  47. #=============================================================================
  48. # Copyright 2011 Nikita Krupen'ko <[email protected]>
  49. # Copyright 2011 Kitware, Inc.
  50. #
  51. # Distributed under the OSI-approved BSD License (the "License");
  52. # see accompanying file Copyright.txt for details.
  53. #
  54. # This software is distributed WITHOUT ANY WARRANTY; without even the
  55. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  56. # See the License for more information.
  57. #=============================================================================
  58. # (To distribute this file outside of CMake, substitute the full
  59. # License text for the above reference.)
  60. # Installation directories
  61. #
  62. if(NOT DEFINED CMAKE_INSTALL_BINDIR)
  63. set(CMAKE_INSTALL_BINDIR "bin" CACHE PATH "user executables (bin)")
  64. endif()
  65. if(NOT DEFINED CMAKE_INSTALL_SBINDIR)
  66. set(CMAKE_INSTALL_SBINDIR "sbin" CACHE PATH "system admin executables (sbin)")
  67. endif()
  68. if(NOT DEFINED CMAKE_INSTALL_LIBEXECDIR)
  69. set(CMAKE_INSTALL_LIBEXECDIR "libexec" CACHE PATH "program executables (libexec)")
  70. endif()
  71. if(NOT DEFINED CMAKE_INSTALL_SYSCONFDIR)
  72. set(CMAKE_INSTALL_SYSCONFDIR "etc" CACHE PATH "read-only single-machine data (etc)")
  73. endif()
  74. if(NOT DEFINED CMAKE_INSTALL_SHAREDSTATEDIR)
  75. set(CMAKE_INSTALL_SHAREDSTATEDIR "com" CACHE PATH "modifiable architecture-independent data (com)")
  76. endif()
  77. if(NOT DEFINED CMAKE_INSTALL_LOCALSTATEDIR)
  78. set(CMAKE_INSTALL_LOCALSTATEDIR "var" CACHE PATH "modifiable single-machine data (var)")
  79. endif()
  80. if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
  81. set(_LIBDIR_DEFAULT "lib")
  82. # Override this default 'lib' with 'lib64' iff:
  83. # - we are on Linux system but NOT cross-compiling
  84. # - we are NOT on debian
  85. # - we are on a 64 bits system
  86. # reason is: amd64 ABI: http://www.x86-64.org/documentation/abi.pdf
  87. # For Debian with multiarch, use 'lib/${CMAKE_LIBRARY_ARCHITECTURE}' if
  88. # CMAKE_LIBRARY_ARCHITECTURE is set (which contains e.g. "i386-linux-gnu"
  89. # See http://wiki.debian.org/Multiarch
  90. if(CMAKE_SYSTEM_NAME MATCHES "Linux"
  91. AND NOT CMAKE_CROSSCOMPILING)
  92. if (EXISTS "/etc/debian_version") # is this a debian system ?
  93. if(CMAKE_LIBRARY_ARCHITECTURE)
  94. set(_LIBDIR_DEFAULT "lib/${CMAKE_LIBRARY_ARCHITECTURE}")
  95. endif()
  96. else() # not debian, rely on CMAKE_SIZEOF_VOID_P:
  97. if(NOT DEFINED CMAKE_SIZEOF_VOID_P)
  98. message(AUTHOR_WARNING
  99. "Unable to determine default CMAKE_INSTALL_LIBDIR directory because no target architecture is known. "
  100. "Please enable at least one language before including GNUInstallDirs.")
  101. else()
  102. if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
  103. set(_LIBDIR_DEFAULT "lib64")
  104. endif()
  105. endif()
  106. endif()
  107. endif()
  108. set(CMAKE_INSTALL_LIBDIR "${_LIBDIR_DEFAULT}" CACHE PATH "object code libraries (${_LIBDIR_DEFAULT})")
  109. endif()
  110. if(NOT DEFINED CMAKE_INSTALL_INCLUDEDIR)
  111. set(CMAKE_INSTALL_INCLUDEDIR "include" CACHE PATH "C header files (include)")
  112. endif()
  113. if(NOT DEFINED CMAKE_INSTALL_OLDINCLUDEDIR)
  114. set(CMAKE_INSTALL_OLDINCLUDEDIR "/usr/include" CACHE PATH "C header files for non-gcc (/usr/include)")
  115. endif()
  116. if(NOT DEFINED CMAKE_INSTALL_DATAROOTDIR)
  117. set(CMAKE_INSTALL_DATAROOTDIR "share" CACHE PATH "read-only architecture-independent data root (share)")
  118. endif()
  119. #-----------------------------------------------------------------------------
  120. # Values whose defaults are relative to DATAROOTDIR. Store empty values in
  121. # the cache and store the defaults in local variables if the cache values are
  122. # not set explicitly. This auto-updates the defaults as DATAROOTDIR changes.
  123. if(NOT CMAKE_INSTALL_DATADIR)
  124. set(CMAKE_INSTALL_DATADIR "" CACHE PATH "read-only architecture-independent data (DATAROOTDIR)")
  125. set(CMAKE_INSTALL_DATADIR "${CMAKE_INSTALL_DATAROOTDIR}")
  126. endif()
  127. if(NOT CMAKE_INSTALL_INFODIR)
  128. set(CMAKE_INSTALL_INFODIR "" CACHE PATH "info documentation (DATAROOTDIR/info)")
  129. set(CMAKE_INSTALL_INFODIR "${CMAKE_INSTALL_DATAROOTDIR}/info")
  130. endif()
  131. if(NOT CMAKE_INSTALL_LOCALEDIR)
  132. set(CMAKE_INSTALL_LOCALEDIR "" CACHE PATH "locale-dependent data (DATAROOTDIR/locale)")
  133. set(CMAKE_INSTALL_LOCALEDIR "${CMAKE_INSTALL_DATAROOTDIR}/locale")
  134. endif()
  135. if(NOT CMAKE_INSTALL_MANDIR)
  136. set(CMAKE_INSTALL_MANDIR "" CACHE PATH "man documentation (DATAROOTDIR/man)")
  137. set(CMAKE_INSTALL_MANDIR "${CMAKE_INSTALL_DATAROOTDIR}/man")
  138. endif()
  139. if(NOT CMAKE_INSTALL_DOCDIR)
  140. set(CMAKE_INSTALL_DOCDIR "" CACHE PATH "documentation root (DATAROOTDIR/doc/PROJECT_NAME)")
  141. set(CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}")
  142. endif()
  143. #-----------------------------------------------------------------------------
  144. mark_as_advanced(
  145. CMAKE_INSTALL_BINDIR
  146. CMAKE_INSTALL_SBINDIR
  147. CMAKE_INSTALL_LIBEXECDIR
  148. CMAKE_INSTALL_SYSCONFDIR
  149. CMAKE_INSTALL_SHAREDSTATEDIR
  150. CMAKE_INSTALL_LOCALSTATEDIR
  151. CMAKE_INSTALL_LIBDIR
  152. CMAKE_INSTALL_INCLUDEDIR
  153. CMAKE_INSTALL_OLDINCLUDEDIR
  154. CMAKE_INSTALL_DATAROOTDIR
  155. CMAKE_INSTALL_DATADIR
  156. CMAKE_INSTALL_INFODIR
  157. CMAKE_INSTALL_LOCALEDIR
  158. CMAKE_INSTALL_MANDIR
  159. CMAKE_INSTALL_DOCDIR
  160. )
  161. # Result directories
  162. #
  163. foreach(dir
  164. BINDIR
  165. SBINDIR
  166. LIBEXECDIR
  167. SYSCONFDIR
  168. SHAREDSTATEDIR
  169. LOCALSTATEDIR
  170. LIBDIR
  171. INCLUDEDIR
  172. OLDINCLUDEDIR
  173. DATAROOTDIR
  174. DATADIR
  175. INFODIR
  176. LOCALEDIR
  177. MANDIR
  178. DOCDIR
  179. )
  180. if(NOT IS_ABSOLUTE ${CMAKE_INSTALL_${dir}})
  181. set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_${dir}}")
  182. else()
  183. set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_${dir}}")
  184. endif()
  185. endforeach()