cmake: Fail if undefined symbols are used
authorHauke Mehrtens <hauke@hauke-m.de>
Sat, 11 Nov 2023 21:18:18 +0000 (22:18 +0100)
committerHauke Mehrtens <hauke@hauke-m.de>
Sat, 11 Nov 2023 21:22:59 +0000 (22:22 +0100)
Make the linking of the shared library fail when undefined symbols are
used. Linking undefined symbols in a shared library normally works and
the linking of the binary using the shared library fails. We also
compile some example applications and they failed already.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
CMakeLists.txt

index 2de65905a40d8893155877a2b0894bcedec56f39..f4dca0dba358db483fcef82e8fabde4dff587fdd 100644 (file)
@@ -10,6 +10,7 @@ ENDIF()
 ADD_DEFINITIONS(-Wno-unused-parameter -Wmissing-declarations)
 
 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
+SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined")
 
 IF(MBEDTLS)
   ADD_DEFINITIONS(-DHAVE_MBEDTLS)