From 806bfd6da07127c33d1014ef2335a8b9602afe6c Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Wed, 29 Dec 2021 18:17:38 +0100 Subject: CMakeLists.txt: apply -fvisibility=hidden Also, -fvisibility-inlines-hidden is applied in a CMake-native way now. As can be expected, BUILDING_SHARED_QUOTIENT is set when a dynamic library is built while QUOTIENT_STATIC is set whenever static libQuotient is around (both for building it and for building with it). --- CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fc47b42..45aa3726 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,7 @@ if (MSVC) /wd4710 /wd4774 /wd4820 /wd4946 /wd5026 /wd5027) else() foreach (FLAG Wall Wpedantic Wextra Werror=return-type Wno-unused-parameter - Wno-gnu-zero-variadic-macro-arguments fvisibility-inlines-hidden) + Wno-gnu-zero-variadic-macro-arguments) CHECK_CXX_COMPILER_FLAG("-${FLAG}" COMPILER_${FLAG}_SUPPORTED) if ( COMPILER_${FLAG}_SUPPORTED AND NOT CMAKE_CXX_FLAGS MATCHES "(^| )-?${FLAG}($| )") @@ -254,6 +254,12 @@ file(GLOB_RECURSE api_ALL_SRCS CONFIGURE_DEPENDS ${FULL_CSAPI_DIR}/*.* lib/${ASAPI_DEF_DIR}/*.* lib/${ISAPI_DEF_DIR}/*.*) add_library(${PROJECT_NAME} ${lib_SRCS} ${api_ALL_SRCS}) +# Set BUILDING_SHARED_QUOTIENT if building as a shared library +target_compile_definitions(${PROJECT_NAME} PRIVATE + $<$,SHARED_LIBRARY>:BUILDING_SHARED_QUOTIENT>) +# Set QUOTIENT_STATIC in a static library setting +target_compile_definitions(${PROJECT_NAME} PUBLIC + $<$,STATIC_LIBRARY>:QUOTIENT_STATIC>) target_compile_definitions(${PROJECT_NAME} PRIVATE QT_NO_JAVA_STYLE_ITERATORS QT_NO_URL_CAST_FROM_STRING QT_NO_CAST_TO_ASCII) target_compile_definitions(${PROJECT_NAME} PUBLIC ${PROJECT_NAME}_VERSION_MAJOR=${PROJECT_VERSION_MAJOR} @@ -265,6 +271,8 @@ endif() set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 20 CXX_EXTENSIONS OFF + VISIBILITY_INLINES_HIDDEN ON + CXX_VISIBILITY_PRESET hidden VERSION "${PROJECT_VERSION}" SOVERSION ${API_VERSION} INTERFACE_${PROJECT_NAME}_MAJOR_VERSION ${API_VERSION} -- cgit v1.2.3