-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
80 lines (69 loc) · 2.23 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
cmake_minimum_required(VERSION 3.20)
project("NcCommon"
VERSION "1.1.0"
LANGUAGES CXX C
)
option(NC_COMMON_BUILD_TESTS "Enable building tests." OFF)
option(NC_COMMON_STATIC_ANALYSIS "Enable static analysis (MSVC Only)" OFF)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_DEBUG_POSTFIX d)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(NC_COMMON_COMPILE_OPTIONS
-Werror
-Wall
-Wextra
-Wshadow
-Wconversion
-Wfatal-errors
-Wno-cast-function-type
)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(NC_COMMON_COMPILE_OPTIONS
/W4
/WX
/MP
)
if(${NC_COMMON_STATIC_ANALYSIS})
set(NC_COMMON_COMPILE_OPTIONS
${NC_COMMON_COMPILE_OPTIONS}
/analyze
/analyze:external-
/external:I${PROJECT_BINARY_DIR}/_deps
/wd6326 # Suppress 'potential comparison of constants'
)
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(NC_COMMON_COMPILE_OPTIONS
-Werror
-Wall
-Wextra
-Wshadow
-Wconversion
-fexperimental-library
)
endif()
include(FetchContent)
FetchContent_Declare(DirectXMath
GIT_REPOSITORY https://github.com/NcStudios/DirectXMath.git
GIT_TAG v3.1.6+nc.1
GIT_SHALLOW TRUE
)
# We only need {fmt} because GCC hasn't implemented std::format yet. Can be removed eventually.
set(FMT_INSTALL ON)
FetchContent_Declare(fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG 10.1.1
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(DirectXMath fmt)
# Silence warnings from DirectXMath
get_target_property(_DirectXMath_Include_Prop DirectXMath INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(DirectXMath SYSTEM INTERFACE ${_DirectXMath_Include_Prop})
# Silence warnings from fmt
get_target_property(_fmt_Include_Prop fmt INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(fmt SYSTEM INTERFACE ${_fmt_Include_Prop})
add_subdirectory(source)
if(NC_COMMON_BUILD_TESTS)
add_subdirectory(test)
endif()