diff --git a/CMakeLists.txt b/CMakeLists.txt index 95bf9599b..b9ee2e4f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -433,11 +433,15 @@ if(USE_GCC OR USE_CLANG) list(APPEND EXTRA_CFLAGS "-Wshadow") endif() - set(CMAKE_REQUIRED_FLAGS "-Wl,--no-undefined") - check_c_compiler_flag("" HAVE_NO_UNDEFINED) - set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS}) - if(HAVE_NO_UNDEFINED) - list(APPEND EXTRA_LDFLAGS "-Wl,--no-undefined") + if(APPLE) + list(APPEND EXTRA_LDFLAGS "-Wl,-undefined,error") + else() + set(CMAKE_REQUIRED_FLAGS "-Wl,--no-undefined") + check_c_compiler_flag("" HAVE_NO_UNDEFINED) + set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS}) + if(HAVE_NO_UNDEFINED) + list(APPEND EXTRA_LDFLAGS "-Wl,--no-undefined") + endif() endif() endif()