From 805e1aa819ab746bc65c6c856880f5d9cf4ae56d Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Mon, 13 Mar 2017 15:49:11 +0300 Subject: [PATCH] cmake: support visibility for AppleClang too Defaults apple linker behaviour is -two_levelnamespace, and you cannot use "-undefined suppress" with it, so let's link non event_core with event_core library to avoid undefined symbols. --- CMakeLists.txt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d92d38da..275c8e99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -774,7 +774,9 @@ source_group("Source Extra" FILES ${SRC_EXTRA}) # (Place them in the build dir so we don't polute the source tree with generated files). include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/include) -if ((CMAKE_COMPILER_IS_GNUCC) OR (${CMAKE_C_COMPILER_ID} STREQUAL "Clang")) +if ((CMAKE_COMPILER_IS_GNUCC) OR + (${CMAKE_C_COMPILER_ID} STREQUAL "Clang") OR + (${CMAKE_C_COMPILER_ID} STREQUAL "AppleClang")) set(EVENT_SHARED_FLAGS -fvisibility=hidden) elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "SunPro") set(EVENT_SHARED_FLAGS -xldscope=hidden) @@ -794,17 +796,21 @@ configure_file( # include(AddEventLibrary) add_event_library(event_core SOURCES ${SRC_CORE}) -add_event_library(event_extra SOURCES ${SRC_EXTRA}) +add_event_library(event_extra + LIBRARIES event_core_shared + SOURCES ${SRC_EXTRA}) if (NOT EVENT__DISABLE_OPENSSL) add_event_library(event_openssl - LIBRARIES ${OPENSSL_LIBRARIES} + LIBRARIES event_core_shared ${OPENSSL_LIBRARIES} SOURCES ${SRC_OPENSSL}) endif() if (CMAKE_USE_PTHREADS_INIT) set(SRC_PTHREADS evthread_pthread.c) - add_event_library(event_pthreads SOURCES ${SRC_PTHREADS}) + add_event_library(event_pthreads + LIBRARIES event_core_shared + SOURCES ${SRC_PTHREADS}) endif() # library exists for historical reasons; it contains the contents of -- 2.50.1