CMakeGenericSystem.cmake 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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_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.")
  37. IF(CMAKE_GENERATOR MATCHES "Makefiles")
  38. SET(CMAKE_COLOR_MAKEFILE ON CACHE BOOL
  39. "Enable/Disable color output during build."
  40. )
  41. MARK_AS_ADVANCED(CMAKE_COLOR_MAKEFILE)
  42. IF(DEFINED CMAKE_RULE_MESSAGES)
  43. SET_PROPERTY(GLOBAL PROPERTY RULE_MESSAGES ${CMAKE_RULE_MESSAGES})
  44. ENDIF(DEFINED CMAKE_RULE_MESSAGES)
  45. SET(CMAKE_EXPORT_COMPILE_COMMANDS OFF CACHE BOOL
  46. "Enable/Disable output of compile commands during generation."
  47. )
  48. ENDIF(CMAKE_GENERATOR MATCHES "Makefiles")
  49. # GetDefaultWindowsPrefixBase
  50. #
  51. # Compute the base directory for CMAKE_INSTALL_PREFIX based on:
  52. # - is this 32-bit or 64-bit Windows
  53. # - is this 32-bit or 64-bit CMake running
  54. # - what architecture targets will be built
  55. #
  56. function(GetDefaultWindowsPrefixBase var)
  57. # Try to guess what architecture targets will end up being built as,
  58. # even if CMAKE_SIZEOF_VOID_P is not computed yet... We need to know
  59. # the architecture of the targets being built to choose the right
  60. # default value for CMAKE_INSTALL_PREFIX.
  61. #
  62. if("${CMAKE_GENERATOR}" MATCHES "Win64")
  63. set(arch_hint "x64")
  64. elseif("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
  65. set(arch_hint "x64")
  66. elseif("$ENV{LIB}" MATCHES "(amd64|ia64)")
  67. set(arch_hint "x64")
  68. endif()
  69. if(NOT arch_hint)
  70. set(arch_hint "x86")
  71. endif()
  72. # default env in a 64-bit app on Win64:
  73. # ProgramFiles=C:\Program Files
  74. # ProgramFiles(x86)=C:\Program Files (x86)
  75. # ProgramW6432=C:\Program Files
  76. #
  77. # default env in a 32-bit app on Win64:
  78. # ProgramFiles=C:\Program Files (x86)
  79. # ProgramFiles(x86)=C:\Program Files (x86)
  80. # ProgramW6432=C:\Program Files
  81. #
  82. # default env in a 32-bit app on Win32:
  83. # ProgramFiles=C:\Program Files
  84. # ProgramFiles(x86) NOT DEFINED
  85. # ProgramW6432 NOT DEFINED
  86. # By default, use the ProgramFiles env var as the base value of
  87. # CMAKE_INSTALL_PREFIX:
  88. #
  89. set(_PREFIX_ENV_VAR "ProgramFiles")
  90. if ("$ENV{ProgramW6432}" STREQUAL "")
  91. # running on 32-bit Windows
  92. # must be a 32-bit CMake, too...
  93. #message("guess: this is a 32-bit CMake running on 32-bit Windows")
  94. else()
  95. # running on 64-bit Windows
  96. if ("$ENV{ProgramW6432}" STREQUAL "$ENV{ProgramFiles}")
  97. # 64-bit CMake
  98. #message("guess: this is a 64-bit CMake running on 64-bit Windows")
  99. if(NOT "${arch_hint}" STREQUAL "x64")
  100. # building 32-bit targets
  101. set(_PREFIX_ENV_VAR "ProgramFiles(x86)")
  102. endif()
  103. else()
  104. # 32-bit CMake
  105. #message("guess: this is a 32-bit CMake running on 64-bit Windows")
  106. if("${arch_hint}" STREQUAL "x64")
  107. # building 64-bit targets
  108. set(_PREFIX_ENV_VAR "ProgramW6432")
  109. endif()
  110. endif()
  111. endif()
  112. #if("${arch_hint}" STREQUAL "x64")
  113. # message("guess: you are building a 64-bit app")
  114. #else()
  115. # message("guess: you are building a 32-bit app")
  116. #endif()
  117. if(NOT "$ENV{${_PREFIX_ENV_VAR}}" STREQUAL "")
  118. file(TO_CMAKE_PATH "$ENV{${_PREFIX_ENV_VAR}}" _base)
  119. elseif(NOT "$ENV{SystemDrive}" STREQUAL "")
  120. set(_base "$ENV{SystemDrive}/Program Files")
  121. else()
  122. set(_base "C:/Program Files")
  123. endif()
  124. set(${var} "${_base}" PARENT_SCOPE)
  125. endfunction()
  126. # Set a variable to indicate whether the value of CMAKE_INSTALL_PREFIX
  127. # was initialized by the block below. This is useful for user
  128. # projects to change the default prefix while still allowing the
  129. # command line to override it.
  130. IF(NOT DEFINED CMAKE_INSTALL_PREFIX)
  131. SET(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT 1)
  132. ENDIF(NOT DEFINED CMAKE_INSTALL_PREFIX)
  133. # Choose a default install prefix for this platform.
  134. IF(CMAKE_HOST_UNIX)
  135. SET(CMAKE_INSTALL_PREFIX "/usr/local"
  136. CACHE PATH "Install path prefix, prepended onto install directories.")
  137. ELSE(CMAKE_HOST_UNIX)
  138. GetDefaultWindowsPrefixBase(CMAKE_GENERIC_PROGRAM_FILES)
  139. SET(CMAKE_INSTALL_PREFIX
  140. "${CMAKE_GENERIC_PROGRAM_FILES}/${PROJECT_NAME}"
  141. CACHE PATH "Install path prefix, prepended onto install directories.")
  142. SET(CMAKE_GENERIC_PROGRAM_FILES)
  143. ENDIF(CMAKE_HOST_UNIX)
  144. MARK_AS_ADVANCED(
  145. CMAKE_SKIP_RPATH
  146. CMAKE_VERBOSE_MAKEFILE
  147. )