-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
92 lines (77 loc) · 2.31 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
cmake_minimum_required(VERSION 3.11)
project(jsonpp VERSION 0.1.0)
add_library(${PROJECT_NAME} STATIC)
set(CMAKE_CXX_STANDARD 11)
set(DEFAULT_PARSER_BACKEND "simdjson" CACHE STRING "Specify default ParserBackendType, the default value is simdjson.")
set_property(CACHE DEFAULT_PARSER_BACKEND PROPERTY STRINGS simdjson cparser)
add_definitions(-DJSONPP_DEFAULT_PARSER_BACKEND=${DEFAULT_PARSER_BACKEND})
include(FetchContent)
FetchContent_Declare(
metapp
GIT_REPOSITORY https://github.com/wqking/metapp.git
GIT_REMOTE_NAME origin/master
GIT_TAG 4c3a0bcf2f016948049cc4b51858fe28b1acda19
)
FetchContent_MakeAvailable(metapp)
target_link_libraries(${PROJECT_NAME} metapp::metapp)
target_include_directories(
${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
file(GLOB_RECURSE SRC_LIB "src/*.c*")
target_sources(${PROJECT_NAME}
PRIVATE
${SRC_LIB}
)
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
# Installation
# ------------
include(GNUInstallDirs)
# Install the library
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
# Install the headers
install(
DIRECTORY include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
# (Generate and) install the target import file
install(
EXPORT ${PROJECT_NAME}Targets
NAMESPACE jsonpp::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsonpp
)
# Generate the package version file
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/jsonppConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
# Generate the package configuration file, that allows other
# CMake projects to find the library with find_package()
configure_package_config_file(
cmake/jsonppConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/jsonppConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsonpp
)
# Install the package version and configuration files
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/jsonppConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/jsonppConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsonpp
)
# Install readme and license
install(
FILES
readme.md
license
DESTINATION ${CMAKE_INSTALL_DATADIR}/jsonpp
)