-
Notifications
You must be signed in to change notification settings - Fork 62
/
CMakeLists.txt
82 lines (70 loc) · 2.21 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
cmake_minimum_required(VERSION 3.8)
if(DEFINED PROJECT_NAME)
set(SUBPROJECT ON)
endif()
project(qtpromise VERSION 0.7.0 LANGUAGES CXX)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
find_package(QT 5.6.0 NAMES Qt6 Qt5 REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_library(qtpromise INTERFACE)
add_library(qtpromise::qtpromise ALIAS qtpromise)
target_link_libraries(qtpromise INTERFACE Qt${QT_VERSION_MAJOR}::Core)
target_include_directories(qtpromise INTERFACE "${CMAKE_CURRENT_LIST_DIR}/include")
add_definitions(
-DQT_DEPRECATED_WARNINGS
-DQT_NO_KEYWORDS
)
# https://github.com/simonbrunel/qtpromise/issues/10
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
# https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
add_compile_options(
-Werror
-Wpedantic
-Wall
-Wextra
-Wconversion
-Wdouble-promotion
-Wformat=2
-Wlogical-op
-Wmissing-noreturn
-Wold-style-cast
# -Wshadow # disabled due to many findings in the current code
-Wsign-conversion
-Wswitch-default
-Wunused-local-typedefs
-pedantic-errors
)
# https://github.com/Barro/compiler-warnings/blob/master/gcc/warnings-gcc-6.txt
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6)
add_compile_options(
-Wduplicated-cond
)
endif()
# https://github.com/Barro/compiler-warnings/blob/master/gcc/warnings-gcc-7.txt
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 7)
add_compile_options(
-Wduplicated-branches
)
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# https://clang.llvm.org/docs/DiagnosticsReference.html
add_compile_options(
-Wall
-Wextra
-Wpedantic
-Wsuggest-destructor-override
-Wsuggest-override
)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
# https://docs.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level
add_compile_options(
/WX
)
endif()
if(NOT SUBPROJECT)
enable_testing()
add_subdirectory(tests)
endif()