-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
70 lines (55 loc) · 1.55 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
cmake_minimum_required(VERSION 3.25)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project(
"stk"
VERSION 0.2.1
LANGUAGES CXX
)
option(THIRD_PARTY_ONLY "If true, CMake would stop after making third party dependencies available.")
option(FAIL_ON_WARNINGS "Whether to treat compilation warnings as errors.")
option(BUILD_TESTS "Whether to include the test folder to the build.")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})
set(PROJECT_BINARY_DIR ${PROJECT_SOURCE_DIR}/build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
add_subdirectory(thirdparty)
if(THIRD_PARTY_ONLY)
return()
endif(THIRD_PARTY_ONLY)
add_compile_options(
-Wall
-Wextra
-pedantic
-Wno-missing-braces
)
if(FAIL_ON_WARNINGS)
add_compile_options(-Werror)
endif()
find_program(CPPCHECK cppcheck)
if(CPPCHECK)
set(CMAKE_CXX_CPPCHECK ${CPPCHECK})
list(APPEND CMAKE_CXX_CPPCHECK
"--enable=all"
"--inconclusive"
"--inline-suppr"
"--quiet"
"--suppress=*:${CMAKE_SOURCE_DIR}/test*"
"--suppress=*:${FETCHCONTENT_BASE_DIR}*"
"--suppressions-list=${CMAKE_SOURCE_DIR}/.cppcheck"
)
if(FAIL_ON_WARNINGS)
list(APPEND CMAKE_CXX_CPPCHECK
"--error-exitcode=1"
)
endif()
endif()
add_subdirectory(src)
if(BUILD_TESTS)
include(CTest)
add_subdirectory(test)
endif(BUILD_TESTS)