forked from germanespinosa/json-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
106 lines (83 loc) · 2.97 KB
/
CMakeLists.txt
File metadata and controls
106 lines (83 loc) · 2.97 KB
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
cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 20)
project(json-cpp
VERSION 2019.1.0
DESCRIPTION "Json c++ library"
LANGUAGES CXX)
####
#### DEPENDENCIES
####
find_package (Dependencies QUIET)
if (NOT ${Dependencies_FOUND})
if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/DependenciesConfig.cmake)
file(DOWNLOAD https://raw.githubusercontent.com/germanespinosa/dependencies/main/DependenciesConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/DependenciesConfig.cmake)
endif()
set(Dependencies_DIR "${CMAKE_CURRENT_BINARY_DIR}")
find_package (Dependencies REQUIRED)
endif()
####
#### END DEPENDENCIES
####
if ("${BUILD_PYTHON_MODULE_ONLY}" STREQUAL "")
set (BUILD_PYTHON_MODULE_ONLY FALSE CACHE STRING "Builds only the python module")
endif()
set (json_cpp_core_files
src/json_base.cpp
src/json_base64.cpp
src/json_buffer.cpp
src/json_util.cpp
src/json_builder.cpp
src/json_object.cpp
)
include_directories(include)
install_git_dependency( Catch
https://github.com/cellworld/dependency_catch
ADD_SUBDIRECTORY)
if (NOT ${BUILD_PYTHON_MODULE_ONLY})
set (json_cpp_files
${json_cpp_core_files}
src/json_date.cpp
src/json_dictionary.cpp
)
install_git_dependency( Date
https://github.com/cellworld/dependency_date
INCLUDE_DIRECTORIES include )
add_library(json-cpp ${json_cpp_files})
target_include_directories(json-cpp
SYSTEM INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
set_target_properties( json-cpp
PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED On
CXX_EXTENSIONS Off
VERSION ${PROJECT_VERSION})
target_compile_options(json-cpp PRIVATE -Wextra -pedantic -Wall -fPIC)
###
### TESTS
###
add_catch_test( json-cpp_tests
TEST_FILES
catchtests/json_tests.cpp
LINK_LIBRARIES json-cpp
INCLUDE_DIRECTORIES
include
${Date_Folder}/include)
if (NOT ${BUILD_AS_DEPENDENCY})
###
### LIBRARY INSTALLATION
###
export(TARGETS json-cpp FILE JsonCppConfig.cmake)
include(GNUInstallDirs)
install(TARGETS json-cpp EXPORT Json-cppConfig
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(EXPORT Json-cppConfig
DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/Json-cpp
EXPORT_LINK_INTERFACE_LIBRARIES)
export(TARGETS json-cpp FILE Json-cppConfig.cmake)
endif()
endif()