2020-05-04 02:28:07 +08:00
|
|
|
# Set common variables and create some interface-only library targets
|
|
|
|
# that some or all other targets will link to, either directly or transitively,
|
|
|
|
# to consume common compile options/definitions
|
|
|
|
|
|
|
|
macro(qbt_common_config)
|
|
|
|
|
|
|
|
# treat value specified by the CXX_STANDARD target property as a requirement by default
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
|
|
|
add_library(qbt_common_cfg INTERFACE)
|
|
|
|
|
2020-12-19 14:52:01 +08:00
|
|
|
# Full C++ 17 support is required
|
2020-05-04 02:28:07 +08:00
|
|
|
# See also https://cmake.org/cmake/help/latest/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html
|
|
|
|
# for a breakdown of the features that CMake recognizes for each C++ standard
|
|
|
|
target_compile_features(qbt_common_cfg INTERFACE
|
2020-12-19 14:52:01 +08:00
|
|
|
cxx_std_17
|
2020-05-04 02:28:07 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
target_compile_definitions(qbt_common_cfg INTERFACE
|
2021-07-09 12:43:43 +08:00
|
|
|
QT_DISABLE_DEPRECATED_BEFORE=0x050f02
|
2020-05-04 02:28:07 +08:00
|
|
|
QT_NO_CAST_TO_ASCII
|
|
|
|
QT_NO_CAST_FROM_BYTEARRAY
|
|
|
|
QT_USE_QSTRINGBUILDER
|
|
|
|
QT_STRICT_ITERATORS
|
|
|
|
$<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG_OUTPUT>
|
|
|
|
)
|
|
|
|
|
2021-11-02 10:41:09 +08:00
|
|
|
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
|
|
|
target_compile_definitions(qbt_common_cfg INTERFACE
|
|
|
|
_DARWIN_FEATURE_64_BIT_INODE
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2020-05-04 02:28:07 +08:00
|
|
|
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|
|
|
target_compile_definitions(qbt_common_cfg INTERFACE
|
|
|
|
NTDDI_VERSION=0x06010000
|
|
|
|
_WIN32_WINNT=0x0601
|
|
|
|
_WIN32_IE=0x0601
|
|
|
|
WIN32_LEAN_AND_MEAN
|
|
|
|
NOMINMAX
|
|
|
|
UNICODE
|
|
|
|
_UNICODE
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2021-05-21 00:21:13 +08:00
|
|
|
if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))
|
2020-05-04 02:28:07 +08:00
|
|
|
target_compile_options(qbt_common_cfg INTERFACE
|
|
|
|
-Wall
|
|
|
|
-Wextra
|
|
|
|
-Wcast-qual
|
|
|
|
-Wcast-align
|
|
|
|
-Winvalid-pch
|
|
|
|
-Woverloaded-virtual
|
|
|
|
-Wold-style-cast
|
|
|
|
-Wnon-virtual-dtor
|
|
|
|
-pedantic
|
|
|
|
-pedantic-errors
|
|
|
|
)
|
|
|
|
|
|
|
|
# Clang 11 still doesn't support -Wstrict-null-sentinel
|
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
check_cxx_compiler_flag(-Wstrict-null-sentinel SNS_SUPPORT)
|
|
|
|
if (SNS_SUPPORT)
|
|
|
|
target_compile_options(qbt_common_cfg INTERFACE -Wstrict-null-sentinel)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-05-21 00:21:13 +08:00
|
|
|
if ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))
|
2021-01-06 12:04:11 +08:00
|
|
|
target_compile_options(qbt_common_cfg INTERFACE
|
|
|
|
-Wno-range-loop-analysis
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2020-05-04 02:28:07 +08:00
|
|
|
if (MINGW)
|
|
|
|
target_link_options(qbt_common_cfg INTERFACE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:LINKER:--dynamicbase>)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (MSVC_RUNTIME_DYNAMIC)
|
|
|
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
|
|
|
else()
|
|
|
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
|
|
|
endif()
|
|
|
|
|
2020-09-20 17:00:50 +08:00
|
|
|
if (MSVC)
|
2021-01-06 11:53:28 +08:00
|
|
|
target_compile_options(qbt_common_cfg INTERFACE
|
|
|
|
/guard:cf
|
|
|
|
/utf-8
|
2021-05-27 11:57:22 +08:00
|
|
|
# https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
|
|
|
|
/Zc:__cplusplus
|
2021-01-06 11:53:28 +08:00
|
|
|
)
|
|
|
|
target_link_options(qbt_common_cfg INTERFACE
|
|
|
|
/guard:cf
|
2020-09-20 17:00:50 +08:00
|
|
|
$<$<NOT:$<CONFIG:Debug>>:/OPT:REF /OPT:ICF>
|
|
|
|
# suppress linking warning due to /INCREMENTAL and /OPT:ICF being both ON
|
|
|
|
$<$<CONFIG:RelWithDebInfo>:/INCREMENTAL:NO>
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2021-08-11 13:26:15 +08:00
|
|
|
if (LibtorrentRasterbar_VERSION VERSION_GREATER_EQUAL ${minLibtorrentVersion})
|
|
|
|
target_compile_definitions(qbt_common_cfg INTERFACE QBT_USES_LIBTORRENT2)
|
|
|
|
endif()
|
2020-05-04 02:28:07 +08:00
|
|
|
endmacro(qbt_common_config)
|