diff options
author | Antenore Gatta <antenore@simbiosi.org> | 2021-03-07 00:59:44 +0300 |
---|---|---|
committer | Antenore Gatta <antenore@simbiosi.org> | 2021-03-07 00:59:44 +0300 |
commit | d269ec49b37dc96e688a87270dcdc7e37f3f00ff (patch) | |
tree | 3af409046ed59a0f82437169dabf0145888b3a52 /CMakeLists.txt | |
parent | 428c7edd672f1f408608c1751f4f07ec3fcea075 (diff) |
Adding linker option -Wl,–no-undefined
-Wl,–no-undefined linker option can be used when building shared library, undefined symbols will be shown as linker errors.
This should avoid issues like #2429
Signed-off-by: Antenore Gatta <antenore@simbiosi.org>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ebe088e54..4492dfc24 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -237,6 +237,17 @@ if(${CMAKE_C_COMPILER_ID} STREQUAL "Clang") endif() endif() +# Figure out no-undefined flag +if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin) + set(NO_UNDEFINED_FLAG "-Wl,-undefined,error") +elseif((${CMAKE_SYSTEM_NAME} STREQUAL Linux) OR MINGW) + set(NO_UNDEFINED_FLAG "-Wl,--no-undefined") +else() + # On OpenBSD this seems to cause problems, so we unset it + set(NO_UNDEFINED_FLAG "") +endif() +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${NO_UNDEFINED_FLAG}") + check_include_files(sys/socket.h HAVE_SYS_SOCKET_H) check_include_files(arpa/inet.h HAVE_ARPA_INET_H) check_include_files(netinet/in.h HAVE_NETINET_IN_H) |