From d269ec49b37dc96e688a87270dcdc7e37f3f00ff Mon Sep 17 00:00:00 2001 From: Antenore Gatta Date: Sat, 6 Mar 2021 22:59:44 +0100 Subject: =?UTF-8?q?Adding=20linker=20option=20-Wl,=E2=80=93no-undefined?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -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 --- CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'CMakeLists.txt') 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) -- cgit v1.2.3