CMakeGenericSystem.cmake 6.5 KB

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