GNUInstallDirs.cmake 7.2 KB

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