-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
131 lines (111 loc) · 4.08 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
cmake_minimum_required(VERSION 3.16)
project(jsontoolkit VERSION 2.0.0 LANGUAGES CXX
DESCRIPTION "The high-performance JSON Schema evaluator and related JSON utilities for modern C++"
HOMEPAGE_URL "https://jsontoolkit.sourcemeta.com")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(vendor/noa/cmake/noa.cmake)
# Options
option(JSONTOOLKIT_URI "Build the JSON Toolkit URI library" ON)
option(JSONTOOLKIT_JSON "Build the JSON Toolkit JSON library" ON)
option(JSONTOOLKIT_JSONSCHEMA "Build the JSON Toolkit JSON Schema library" ON)
option(JSONTOOLKIT_EVALUATOR "Build the JSON Toolkit JSON Schema evaluator library" ON)
option(JSONTOOLKIT_JSONPOINTER "Build the JSON Toolkit JSON Pointer library" ON)
option(JSONTOOLKIT_JSONL "Build the JSON Toolkit JSONL library" ON)
option(JSONTOOLKIT_TESTS "Build the JSON Toolkit tests" OFF)
option(JSONTOOLKIT_BENCHMARK "Build the JSON Toolkit benchmarks" OFF)
option(JSONTOOLKIT_DOCS "Build the JSON Toolkit docs" OFF)
option(JSONTOOLKIT_INSTALL "Install the JSON Toolkit library" ON)
option(JSONTOOLKIT_ADDRESS_SANITIZER "Build JSON Toolkit with an address sanitizer" OFF)
option(JSONTOOLKIT_UNDEFINED_SANITIZER "Build JSON Toolkit with an undefined behavior sanitizer" OFF)
if(JSONTOOLKIT_INSTALL)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
configure_package_config_file(
config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
COMPATIBILITY SameMajorVersion)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
COMPONENT sourcemeta_jsontoolkit_dev)
endif()
if(JSONTOOLKIT_URI)
find_package(UriParser REQUIRED)
add_subdirectory(src/uri)
endif()
if(JSONTOOLKIT_JSON)
add_subdirectory(src/json)
endif()
if(JSONTOOLKIT_JSON AND JSONTOOLKIT_JSONPOINTER)
add_subdirectory(src/jsonpointer)
endif()
if(JSONTOOLKIT_URI AND JSONTOOLKIT_JSON AND
JSONTOOLKIT_JSONPOINTER AND JSONTOOLKIT_EVALUATOR)
add_subdirectory(src/evaluator)
endif()
if(JSONTOOLKIT_URI AND JSONTOOLKIT_JSON AND
JSONTOOLKIT_JSONPOINTER AND JSONTOOLKIT_EVALUATOR AND
JSONTOOLKIT_JSONSCHEMA)
add_subdirectory(src/jsonschema)
endif()
if(JSONTOOLKIT_JSON AND JSONTOOLKIT_JSONL)
add_subdirectory(src/jsonl)
endif()
if(JSONTOOLKIT_ADDRESS_SANITIZER)
noa_sanitizer(TYPE address)
elseif(JSONTOOLKIT_UNDEFINED_SANITIZER)
noa_sanitizer(TYPE undefined)
endif()
if(JSONTOOLKIT_DOCS)
noa_target_doxygen(CONFIG "${PROJECT_SOURCE_DIR}/doxygen/Doxyfile.in"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/website")
endif()
if(PROJECT_IS_TOP_LEVEL)
noa_target_clang_format(SOURCES
src/*.h src/*.cc
benchmark/*.h benchmark/*.cc
test/*.h test/*.cc)
noa_target_clang_tidy(SOURCES
src/*.h src/*.cc)
endif()
# Testing
if(JSONTOOLKIT_TESTS)
find_package(GoogleTest REQUIRED)
enable_testing()
if(JSONTOOLKIT_URI)
add_subdirectory(test/uri)
endif()
if(JSONTOOLKIT_JSON)
add_subdirectory(test/json)
endif()
if(JSONTOOLKIT_JSON AND JSONTOOLKIT_JSONPOINTER)
add_subdirectory(test/jsonpointer)
endif()
if(JSONTOOLKIT_URI AND JSONTOOLKIT_JSON AND
JSONTOOLKIT_JSONPOINTER AND JSONTOOLKIT_EVALUATOR)
add_subdirectory(test/evaluator)
endif()
if(JSONTOOLKIT_URI AND JSONTOOLKIT_JSON AND
JSONTOOLKIT_JSONPOINTER AND JSONTOOLKIT_EVALUATOR AND
JSONTOOLKIT_JSONSCHEMA)
add_subdirectory(test/jsonschema)
endif()
if(JSONTOOLKIT_JSON AND JSONTOOLKIT_JSONL)
add_subdirectory(test/jsonl)
endif()
if(PROJECT_IS_TOP_LEVEL)
# Otherwise we need the child project to link
# against the sanitizers too.
if(NOT JSONTOOLKIT_ADDRESS_SANITIZER AND NOT JSONTOOLKIT_UNDEFINED_SANITIZER)
add_subdirectory(test/packaging)
endif()
endif()
if(JSONTOOLKIT_BENCHMARK)
find_package(GoogleBenchmark REQUIRED)
add_subdirectory(benchmark)
endif()
endif()