-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
85 lines (66 loc) · 2.41 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
#
# Copyright Soramitsu Co., 2021-2023
# Copyright Quadrivium Co., 2023
# All Rights Reserved
# SPDX-License-Identifier: Apache-2.0
#
cmake_minimum_required(VERSION 3.12)
include("cmake/Hunter/init.cmake")
cmake_policy(SET CMP0048 NEW)
project(soralog VERSION 0.2.2 LANGUAGES CXX)
find_program(CCACHE_FOUND ccache)
if (CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif (CCACHE_FOUND)
include(cmake/functions.cmake)
include(cmake/toolchain/compiler.cmake)
if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
if (MAX_SUPPORTED_CXX_STANDARD GREATER_EQUAL 20)
set(CMAKE_TOOLCHAIN_FILE
"${CMAKE_SOURCE_DIR}/cmake/toolchain/cxx20.cmake"
CACHE FILEPATH "Default toolchain"
)
else ()
set(CMAKE_TOOLCHAIN_FILE
"${CMAKE_SOURCE_DIR}/cmake/toolchain/cxx17.cmake"
CACHE FILEPATH "Default toolchain"
)
endif ()
endif ()
print("Toolchain: ${CMAKE_TOOLCHAIN_FILE}")
include(${CMAKE_TOOLCHAIN_FILE})
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(TESTING "Build tests" ON)
option(EXAMPLES "Build examples" ON)
option(CLANG_FORMAT "Enable clang-format target" OFF)
option(CLANG_TIDY "Enable clang-tidy checks during compilation" OFF)
option(COVERAGE "Enable generation of coverage info" OFF)
# Sanitizers enables only for this project, and will be disabled for dependencies
option(ASAN "Enable address sanitizer" OFF)
option(LSAN "Enable leak sanitizer" OFF)
option(MSAN "Enable memory sanitizer" OFF)
option(TSAN "Enable thread sanitizer" OFF)
option(UBSAN "Enable UB sanitizer" OFF)
# the property is out of "if TESTING" scope due to addtest func is out too
set_property(GLOBAL PROPERTY TEST_TARGETS)
include(cmake/dependencies.cmake)
include(cmake/sanitizers.cmake)
if(CLANG_TIDY)
# Must be included before creating any target
include(cmake/clang-tidy.cmake)
endif()
if(CLANG_FORMAT)
include(cmake/clang-format.cmake)
endif()
add_subdirectory(src)
if(TESTING OR COVERAGE)
enable_testing()
add_subdirectory(test)
endif()
if(EXAMPLES)
add_subdirectory(example)
endif()
if (COVERAGE)
include(cmake/coverage.cmake)
endif ()