-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
107 lines (91 loc) · 3.1 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
cmake_minimum_required(VERSION 3.24)
project(jsonbinpack VERSION 0.0.1 LANGUAGES CXX
DESCRIPTION "\
A space-efficient open-source binary JSON serialization \
format based on JSON Schema with \
both schema-driven and schema-less support."
HOMEPAGE_URL "https://jsonbinpack.sourcemeta.com")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(vendor/noa/cmake/noa.cmake)
# Options
option(JSONBINPACK_NUMERIC "Build the JSON BinPack numeric library" ON)
option(JSONBINPACK_RUNTIME "Build the JSON BinPack runtime" ON)
option(JSONBINPACK_COMPILER "Build the JSON BinPack compiler" ON)
option(JSONBINPACK_TESTS "Build the JSON BinPack tests" OFF)
option(JSONBINPACK_INSTALL "Install the JSON BinPack library" ON)
option(JSONBINPACK_WEBSITE "Build the JSON BinPack website" OFF)
option(JSONBINPACK_DOCS "Build the JSON BinPack documentation" OFF)
option(JSONBINPACK_ADDRESS_SANITIZER "Build JSON BinPack with an address sanitizer" OFF)
option(JSONBINPACK_UNDEFINED_SANITIZER "Build JSON BinPack with an undefined behavior sanitizer" OFF)
if(JSONBINPACK_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_jsonbinpack_dev)
endif()
# Dependencies
find_package(JSONToolkit REQUIRED)
find_package(AlterSchema REQUIRED)
# Numeric
if(JSONBINPACK_NUMERIC)
add_subdirectory(src/numeric)
endif()
# Runtime
if(JSONBINPACK_RUNTIME)
add_subdirectory(src/runtime)
endif()
# Compiler
if(JSONBINPACK_COMPILER)
add_subdirectory(src/compiler)
endif()
if(JSONBINPACK_ADDRESS_SANITIZER)
noa_sanitizer(TYPE address)
elseif(JSONBINPACK_UNDEFINED_SANITIZER)
noa_sanitizer(TYPE undefined)
endif()
if(JSONBINPACK_WEBSITE)
add_subdirectory(www)
endif()
if(JSONBINPACK_DOCS)
noa_target_doxygen(CONFIG "${PROJECT_SOURCE_DIR}/doxygen/Doxyfile.in"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/www/api")
endif()
if(PROJECT_IS_TOP_LEVEL)
noa_target_clang_format(SOURCES
src/*.h src/*.cc
test/*.h test/*.cc)
noa_target_clang_tidy(SOURCES
src/*.h src/*.cc)
endif()
# Testing
if(JSONBINPACK_TESTS)
find_package(GoogleTest REQUIRED)
enable_testing()
if(JSONBINPACK_NUMERIC)
add_subdirectory(test/numeric)
endif()
if(JSONBINPACK_RUNTIME)
add_subdirectory(test/runtime)
endif()
if(JSONBINPACK_COMPILER)
add_subdirectory(test/compiler)
endif()
add_subdirectory(test/e2e)
if(PROJECT_IS_TOP_LEVEL)
# Otherwise we need the child project to link
# against the sanitizers too.
if(NOT JSONBINPACK_ADDRESS_SANITIZER AND NOT JSONBINPACK_UNDEFINED_SANITIZER)
add_subdirectory(test/packaging)
endif()
endif()
endif()