diff options
author | Guy Harris <guy@alum.mit.edu> | 2016-01-26 15:36:00 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2016-01-27 00:55:07 +0000 |
commit | dc91ac5241f89f764fc442f9f8b6245ce308dd2d (patch) | |
tree | 5445d3527bf281b620b1d4a6473170ae87b5ebb1 /cmake | |
parent | 7ac62e902788c455db9375343f6287d507c8792f (diff) |
Make CHECK_C_LINKER_FLAG work with, at least, the Xcode generator.
As per a suggestion from a Kitware person in bug 0015934:
https://cmake.org/Bug/view.php?id=15934
We also don't need to check whether the resulting code *runs* -
check_c_source_compiles not only compiles, it links as well.
Change-Id: Ied09b9da7c88ac46f14df14f6a6260037abdbef4
Reviewed-on: https://code.wireshark.org/review/13556
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/modules/CheckCLinkerFlag.cmake | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/cmake/modules/CheckCLinkerFlag.cmake b/cmake/modules/CheckCLinkerFlag.cmake index abe4a3a283..4a07a8612e 100644 --- a/cmake/modules/CheckCLinkerFlag.cmake +++ b/cmake/modules/CheckCLinkerFlag.cmake @@ -15,9 +15,26 @@ INCLUDE(CheckCSourceRuns) MACRO (CHECK_C_LINKER_FLAG _FLAG _RESULT) - SET(CMAKE_REQUIRED_FLAGS "${_FLAG}") - message(status "check linker flag - test linker flags: ${CMAKE_REQUIRED_FLAGS}") - CHECK_C_SOURCE_RUNS("int main() { return 0;}" ${_RESULT}) - SET(CMAKE_REQUIRED_FLAGS "") + # + # This is ugly. + # + # See CMake bug 0015934: + # + # https://cmake.org/Bug/view.php?id=15934 + # + # So we add the flags to CMAKE_REQUIRED_LIBRARIES, to sneak it into + # the linker flags. + # + # This may or may not work with versions earlier than 2.8.11, although + # 2.8.10's Xcode generator doesn't appear to work at all - it fails + # with an internal CMake error. + # + # With 3.2 and later, we could also set policy CMP0056 to NEW and + # set CMAKE_EXE_LINKER_FLAGS. + # + set(CMAKE_REQUIRED_LIBRARIES "${_FLAG}") + message(status "check linker flag - test linker flags: ${CMAKE_REQUIRED_LIBRARIES}") + check_c_source_compiles("int main() { return 0;}" ${_RESULT}) + set(CMAKE_REQUIRED_LIBRARIES "") ENDMACRO (CHECK_C_LINKER_FLAG) |