cmake: add -Wl,--no-undefined to GCC linker flags
authorSam Lantinga <slouken@libsdl.org>
Sun, 17 Aug 2014 13:15:45 -0700
changeset 9082 22232029f074
parent 9081 39eb61ccbc82
child 9083 029f8d643dbe
cmake: add -Wl,--no-undefined to GCC linker flags This way unresolved symbols will be detected when linking the shared library version.
CMakeLists.txt
--- a/CMakeLists.txt	Sun Aug 17 13:15:09 2014 -0700
+++ b/CMakeLists.txt	Sun Aug 17 13:15:45 2014 -0700
@@ -340,6 +340,12 @@
   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)