-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
82 lines (64 loc) · 2.37 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.19)
INCLUDE(cmake/Conan.cmake)
# Set the project name to your project name, my project isn't very descriptive
PROJECT(ntc-compile-time CXX)
SET(CMAKE_BUILD_PARALLEL_LEVEL 8)
IF(NOT DEFINED CXX_STANDARD)
SET(CMAKE_CXX_STANDARD 20)
ELSE()
SET(CMAKE_CXX_STANDARD ${CXX_STANDARD})
ENDIF()
MESSAGE("Using C++ standard ${CMAKE_CXX_STANDARD}")
INCLUDE(cmake/StandardProjectSettings.cmake)
INCLUDE(cmake/PreventInSourceBuilds.cmake)
# Link this 'library' to set the c++ standard / compile-time options requested
ADD_LIBRARY(project_options INTERFACE)
TARGET_COMPILE_FEATURES(project_options INTERFACE cxx_std_${CMAKE_CXX_STANDARD})
IF(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
OPTION(ENABLE_BUILD_WITH_TIME_TRACE "Enable -ftime-trace to generate time tracing .json files on clang" OFF)
IF(ENABLE_BUILD_WITH_TIME_TRACE)
TARGET_COMPILE_OPTIONS(project_options INTERFACE -ftime-trace)
ENDIF()
ENDIF()
# Link this 'library' to use the warnings specified in CompilerWarnings.cmake
ADD_LIBRARY(project_warnings INTERFACE)
# enable cache system
INCLUDE(cmake/Cache.cmake)
# standard compiler warnings
INCLUDE(cmake/CompilerWarnings.cmake)
SET_PROJECT_WARNINGS(project_warnings)
# sanitizer options if supported by compiler
INCLUDE(cmake/Sanitizers.cmake)
ENABLE_SANITIZERS(project_options)
# enable doxygen
INCLUDE(cmake/Doxygen.cmake)
ENABLE_DOXYGEN()
# allow for static analysis options
INCLUDE(cmake/StaticAnalyzers.cmake)
OPTION(BUILD_SHARED_LIBS "Enable compilation of shared libraries" OFF)
OPTION(ENABLE_TESTING "Enable Test Builds" ON)
# Very basic PCH example
OPTION(ENABLE_PCH "Enable Precompiled Headers" OFF)
IF(ENABLE_PCH)
# This sets a global PCH parameter, each project will build its own PCH, which is a good idea if any #define's change
#
# consider breaking this out per project as necessary
TARGET_PRECOMPILE_HEADERS(
project_options
INTERFACE
<vector>
<utility>)
ENDIF()
FIND_PACKAGE(fmt REQUIRED)
FIND_PACKAGE(Catch2 REQUIRED)
IF(ENABLE_TESTING)
ENABLE_TESTING()
MESSAGE("Building Tests.")
ADD_SUBDIRECTORY(test)
ENDIF()
ADD_SUBDIRECTORY(source)
OPTION(ENABLE_UNITY "Enable Unity builds of projects" OFF)
IF(ENABLE_UNITY)
# Add for any project you want to apply unity builds for
SET_TARGET_PROPERTIES(TypeRegisterExample PROPERTIES UNITY_BUILD ON)
ENDIF()