From bfed3797a0c33abdf396dd19007f9f640535ac56 Mon Sep 17 00:00:00 2001 From: evpobr Date: Sat, 27 Oct 2018 05:26:53 +0500 Subject: [PATCH] Improve CMake VISIBILITY_HIDDEN option handling (#810) Use standard CMake's CXX_VISIBILITY_PRESET property. --- CMakeLists.txt | 4 ---- bindings/c/CMakeLists.txt | 9 ++++++++- taglib/CMakeLists.txt | 5 +++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e081ea2..2de06324 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,10 +36,6 @@ if(ENABLE_CCACHE) endif() option(VISIBILITY_HIDDEN "Build with -fvisibility=hidden" OFF) -if(VISIBILITY_HIDDEN) - add_definitions(-fvisibility=hidden) -endif() - option(BUILD_TESTS "Build the test suite" OFF) option(BUILD_EXAMPLES "Build the examples" OFF) option(BUILD_BINDINGS "Build the bindings" ON) diff --git a/bindings/c/CMakeLists.txt b/bindings/c/CMakeLists.txt index 387f1bd1..ebb1267f 100644 --- a/bindings/c/CMakeLists.txt +++ b/bindings/c/CMakeLists.txt @@ -21,7 +21,14 @@ set(tag_c_HDRS tag_c.h) add_library(tag_c tag_c.cpp ${tag_c_HDRS}) target_link_libraries(tag_c tag) -set_target_properties(tag_c PROPERTIES PUBLIC_HEADER "${tag_c_HDRS}") +set_target_properties(tag_c PROPERTIES + PUBLIC_HEADER "${tag_c_HDRS}" + DEFINE_SYMBOL MAKE_TAGLIB_LIB +) +if(VISIBILITY_HIDDEN) + set_target_properties(tag_c PROPERTIES C_VISIBILITY_PRESET hidden + ) +endif() if(BUILD_FRAMEWORK) set_target_properties(tag_c PROPERTIES FRAMEWORK TRUE) endif() diff --git a/taglib/CMakeLists.txt b/taglib/CMakeLists.txt index 25041d25..64939071 100644 --- a/taglib/CMakeLists.txt +++ b/taglib/CMakeLists.txt @@ -347,6 +347,11 @@ set_target_properties(tag PROPERTIES LINK_INTERFACE_LIBRARIES "" PUBLIC_HEADER "${tag_HDRS}" ) +if(VISIBILITY_HIDDEN) + set_target_properties(tag PROPERTIES C_VISIBILITY_PRESET hidden + ) +endif() + if(BUILD_FRAMEWORK) unset(INSTALL_NAME_DIR) set_target_properties(tag PROPERTIES -- 2.40.0