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-algo best --threshold 5)
13 add_library(qbt_common_cfg INTERFACE)
15 # 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_UP_TO=0x060500
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=0x0A000006
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
88 # https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
91 target_link_options(qbt_common_cfg INTERFACE
93 $<$<NOT:$<CONFIG:Debug>>:/OPT:REF /OPT:ICF>
94 # suppress linking warning due to /INCREMENTAL and /OPT:ICF being both ON
95 $<$<CONFIG:RelWithDebInfo>:/INCREMENTAL:NO>
98 if (MSVC_RUNTIME_DYNAMIC)
99 set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
101 set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
106 target_compile_definitions(qbt_common_cfg INTERFACE QBT_USES_DBUS)
109 if (LibtorrentRasterbar_VERSION VERSION_GREATER_EQUAL ${minLibtorrentVersion})
110 target_compile_definitions(qbt_common_cfg INTERFACE QBT_USES_LIBTORRENT2)