CMakeGenericSystem.cmake 6.2 KB

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