CMakeCommonLanguageInclude.cmake 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. # this file has flags that are shared across languages and sets
  14. # cache values that can be initialized in the platform-compiler.cmake file
  15. # it may be included by more than one language.
  16. string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " $ENV{LDFLAGS}")
  17. string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " $ENV{LDFLAGS}")
  18. string(APPEND CMAKE_MODULE_LINKER_FLAGS_INIT " $ENV{LDFLAGS}")
  19. foreach(t EXE SHARED MODULE STATIC)
  20. foreach(c "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO)
  21. string(STRIP "${CMAKE_${t}_LINKER_FLAGS${c}_INIT}" CMAKE_${t}_LINKER_FLAGS${c}_INIT)
  22. endforeach()
  23. endforeach()
  24. if(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
  25. # default build type is none
  26. if(NOT CMAKE_NO_BUILD_TYPE)
  27. set (CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE_INIT} CACHE STRING
  28. "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.")
  29. endif()
  30. set (CMAKE_EXE_LINKER_FLAGS_DEBUG ${CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT} CACHE STRING
  31. "Flags used by the linker during debug builds.")
  32. set (CMAKE_EXE_LINKER_FLAGS_MINSIZEREL ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT} CACHE STRING
  33. "Flags used by the linker during release minsize builds.")
  34. set (CMAKE_EXE_LINKER_FLAGS_RELEASE ${CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT} CACHE STRING
  35. "Flags used by the linker during release builds.")
  36. set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
  37. ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT} CACHE STRING
  38. "Flags used by the linker during Release with Debug Info builds.")
  39. set (CMAKE_SHARED_LINKER_FLAGS_DEBUG ${CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT} CACHE STRING
  40. "Flags used by the linker during debug builds.")
  41. set (CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL ${CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL_INIT}
  42. CACHE STRING
  43. "Flags used by the linker during release minsize builds.")
  44. set (CMAKE_SHARED_LINKER_FLAGS_RELEASE ${CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT} CACHE STRING
  45. "Flags used by the linker during release builds.")
  46. set (CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
  47. ${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT} CACHE STRING
  48. "Flags used by the linker during Release with Debug Info builds.")
  49. set (CMAKE_MODULE_LINKER_FLAGS_DEBUG ${CMAKE_MODULE_LINKER_FLAGS_DEBUG_INIT} CACHE STRING
  50. "Flags used by the linker during debug builds.")
  51. set (CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL ${CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL_INIT}
  52. CACHE STRING
  53. "Flags used by the linker during release minsize builds.")
  54. set (CMAKE_MODULE_LINKER_FLAGS_RELEASE ${CMAKE_MODULE_LINKER_FLAGS_RELEASE_INIT} CACHE STRING
  55. "Flags used by the linker during release builds.")
  56. set (CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
  57. ${CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO_INIT} CACHE STRING
  58. "Flags used by the linker during Release with Debug Info builds.")
  59. set (CMAKE_STATIC_LINKER_FLAGS_DEBUG ${CMAKE_STATIC_LINKER_FLAGS_DEBUG_INIT} CACHE STRING
  60. "Flags used by the linker during debug builds.")
  61. set (CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL ${CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL_INIT}
  62. CACHE STRING
  63. "Flags used by the linker during release minsize builds.")
  64. set (CMAKE_STATIC_LINKER_FLAGS_RELEASE ${CMAKE_STATIC_LINKER_FLAGS_RELEASE_INIT} CACHE STRING
  65. "Flags used by the linker during release builds.")
  66. set (CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO
  67. ${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO_INIT} CACHE STRING
  68. "Flags used by the linker during Release with Debug Info builds.")
  69. endif()
  70. # executable linker flags
  71. set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS_INIT}"
  72. CACHE STRING "Flags used by the linker.")
  73. # shared linker flags
  74. set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT}"
  75. CACHE STRING "Flags used by the linker during the creation of dll's.")
  76. # module linker flags
  77. set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS_INIT}"
  78. CACHE STRING "Flags used by the linker during the creation of modules.")
  79. # static linker flags
  80. set (CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS_INIT}"
  81. CACHE STRING "Flags used by the linker during the creation of static libraries.")
  82. # Alias the build tool variable for backward compatibility.
  83. set(CMAKE_BUILD_TOOL ${CMAKE_MAKE_PROGRAM})
  84. mark_as_advanced(
  85. CMAKE_VERBOSE_MAKEFILE
  86. CMAKE_EXE_LINKER_FLAGS
  87. CMAKE_EXE_LINKER_FLAGS_DEBUG
  88. CMAKE_EXE_LINKER_FLAGS_MINSIZEREL
  89. CMAKE_EXE_LINKER_FLAGS_RELEASE
  90. CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
  91. CMAKE_SHARED_LINKER_FLAGS
  92. CMAKE_SHARED_LINKER_FLAGS_DEBUG
  93. CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL
  94. CMAKE_SHARED_LINKER_FLAGS_RELEASE
  95. CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
  96. CMAKE_MODULE_LINKER_FLAGS
  97. CMAKE_MODULE_LINKER_FLAGS_DEBUG
  98. CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL
  99. CMAKE_MODULE_LINKER_FLAGS_RELEASE
  100. CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
  101. CMAKE_STATIC_LINKER_FLAGS
  102. CMAKE_STATIC_LINKER_FLAGS_DEBUG
  103. CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL
  104. CMAKE_STATIC_LINKER_FLAGS_RELEASE
  105. CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO
  106. )