cmake: Fix building for macOS with Xcode generator (thanks, dungaipara!).

Fixes Bugzilla #3625.
Ryan C. Gordon 2017-08-18 18:52:25 -04:00
parent e3e6b4fd35
commit f75caa2ff6
1 changed files with 9 additions and 5 deletions

View File

@ -433,6 +433,9 @@ if(USE_GCC OR USE_CLANG)
list(APPEND EXTRA_CFLAGS "-Wshadow") list(APPEND EXTRA_CFLAGS "-Wshadow")
endif() endif()
if(APPLE)
list(APPEND EXTRA_LDFLAGS "-Wl,-undefined,error")
else()
set(CMAKE_REQUIRED_FLAGS "-Wl,--no-undefined") set(CMAKE_REQUIRED_FLAGS "-Wl,--no-undefined")
check_c_compiler_flag("" HAVE_NO_UNDEFINED) check_c_compiler_flag("" HAVE_NO_UNDEFINED)
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS}) set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
@ -440,6 +443,7 @@ if(USE_GCC OR USE_CLANG)
list(APPEND EXTRA_LDFLAGS "-Wl,--no-undefined") list(APPEND EXTRA_LDFLAGS "-Wl,--no-undefined")
endif() endif()
endif() endif()
endif()
if(ASSEMBLY) if(ASSEMBLY)
if(USE_GCC OR USE_CLANG) if(USE_GCC OR USE_CLANG)