1 # Set platform variables and create some interface-only library targets
2 # that some or all other targets will link to, either directly or transitively,
3 # to consume common compile options/definitions
5 # treat value specified by the CXX_STANDARD target property as a requirement by default
6 set(CMAKE_CXX_STANDARD_REQUIRED ON)
7 set(CMAKE_CXX_EXTENSIONS OFF)
11 set(CMAKE_AUTORCC_OPTIONS --compress 9 --threshold 5)
13 add_library(qbt_common_cfg INTERFACE)
15 # Full C++ 20 support is required
16 # See also https://cmake.org/cmake/help/latest/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html
17 # for a breakdown of the features that CMake recognizes for each C++ standard
18 target_compile_features(qbt_common_cfg INTERFACE
22 target_compile_definitions(qbt_common_cfg INTERFACE
23 QT_DISABLE_DEPRECATED_BEFORE=0x050f02
26 QT_NO_CAST_FROM_BYTEARRAY
27 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
30 $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG_OUTPUT>
33 if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
34 target_compile_definitions(qbt_common_cfg INTERFACE
35 _DARWIN_FEATURE_64_BIT_INODE
39 if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
40 target_compile_definitions(qbt_common_cfg INTERFACE
41 NTDDI_VERSION=0x06010000
51 if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))
52 target_compile_options(qbt_common_cfg INTERFACE
65 # Clang 11 still doesn't support -Wstrict-null-sentinel
66 include(CheckCXXCompilerFlag)
67 check_cxx_compiler_flag(-Wstrict-null-sentinel SNS_SUPPORT)
69 target_compile_options(qbt_common_cfg INTERFACE -Wstrict-null-sentinel)
73 if ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))
74 target_compile_options(qbt_common_cfg INTERFACE
75 -Wno-range-loop-analysis
80 target_link_options(qbt_common_cfg INTERFACE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:LINKER:--dynamicbase>)
84 target_compile_options(qbt_common_cfg INTERFACE
87 # https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
90 target_link_options(qbt_common_cfg INTERFACE
92 $<$<NOT:$<CONFIG:Debug>>:/OPT:REF /OPT:ICF>
93 # suppress linking warning due to /INCREMENTAL and /OPT:ICF being both ON
94 $<$<CONFIG:RelWithDebInfo>:/INCREMENTAL:NO>
97 if (MSVC_RUNTIME_DYNAMIC)
98 set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
100 set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
105 target_compile_definitions(qbt_common_cfg INTERFACE QBT_USES_DBUS)
108 if (LibtorrentRasterbar_VERSION VERSION_GREATER_EQUAL ${minLibtorrentVersion})
109 target_compile_definitions(qbt_common_cfg INTERFACE QBT_USES_LIBTORRENT2)