GNUInstallDirs.cmake 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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)
  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. # Note that the future of multi-arch handling may be even
  71. # more complicated than that: http://wiki.debian.org/Multiarch
  72. if(CMAKE_SYSTEM_NAME MATCHES "Linux"
  73. AND NOT CMAKE_CROSSCOMPILING
  74. AND NOT EXISTS "/etc/debian_version")
  75. if(NOT DEFINED CMAKE_SIZEOF_VOID_P)
  76. message(AUTHOR_WARNING
  77. "Unable to determine default CMAKE_INSTALL_LIBDIR directory because no target architecture is known. "
  78. "Please enable at least one language before including GNUInstallDirs.")
  79. else()
  80. if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
  81. set(_LIBDIR_DEFAULT "lib64")
  82. endif()
  83. endif()
  84. endif()
  85. set(CMAKE_INSTALL_LIBDIR "${_LIBDIR_DEFAULT}" CACHE PATH "object code libraries (${_LIBDIR_DEFAULT})")
  86. endif()
  87. if(NOT DEFINED CMAKE_INSTALL_INCLUDEDIR)
  88. set(CMAKE_INSTALL_INCLUDEDIR "include" CACHE PATH "C header files (include)")
  89. endif()
  90. if(NOT DEFINED CMAKE_INSTALL_OLDINCLUDEDIR)
  91. set(CMAKE_INSTALL_OLDINCLUDEDIR "/usr/include" CACHE PATH "C header files for non-gcc (/usr/include)")
  92. endif()
  93. if(NOT DEFINED CMAKE_INSTALL_DATAROOTDIR)
  94. set(CMAKE_INSTALL_DATAROOTDIR "share" CACHE PATH "read-only architecture-independent data root (share)")
  95. endif()
  96. #-----------------------------------------------------------------------------
  97. # Values whose defaults are relative to DATAROOTDIR. Store empty values in
  98. # the cache and store the defaults in local variables if the cache values are
  99. # not set explicitly. This auto-updates the defaults as DATAROOTDIR changes.
  100. if(NOT CMAKE_INSTALL_DATADIR)
  101. set(CMAKE_INSTALL_DATADIR "" CACHE PATH "read-only architecture-independent data (DATAROOTDIR)")
  102. set(CMAKE_INSTALL_DATADIR "${CMAKE_INSTALL_DATAROOTDIR}")
  103. endif()
  104. if(NOT CMAKE_INSTALL_INFODIR)
  105. set(CMAKE_INSTALL_INFODIR "" CACHE PATH "info documentation (DATAROOTDIR/info)")
  106. set(CMAKE_INSTALL_INFODIR "${CMAKE_INSTALL_DATAROOTDIR}/info")
  107. endif()
  108. if(NOT CMAKE_INSTALL_LOCALEDIR)
  109. set(CMAKE_INSTALL_LOCALEDIR "" CACHE PATH "locale-dependent data (DATAROOTDIR/locale)")
  110. set(CMAKE_INSTALL_LOCALEDIR "${CMAKE_INSTALL_DATAROOTDIR}/locale")
  111. endif()
  112. if(NOT CMAKE_INSTALL_MANDIR)
  113. set(CMAKE_INSTALL_MANDIR "" CACHE PATH "man documentation (DATAROOTDIR/man)")
  114. set(CMAKE_INSTALL_MANDIR "${CMAKE_INSTALL_DATAROOTDIR}/man")
  115. endif()
  116. if(NOT CMAKE_INSTALL_DOCDIR)
  117. set(CMAKE_INSTALL_DOCDIR "" CACHE PATH "documentation root (DATAROOTDIR/doc/PROJECT_NAME)")
  118. set(CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}")
  119. endif()
  120. #-----------------------------------------------------------------------------
  121. mark_as_advanced(
  122. CMAKE_INSTALL_BINDIR
  123. CMAKE_INSTALL_SBINDIR
  124. CMAKE_INSTALL_LIBEXECDIR
  125. CMAKE_INSTALL_SYSCONFDIR
  126. CMAKE_INSTALL_SHAREDSTATEDIR
  127. CMAKE_INSTALL_LOCALSTATEDIR
  128. CMAKE_INSTALL_LIBDIR
  129. CMAKE_INSTALL_INCLUDEDIR
  130. CMAKE_INSTALL_OLDINCLUDEDIR
  131. CMAKE_INSTALL_DATAROOTDIR
  132. CMAKE_INSTALL_DATADIR
  133. CMAKE_INSTALL_INFODIR
  134. CMAKE_INSTALL_LOCALEDIR
  135. CMAKE_INSTALL_MANDIR
  136. CMAKE_INSTALL_DOCDIR
  137. )
  138. # Result directories
  139. #
  140. foreach(dir
  141. BINDIR
  142. SBINDIR
  143. LIBEXECDIR
  144. SYSCONFDIR
  145. SHAREDSTATEDIR
  146. LOCALSTATEDIR
  147. LIBDIR
  148. INCLUDEDIR
  149. OLDINCLUDEDIR
  150. DATAROOTDIR
  151. DATADIR
  152. INFODIR
  153. LOCALEDIR
  154. MANDIR
  155. DOCDIR
  156. )
  157. if(NOT IS_ABSOLUTE ${CMAKE_INSTALL_${dir}})
  158. set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_${dir}}")
  159. else()
  160. set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_${dir}}")
  161. endif()
  162. endforeach()