From 7ec90527b782abbcd4140febcab4791962eaf37b Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Sun, 16 Aug 2026 15:36:18 +0100 Subject: [PATCH] [cmake] Disallow undefined symbols in most ndlls If a symbol is undefined, it may cause a load time error. We can catch this at link time instead by using --no-undefined. Some ndlls intentionally allow undefined symbols, so this is not applied universally. --- libs/regexp/CMakeLists.txt | 4 ++++ libs/sqlite/CMakeLists.txt | 4 ++++ libs/ssl/CMakeLists.txt | 4 ++++ libs/std/CMakeLists.txt | 4 ++++ libs/ui/CMakeLists.txt | 4 ++++ libs/zlib/CMakeLists.txt | 4 ++++ 6 files changed, 24 insertions(+) diff --git a/libs/regexp/CMakeLists.txt b/libs/regexp/CMakeLists.txt index aa91e863..20763827 100644 --- a/libs/regexp/CMakeLists.txt +++ b/libs/regexp/CMakeLists.txt @@ -78,6 +78,10 @@ set_target_properties(regexp.ndll SUFFIX .ndll ) +if (UNIX AND NOT APPLE) + target_link_options(regexp.ndll PRIVATE "-Wl,--no-undefined") +endif() + install ( TARGETS regexp.ndll DESTINATION ${DEST_NDLL} diff --git a/libs/sqlite/CMakeLists.txt b/libs/sqlite/CMakeLists.txt index 5a219bde..5609ca3b 100644 --- a/libs/sqlite/CMakeLists.txt +++ b/libs/sqlite/CMakeLists.txt @@ -40,6 +40,10 @@ set_target_properties(sqlite.ndll SUFFIX .ndll ) +if (UNIX AND NOT APPLE) + target_link_options(sqlite.ndll PRIVATE "-Wl,--no-undefined") +endif() + install ( TARGETS sqlite.ndll DESTINATION ${DEST_NDLL} diff --git a/libs/ssl/CMakeLists.txt b/libs/ssl/CMakeLists.txt index 93471683..25d56365 100644 --- a/libs/ssl/CMakeLists.txt +++ b/libs/ssl/CMakeLists.txt @@ -78,6 +78,10 @@ set_target_properties(ssl.ndll SUFFIX .ndll ) +if (UNIX AND NOT APPLE) + target_link_options(ssl.ndll PRIVATE "-Wl,--no-undefined") +endif() + install ( TARGETS ssl.ndll DESTINATION ${DEST_NDLL} diff --git a/libs/std/CMakeLists.txt b/libs/std/CMakeLists.txt index 49f83d70..5b4b44a7 100644 --- a/libs/std/CMakeLists.txt +++ b/libs/std/CMakeLists.txt @@ -39,6 +39,10 @@ set_target_properties(std.ndll SUFFIX .ndll ) +if (UNIX AND NOT APPLE) + target_link_options(std.ndll PRIVATE "-Wl,--no-undefined") +endif() + install ( TARGETS std.ndll DESTINATION ${DEST_NDLL} diff --git a/libs/ui/CMakeLists.txt b/libs/ui/CMakeLists.txt index e53b77c8..dd55c615 100644 --- a/libs/ui/CMakeLists.txt +++ b/libs/ui/CMakeLists.txt @@ -26,6 +26,10 @@ set_target_properties(ui.ndll SUFFIX .ndll ) +if (UNIX AND NOT APPLE) + target_link_options(ui.ndll PRIVATE "-Wl,--no-undefined") +endif() + install ( TARGETS ui.ndll DESTINATION ${DEST_NDLL} diff --git a/libs/zlib/CMakeLists.txt b/libs/zlib/CMakeLists.txt index 38a20bb1..600d1897 100644 --- a/libs/zlib/CMakeLists.txt +++ b/libs/zlib/CMakeLists.txt @@ -18,6 +18,10 @@ set_target_properties(zlib.ndll SUFFIX .ndll ) +if (UNIX AND NOT APPLE) + target_link_options(zlib.ndll PRIVATE "-Wl,--no-undefined") +endif() + install ( TARGETS zlib.ndll DESTINATION ${DEST_NDLL}