1 # Set common 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 macro(qbt_common_config)
6 # treat value specified by the CXX_STANDARD target property as a requirement by default
7 set(CMAKE_CXX_STANDARD_REQUIRED ON)
8 set(CMAKE_CXX_EXTENSIONS OFF)
10 add_library(qbt_common_cfg INTERFACE)
12 # Full C++ 17 support is required
13 # See also https://cmake.org/cmake/help/latest/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html
14 # for a breakdown of the features that CMake recognizes for each C++ standard
15 target_compile_features(qbt_common_cfg INTERFACE
19 target_compile_definitions(qbt_common_cfg INTERFACE
20 QT_DISABLE_DEPRECATED_BEFORE=0x050f02
23 QT_NO_CAST_FROM_BYTEARRAY
24 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
27 $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG_OUTPUT>
30 if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
31 target_compile_definitions(qbt_common_cfg INTERFACE
32 _DARWIN_FEATURE_64_BIT_INODE
36 if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
37 target_compile_definitions(qbt_common_cfg INTERFACE
38 NTDDI_VERSION=0x06010000
48 if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))
49 target_compile_options(qbt_common_cfg INTERFACE
62 # Clang 11 still doesn't support -Wstrict-null-sentinel
63 include(CheckCXXCompilerFlag)
64 check_cxx_compiler_flag(-Wstrict-null-sentinel SNS_SUPPORT)
66 target_compile_options(qbt_common_cfg INTERFACE -Wstrict-null-sentinel)
70 if ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))
71 target_compile_options(qbt_common_cfg INTERFACE
72 -Wno-range-loop-analysis
77 target_link_options(qbt_common_cfg INTERFACE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:LINKER:--dynamicbase>)
80 if (MSVC_RUNTIME_DYNAMIC)
81 set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
83 set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
87 target_compile_options(qbt_common_cfg INTERFACE
90 # https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
93 target_link_options(qbt_common_cfg INTERFACE
95 $<$<NOT:$<CONFIG:Debug>>:/OPT:REF /OPT:ICF>
96 # suppress linking warning due to /INCREMENTAL and /OPT:ICF being both ON
97 $<$<CONFIG:RelWithDebInfo>:/INCREMENTAL:NO>
101 if (LibtorrentRasterbar_VERSION VERSION_GREATER_EQUAL ${minLibtorrentVersion})
102 target_compile_definitions(qbt_common_cfg INTERFACE QBT_USES_LIBTORRENT2)
104 endmacro(qbt_common_config)