Commit 95ced654cbc976901896f502cbb9b49b5ec88e93

Sam Lantinga 2014-08-17T13:15:45

cmake: add -Wl,--no-undefined to GCC linker flags This way unresolved symbols will be detected when linking the shared library version.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fcf7c18..8f408c7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -340,6 +340,12 @@ if(USE_GCC OR USE_CLANG)
   if(HAVE_GCC_WSHADOW)
     list(APPEND EXTRA_CFLAGS "-Wshadow")
   endif()
+
+  set(CMAKE_REQUIRED_FLAGS "-Wl,--no-undefined")
+  check_c_compiler_flag("" HAVE_NO_UNDEFINED)
+  if(HAVE_NO_UNDEFINED)
+    list(APPEND EXTRA_LDFLAGS "-Wl,--no-undefined")
+  endif()
 endif()
 
 if(ASSEMBLY)