CMakeGenericSystem.cmake 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. #=============================================================================
  2. # Copyright 2004-2009 Kitware, Inc.
  3. #
  4. # Distributed under the OSI-approved BSD License (the "License");
  5. # see accompanying file Copyright.txt for details.
  6. #
  7. # This software is distributed WITHOUT ANY WARRANTY; without even the
  8. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. # See the License for more information.
  10. #=============================================================================
  11. # (To distribute this file outside of CMake, substitute the full
  12. # License text for the above reference.)
  13. set(CMAKE_SHARED_LIBRARY_C_FLAGS "") # -pic
  14. set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared
  15. set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib
  16. set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "") # -rpath
  17. set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "") # : or empty
  18. set(CMAKE_INCLUDE_FLAG_C "-I") # -I
  19. set(CMAKE_INCLUDE_FLAG_C_SEP "") # , or empty
  20. set(CMAKE_LIBRARY_PATH_FLAG "-L")
  21. set(CMAKE_LIBRARY_PATH_TERMINATOR "") # for the Digital Mars D compiler the link paths have to be terminated with a "/"
  22. set(CMAKE_LINK_LIBRARY_FLAG "-l")
  23. set(CMAKE_LINK_LIBRARY_SUFFIX "")
  24. set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
  25. set(CMAKE_STATIC_LIBRARY_SUFFIX ".a")
  26. set(CMAKE_SHARED_LIBRARY_PREFIX "lib") # lib
  27. set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") # .so
  28. set(CMAKE_EXECUTABLE_SUFFIX "") # .exe
  29. set(CMAKE_DL_LIBS "dl")
  30. set(CMAKE_FIND_LIBRARY_PREFIXES "lib")
  31. set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a")
  32. # basically all general purpose OSs support shared libs
  33. set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
  34. set (CMAKE_SKIP_RPATH "NO" CACHE BOOL
  35. "If set, runtime paths are not added when using shared libraries.")
  36. set (CMAKE_SKIP_INSTALL_RPATH "NO" CACHE BOOL
  37. "If set, runtime paths are not added when installing shared libraries, but are added when building.")
  38. set(CMAKE_VERBOSE_MAKEFILE FALSE CACHE BOOL "If this value is on, makefiles will be generated without the .SILENT directive, and all commands will be echoed to the console during the make. This is useful for debugging only. With Visual Studio IDE projects all commands are done without /nologo.")
  39. if(CMAKE_GENERATOR MATCHES "Makefiles")
  40. set(CMAKE_COLOR_MAKEFILE ON CACHE BOOL
  41. "Enable/Disable color output during build."
  42. )
  43. mark_as_advanced(CMAKE_COLOR_MAKEFILE)
  44. if(DEFINED CMAKE_RULE_MESSAGES)
  45. set_property(GLOBAL PROPERTY RULE_MESSAGES ${CMAKE_RULE_MESSAGES})
  46. endif()
  47. if(CMAKE_GENERATOR MATCHES "Unix Makefiles")
  48. set(CMAKE_EXPORT_COMPILE_COMMANDS OFF CACHE BOOL
  49. "Enable/Disable output of compile commands during generation."
  50. )
  51. mark_as_advanced(CMAKE_EXPORT_COMPILE_COMMANDS)
  52. endif()
  53. endif()
  54. if(CMAKE_GENERATOR MATCHES "Ninja")
  55. set(CMAKE_EXPORT_COMPILE_COMMANDS OFF CACHE BOOL
  56. "Enable/Disable output of compile commands during generation."
  57. )
  58. mark_as_advanced(CMAKE_EXPORT_COMPILE_COMMANDS)
  59. endif()
  60. # GetDefaultWindowsPrefixBase
  61. #
  62. # Compute the base directory for CMAKE_INSTALL_PREFIX based on:
  63. # - is this 32-bit or 64-bit Windows
  64. # - is this 32-bit or 64-bit CMake running
  65. # - what architecture targets will be built
  66. #
  67. function(GetDefaultWindowsPrefixBase var)
  68. # Try to guess what architecture targets will end up being built as,
  69. # even if CMAKE_SIZEOF_VOID_P is not computed yet... We need to know
  70. # the architecture of the targets being built to choose the right
  71. # default value for CMAKE_INSTALL_PREFIX.
  72. #
  73. if("${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)")
  74. set(arch_hint "x64")
  75. elseif("${CMAKE_GENERATOR}" MATCHES "ARM")
  76. set(arch_hint "ARM")
  77. elseif("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
  78. set(arch_hint "x64")
  79. elseif("$ENV{LIB}" MATCHES "(amd64|ia64)")
  80. set(arch_hint "x64")
  81. endif()
  82. if(NOT arch_hint)
  83. set(arch_hint "x86")
  84. endif()
  85. # default env in a 64-bit app on Win64:
  86. # ProgramFiles=C:\Program Files
  87. # ProgramFiles(x86)=C:\Program Files (x86)
  88. # ProgramW6432=C:\Program Files
  89. #
  90. # default env in a 32-bit app on Win64:
  91. # ProgramFiles=C:\Program Files (x86)
  92. # ProgramFiles(x86)=C:\Program Files (x86)
  93. # ProgramW6432=C:\Program Files
  94. #
  95. # default env in a 32-bit app on Win32:
  96. # ProgramFiles=C:\Program Files
  97. # ProgramFiles(x86) NOT DEFINED
  98. # ProgramW6432 NOT DEFINED
  99. # By default, use the ProgramFiles env var as the base value of
  100. # CMAKE_INSTALL_PREFIX:
  101. #
  102. set(_PREFIX_ENV_VAR "ProgramFiles")
  103. if ("$ENV{ProgramW6432}" STREQUAL "")
  104. # running on 32-bit Windows
  105. # must be a 32-bit CMake, too...
  106. #message("guess: this is a 32-bit CMake running on 32-bit Windows")
  107. else()
  108. # running on 64-bit Windows
  109. if ("$ENV{ProgramW6432}" STREQUAL "$ENV{ProgramFiles}")
  110. # 64-bit CMake
  111. #message("guess: this is a 64-bit CMake running on 64-bit Windows")
  112. if(NOT "${arch_hint}" STREQUAL "x64")
  113. # building 32-bit targets
  114. set(_PREFIX_ENV_VAR "ProgramFiles(x86)")
  115. endif()
  116. else()
  117. # 32-bit CMake
  118. #message("guess: this is a 32-bit CMake running on 64-bit Windows")
  119. if("${arch_hint}" STREQUAL "x64")
  120. # building 64-bit targets
  121. set(_PREFIX_ENV_VAR "ProgramW6432")
  122. endif()
  123. endif()
  124. endif()
  125. #if("${arch_hint}" STREQUAL "x64")
  126. # message("guess: you are building a 64-bit app")
  127. #else()
  128. # message("guess: you are building a 32-bit app")
  129. #endif()
  130. if(NOT "$ENV{${_PREFIX_ENV_VAR}}" STREQUAL "")
  131. file(TO_CMAKE_PATH "$ENV{${_PREFIX_ENV_VAR}}" _base)
  132. elseif(NOT "$ENV{SystemDrive}" STREQUAL "")
  133. set(_base "$ENV{SystemDrive}/Program Files")
  134. else()
  135. set(_base "C:/Program Files")
  136. endif()
  137. set(${var} "${_base}" PARENT_SCOPE)
  138. endfunction()
  139. # Set a variable to indicate whether the value of CMAKE_INSTALL_PREFIX
  140. # was initialized by the block below. This is useful for user
  141. # projects to change the default prefix while still allowing the
  142. # command line to override it.
  143. if(NOT DEFINED CMAKE_INSTALL_PREFIX)
  144. set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT 1)
  145. endif()
  146. # Choose a default install prefix for this platform.
  147. if(CMAKE_HOST_UNIX)
  148. set(CMAKE_INSTALL_PREFIX "/usr/local"
  149. CACHE PATH "Install path prefix, prepended onto install directories.")
  150. else()
  151. GetDefaultWindowsPrefixBase(CMAKE_GENERIC_PROGRAM_FILES)
  152. set(CMAKE_INSTALL_PREFIX
  153. "${CMAKE_GENERIC_PROGRAM_FILES}/${PROJECT_NAME}"
  154. CACHE PATH "Install path prefix, prepended onto install directories.")
  155. set(CMAKE_GENERIC_PROGRAM_FILES)
  156. endif()
  157. # Set a variable which will be used as component name in install() commands
  158. # where no COMPONENT has been given:
  159. set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "Unspecified")
  160. mark_as_advanced(
  161. CMAKE_SKIP_RPATH
  162. CMAKE_SKIP_INSTALL_RPATH
  163. CMAKE_VERBOSE_MAKEFILE
  164. )