forked from GameDevTecnico/cubos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
106 lines (88 loc) · 3.45 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# CMakeLists.txt
# Cubos project root build configuration
cmake_minimum_required(VERSION 3.20.0)
project(cubos VERSION 0.1.0)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
set(CMAKE_CXX_STANDARD 20)
# Should clang-tidy errors be automatically fixed?
option(FIX_CLANG_TIDY_ERRORS "Automatically fix clang-tidy errors" OFF)
# Enable coverage reports
option(ENABLE_COVERAGE "Generate coverage report" OFF)
if(ENABLE_COVERAGE)
include(CodeCoverage)
append_coverage_compiler_flags()
setup_target_for_coverage_lcov(
NAME coverage
EXECUTABLE core/tests/cubos-core-tests
DEPENDENCIES cubos-core-tests
EXCLUDE "core/lib/*" "core/tests/*" "tools/quadrados" "*-components.cpp"
LCOV_ARGS "--no-external"
)
endif()
# Enable CCache
find_program(CCACHE_EXE NAMES "ccache")
if(CCACHE_EXE)
option(USE_CCACHE "Enable CCache" ON)
if(USE_CCACHE)
if (CMAKE_HOST_WIN32)
option(CCACHE_VERSION "Pinned CCache Version")
# find_program only finds Chocolatey's shim which is unable to be used with another name, the original executable must be used.
set(CCACHE_PATH C:/ProgramData/chocolatey/lib/ccache/tools/ccache-${CCACHE_VERSION}-windows-x86_64/ccache.exe)
file(COPY_FILE
${CCACHE_PATH} ${CMAKE_BINARY_DIR}/cl.exe
ONLY_IF_DIFFERENT)
set(CMAKE_VS_GLOBALS
"CLToolExe=cl.exe"
"CLToolPath=${CMAKE_BINARY_DIR}"
"TrackFileAccess=false"
"UseMultiToolTask=true"
"DebugInformationFormat=OldStyle"
)
else ()
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_EXE}")
endif()
endif()
endif()
# Function which configures a target with the options common to all CUBOS. targets.
function(cubos_common_target_options target)
# Enable all warnings and treat them as errors
target_compile_options(${target} PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:
/Zc:preprocessor # Enable preprocessor conformance mode - required for __VA_ARGS__ to work correctly
/W4
/WX
/wd4996 # Disable warning about deprecated functions
/wd4458 # Disable warning about shadowing member variables
/wd4456 # Disable warning about shadowing local variables
/wd4335 # Disable warning about Mac file format
/wd5030> # Introduces false positives for [[cubos::component]]
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:
-Wall
-Wextra
-pedantic
-Wconversion
-Werror
-Wno-attributes
-Wno-unknown-attributes> # Introduces false positives for [[cubos::component]]
)
# Enable clang-tidy
find_program(CLANG_TIDY_EXE NAMES "clang-tidy")
if(CLANG_TIDY_EXE)
option(USE_CLANG_TIDY "Enable clang-tidy" ON)
if(USE_CLANG_TIDY)
set(CLANG_TIDY_COMMAND "${CLANG_TIDY_EXE}")
if(FIX_CLANG_TIDY_ERRORS)
set(CLANG_TIDY_COMMAND "${CLANG_TIDY_COMMAND}" "-fix" "-fix-errors")
endif()
set_target_properties(${target} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
endif()
endif()
endfunction()
add_subdirectory(core)
add_subdirectory(tools)
add_subdirectory(engine)
# Add doxygen documentation
option(BUILD_DOCUMENTATION "Build docs" OFF)
if(BUILD_DOCUMENTATION)
add_subdirectory(docs)
endif()