-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
83 lines (74 loc) · 2.25 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
cmake_minimum_required(VERSION 3.11)
project(
seria
VERSION 0.1.0
LANGUAGES CXX C
)
set(MASTER_PROJECT OFF)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(MASTER_PROJECT ON)
endif ()
option(SERIA_USE_EXTERNAL_RAPIDJSON "use external rapidjson" OFF)
option(SERIA_ENABLE_MPACK "enable mpack(msgpack) support" ON)
option(SERIA_USE_EXTERNAL_MPACK "use external mpack" OFF)
option(SERIA_BUILD_TESTS "whether to build tests" ${MASTER_PROJECT})
option(SERIA_INSTALL "whether to install seria" ${MASTER_PROJECT})
option(FETCHCONTENT_QUIET "" OFF)
if (UNIX)
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address -fsanitize=leak -fsanitize=undefined")
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fsanitize=address -fsanitize=leak -fsanitize=undefined")
endif ()
if (SERIA_ENABLE_MPACK AND NOT SERIA_USE_EXTERNAL_MPACK)
include(${PROJECT_SOURCE_DIR}/third_party/mpack.cmake)
endif ()
add_library(seria INTERFACE)
add_library(seria::seria ALIAS seria)
target_include_directories(
seria
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_compile_features(seria INTERFACE cxx_std_14)
if (SERIA_USE_EXTERNAL_RAPIDJSON)
target_compile_definitions(seria INTERFACE SERIA_USE_EXTERNAL_RAPIDJSON)
endif ()
if (SERIA_BUILD_TESTS)
add_subdirectory(tests)
endif ()
if (SERIA_INSTALL)
install(
TARGETS seria
EXPORT seria-targets
)
install(
DIRECTORY
${PROJECT_SOURCE_DIR}/include/seria
${PROJECT_SOURCE_DIR}/include/rapidjson
DESTINATION include
)
install(
EXPORT seria-targets
FILE seria-targets.cmake
NAMESPACE seria::
DESTINATION lib/cmake/seria
)
include(CMakePackageConfigHelpers)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/seria-config.cmake"
INSTALL_DESTINATION "lib/cmake/seria"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/seria-config.cmake
DESTINATION lib/cmake/seria
)
export(
EXPORT seria-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/seria-targets.cmake"
)
endif ()