CMakeCommonLanguageInclude.cmake 5.2 KB

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