From d060974a370ce8559735040ee58b4c20ef92c676 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Sat, 12 Aug 2023 18:43:29 +0200 Subject: [PATCH] CMakeLists: apply common properties to the entire source tree Instead of setting visibility flags and (some) Qt feature macros individually on Quotient target, this commit applies the same set of flags to both the library and all tests for it. Ideally, visibility flags would be propagated to the client code (using different visibility while compiling the same header files can lead to surprises); unfortunately, CMake doesn't seem to have a way to do that (build properties can't be set to PUBLIC/PRIVATE/INTERFACE), so client code has to replicate the same settings explicitly. --- CMakeLists.txt | 29 ++++++++++++----------------- quotest/CMakeLists.txt | 5 ----- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1bde998d2..93e66b7b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,18 @@ else() add_compile_options(-fno-exceptions) endif() +add_compile_definitions( + QT_NO_JAVA_STYLE_ITERATORS QT_NO_URL_CAST_FROM_STRING QT_NO_CAST_TO_ASCII + QT_NO_CAST_FROM_ASCII QT_STRICT_ITERATORS QT_NO_CAST_FROM_BYTEARRAY + QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_FOREACH) + +set_directory_properties(PROPERTIES + CXX_STANDARD 20 + CXX_EXTENSIONS OFF + VISIBILITY_INLINES_HIDDEN ON + CXX_VISIBILITY_PRESET hidden +) + option(BUILD_WITH_QT6 "Build Quotient with Qt 6 (EXPERIMENTAL)" OFF) if (BUILD_WITH_QT6) set(QUOTIENT_LIB_NAME ${PROJECT_NAME}Qt6) @@ -269,15 +281,6 @@ add_feature_info(EnableApiCodeGeneration "${API_GENERATION_ENABLED}" file(GLOB_RECURSE api_ALL_SRCS CONFIGURE_DEPENDS ${FULL_CSAPI_DIR}/*.* Quotient/${ASAPI_DEF_DIR}/*.* Quotient/${ISAPI_DEF_DIR}/*.*) -add_compile_options( - -DQT_NO_CAST_TO_ASCII - -DQT_NO_CAST_FROM_ASCII - -DQT_NO_URL_CAST_FROM_STRING - -DQT_NO_CAST_FROM_BYTEARRAY - -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT - -DQT_NO_FOREACH -) - add_library(${QUOTIENT_LIB_NAME} ${lib_SRCS} ${api_ALL_SRCS}) # Set BUILDING_SHARED_QUOTIENT if building as a shared library target_compile_definitions(${QUOTIENT_LIB_NAME} PRIVATE @@ -285,10 +288,6 @@ target_compile_definitions(${QUOTIENT_LIB_NAME} PRIVATE # Set QUOTIENT_STATIC in a static library setting target_compile_definitions(${QUOTIENT_LIB_NAME} PUBLIC $<$,STATIC_LIBRARY>:QUOTIENT_STATIC>) -target_compile_definitions(${QUOTIENT_LIB_NAME} PRIVATE - QT_NO_JAVA_STYLE_ITERATORS QT_NO_URL_CAST_FROM_STRING QT_NO_CAST_TO_ASCII - QT_STRICT_ITERATORS QT_NO_CAST_FROM_BYTEARRAY) - target_compile_definitions(${QUOTIENT_LIB_NAME} PUBLIC ${PROJECT_NAME}_VERSION_MAJOR=${PROJECT_VERSION_MAJOR} ${PROJECT_NAME}_VERSION_MINOR=${PROJECT_VERSION_MINOR} ${PROJECT_NAME}_VERSION_PATCH=${PROJECT_VERSION_PATCH} ${PROJECT_NAME}_VERSION_STRING=\"${PROJECT_VERSION}\") @@ -296,10 +295,6 @@ if (${PROJECT_NAME}_ENABLE_E2EE) target_compile_definitions(${QUOTIENT_LIB_NAME} PUBLIC ${PROJECT_NAME}_E2EE_ENABLED) endif() set_target_properties(${QUOTIENT_LIB_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} diff --git a/quotest/CMakeLists.txt b/quotest/CMakeLists.txt index 56d63b845..ac5cd681f 100644 --- a/quotest/CMakeLists.txt +++ b/quotest/CMakeLists.txt @@ -8,11 +8,6 @@ find_package(${Qt} COMPONENTS Concurrent) add_executable(quotest ${quotest_SRCS}) target_link_libraries(quotest PRIVATE ${Qt}::Core ${Qt}::Test ${Qt}::Concurrent ${QUOTIENT_LIB_NAME}) -set_target_properties(quotest PROPERTIES - VISIBILITY_INLINES_HIDDEN ON - CXX_VISIBILITY_PRESET hidden -) - if (MSVC) target_compile_options(quotest PUBLIC /EHsc /W4 /wd4100 /wd4127 /wd4242 /wd4244 /wd4245 /wd4267 /wd4365 /wd4456 /wd4459