diff options
author | Guy Harris <guy@alum.mit.edu> | 2016-01-26 19:13:44 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2016-01-27 05:24:50 +0000 |
commit | 54e3b32027f1b28cc9871b5ff35c358eaf8cd05f (patch) | |
tree | be8de4fd8e88d24eff55ce737941b1ff0bbf2545 /cmake/modules/CheckCLinkerFlag.cmake | |
parent | 59bdb4bcb6fa8deea4bdd0cbf1940acc11ef5f4d (diff) |
Don't treat Visual Studio specially for linker flags.
Have CHECK_C_LINKER_FLAG pass /WX to the linker if we're using MSVC, to
force the link to fail if the linker doesn't recognize the flag.
Add flags to WIRESHARK_LD_FLAGS even with MSVC; let CHECK_C_LINKER_FLAG
figure out whether the flag should be used.
While we're at it, fix CHECK_C_LINKER_FLAG to save and restore
CMAKE_REQUIRED_LIBRARIES.
Change-Id: I7f73b4cc3a28eb14e46c2e1e9ad69f5303754f01
Reviewed-on: https://code.wireshark.org/review/13558
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/modules/CheckCLinkerFlag.cmake')
-rw-r--r-- | cmake/modules/CheckCLinkerFlag.cmake | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/cmake/modules/CheckCLinkerFlag.cmake b/cmake/modules/CheckCLinkerFlag.cmake index 4a07a8612e..f657a9b884 100644 --- a/cmake/modules/CheckCLinkerFlag.cmake +++ b/cmake/modules/CheckCLinkerFlag.cmake @@ -32,9 +32,19 @@ MACRO (CHECK_C_LINKER_FLAG _FLAG _RESULT) # 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}") + set(save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + if(CMAKE_C_COMPILER_ID MATCHES "MSVC") + # + # This means the linker is presumably the Microsoft linker; + # we need to pass /WX in order to have the linker fail, + # rather than just complaining and driving on, if it's + # passed a flag it doesn't handle. + # + set(CMAKE_REQUIRED_LIBRARIES "/WX") + endif() + set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES} ${_FLAG}") + message(status "check linker flag - test linker flags: ${_FLAG}") check_c_source_compiles("int main() { return 0;}" ${_RESULT}) - set(CMAKE_REQUIRED_LIBRARIES "") + set(CMAKE_REQUIRED_LIBRARIES "${save_CMAKE_REQUIRED_LIBRARIES}") ENDMACRO (CHECK_C_LINKER_FLAG) |