forked from sourcemeta/jsonbinpack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
86 lines (77 loc) · 2.64 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
cmake_minimum_required(VERSION 3.15)
project("JSON BinPack" 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.")
# Only allow Debug and Release builds
# Adapted from Professional CMake (https://crascit.com/professional-cmake/)
set(BUILD_TYPES Debug Release)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${BUILD_TYPES}")
# Set a sensible default instead of the ambiguous empty string
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE)
elseif(NOT CMAKE_BUILD_TYPE IN_LIST BUILD_TYPES)
message(FATAL_ERROR "Unknown build type: ${CMAKE_BUILD_TYPE}")
endif()
# Global options
add_compile_options(
-Wall
-Wextra
-Werror
-Wpedantic
-Wshadow
-Wdouble-promotion
-Wconversion
-Wunused-parameter
)
# Specify the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Hide symbols from shared libraries by default
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)
# Options
option(JSONBINPACK_CLI "Build the JSON BinPack CLI" ON)
option(JSONBINPACK_TESTS "Build the JSON BinPack tests" ON)
# Sources
add_subdirectory(src/jsontoolkit)
add_subdirectory(src/alterschema)
add_subdirectory(src/canonicalizer)
add_subdirectory(src/encoder)
add_subdirectory(src/decoder)
if(JSONBINPACK_CLI)
add_subdirectory(src/cli)
endif()
# Testing
if(JSONBINPACK_TESTS)
enable_testing()
set(BUILD_GMOCK OFF)
set(INSTALL_GTEST OFF)
include(GoogleTest)
add_subdirectory(vendor/googletest)
add_subdirectory(test/jsontoolkit)
add_subdirectory(test/alterschema)
add_subdirectory(test/canonicalizer)
add_subdirectory(test/encoder)
add_subdirectory(test/decoder)
if(JSONBINPACK_CLI)
add_subdirectory(test/cli)
endif()
endif()
# Only for top-level builds
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
file(GLOB_RECURSE JSONBINPACK_CXX_SOURCE_FILES src/*.cc src/*.h test/*.cc test/*.h)
file(GLOB_RECURSE JSONBINPACK_SH_SOURCE_FILES test/*.sh scripts/*.sh)
string(TOLOWER ${CMAKE_BUILD_TYPE} JSONBINPACK_BUILD_TYPE)
set(JSONBINPACK_WEBSITE_OUT ${PROJECT_SOURCE_DIR}/build/${JSONBINPACK_BUILD_TYPE}/www)
set(JSONBINPACK_WEBSITE_SRC ${PROJECT_SOURCE_DIR}/www)
include(${PROJECT_SOURCE_DIR}/cmake/clang-format.cmake)
include(${PROJECT_SOURCE_DIR}/cmake/clang-tidy.cmake)
include(${PROJECT_SOURCE_DIR}/cmake/bundler.cmake)
include(${PROJECT_SOURCE_DIR}/cmake/jekyll.cmake)
include(${PROJECT_SOURCE_DIR}/cmake/doxygen.cmake)
include(${PROJECT_SOURCE_DIR}/cmake/shellcheck.cmake)
# TODO: Define packaging
endif()