-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
70 lines (54 loc) · 2.3 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.16)
PROJECT(crc_cpp CXX)
SET(CMAKE_BUILD_PARALLEL_LEVEL 4)
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)
FIND_PACKAGE(Python COMPONENTS Interpreter REQUIRED)
# install PyPI Python packages using pip
# Can't update to conan2 yet, not supported by clion or Conan.cmake, so force to 1.x
# NOTE: also change .github/build_cmake.yml windows build process when fixed.
EXECUTE_PROCESS(COMMAND ${Python_EXECUTABLE} -m pip install --user --upgrade pip setuptools jinja2 conan~=1.0)
# 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)
# 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)
# Set up some extra Conan dependencies based on our needs before loading Conan
SET(CONAN_EXTRA_REQUIRES "")
SET(CONAN_EXTRA_OPTIONS "")
INCLUDE(cmake/Conan.cmake)
RUN_CONAN()
IF(ENABLE_TESTING)
ENABLE_TESTING()
MESSAGE("Building Tests. Be sure to check out test/constexpr_tests for constexpr testing")
ADD_SUBDIRECTORY(test)
ENDIF()
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()