build: use --no-undefined if available

This commit is contained in:
Bernhard Miklautz
2016-04-07 14:35:57 +02:00
parent a0d9969a30
commit 8fe88acbf3

View File

@@ -193,6 +193,21 @@ if(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
endif()
if (DEFINED CMAKE_REQUIRED_FLAGS)
set(SAVE_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
endif()
set(CMAKE_REQUIRED_FLAGS "-Wl,--no-undefined")
CHECK_C_COMPILER_FLAG (-Wl,--no-undefined no-undefined)
if (DEFINED SAVE_CMAKE_REQUIRED_FLAGS)
set(CMAKE_REQUIRED_FLAGS ${SAVE_CMAKE_REQUIRED_FLAGS})
unset(SAVE_CMAKE_REQUIRED_FLAGS)
else()
unset(CMAKE_REQUIRED_FLAGS)
endif()
if(no-undefined)
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined" )
endif()
if(NOT EXPORT_ALL_SYMBOLS)
message(STATUS "GCC default symbol visibility: hidden")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")