@@ -15,7 +15,7 @@ project(
15
15
' cpp_std=c++11' ,
16
16
' warning_level=1' ],
17
17
license : ' Public Domain' ,
18
- meson_version : ' >= 0.49 .0' )
18
+ meson_version : ' >= 0.54 .0' )
19
19
20
20
21
21
jsoncpp_headers = files ([
@@ -62,6 +62,43 @@ import('pkgconfig').generate(
62
62
filebase : ' jsoncpp' ,
63
63
description : ' A C++ library for interacting with JSON' )
64
64
65
+ cmakeconf = configuration_data ()
66
+ cmakeconf.set(' MESON_LIB_DIR' , get_option (' libdir' ))
67
+ cmakeconf.set(' MESON_INCLUDE_DIR' , get_option (' includedir' ))
68
+
69
+ fs = import (' fs' )
70
+ if get_option (' default_library' ) == ' shared'
71
+ shared_name = fs.name(jsoncpp_lib.full_path())
72
+ endif
73
+ if get_option (' default_library' ) == ' static'
74
+ static_name = fs.name(jsoncpp_lib.full_path())
75
+ endif
76
+ if get_option (' default_library' ) == ' both'
77
+ shared_name = fs.name(jsoncpp_lib.get_shared_lib().full_path())
78
+ static_name = fs.name(jsoncpp_lib.get_static_lib().full_path())
79
+ endif
80
+
81
+ if get_option (' default_library' ) == ' shared' or get_option (' default_library' ) == ' both'
82
+ cmakeconf.set(' MESON_SHARED_TARGET' , '''
83
+ add_library(jsoncpp_lib IMPORTED SHARED)
84
+ set_target_properties(jsoncpp_lib PROPERTIES
85
+ IMPORTED_LOCATION "''' + join_paths (' ${PACKAGE_PREFIX_DIR}' , get_option (' libdir' ), shared_name) + ''' "
86
+ INTERFACE_INCLUDE_DIRECTORIES "''' + join_paths (' ${PACKAGE_PREFIX_DIR}' , get_option (' includedir' )) + ' ")' )
87
+ endif
88
+ if get_option (' default_library' ) == ' static' or get_option (' default_library' ) == ' both'
89
+ cmakeconf.set(' MESON_STATIC_TARGET' , '''
90
+ add_library(jsoncpp_static IMPORTED STATIC)
91
+ set_target_properties(jsoncpp_static PROPERTIES
92
+ IMPORTED_LOCATION "''' + join_paths (' ${PACKAGE_PREFIX_DIR}' , get_option (' libdir' ), static_name) + ''' "
93
+ INTERFACE_INCLUDE_DIRECTORIES "''' + join_paths (' ${PACKAGE_PREFIX_DIR}' , get_option (' includedir' )) + ' ")' )
94
+ endif
95
+
96
+ import (' cmake' ).configure_package_config_file(
97
+ name : ' jsoncpp' ,
98
+ input : ' jsoncppConfig.cmake.meson.in' ,
99
+ configuration : cmakeconf)
100
+ install_data (' jsoncpp-namespaced-targets.cmake' , install_dir : join_paths (get_option (' libdir' ), ' cmake' , jsoncpp_lib.name()))
101
+
65
102
# for libraries bundling jsoncpp
66
103
jsoncpp_dep = declare_dependency (
67
104
include_directories : jsoncpp_include_directories,
0 commit comments