3@brief Output a
boolean to JSON
5Appends a condition as a JSON
boolean with the given dictionary
key name to the
9_vtk_json_bool(<output> <
name> <cond>)
18 string(APPEND "${output}
" "\
"${name}\": ${val}, ")
24@brief Output a
string list to JSON
26Appends a variable as a JSON list of strings with the given dictionary
key name
27to the given
string variable.
30_vtk_json_string_list(<output> <
name> <cond>)
35 foreach (
value IN LISTS
"${var}")
36 string(APPEND list
"\"${value}\", ")
39 string(REPLACE ", ]" "]" list "${list}
")
40 string(APPEND "${output}
" "\
"${name}\": ${list}, ")
46@ingroup module-support
47@brief JSON metadata representation of modules
49Information about the modules built and/or available may be dumped to a JSON
58 * `MODULES`: (Required) The modules to output information
for.
59 * `OUTPUT`: (Required) A JSON file describing the modules built will
60 be output to
this path. Relative paths are rooted to `CMAKE_BINARY_DIR`.
69 "library_name":
"...",
71 "implementable": <
bool>,
72 "third_party": <
bool>,
73 "wrap_exclude": <
bool>,
104 cmake_parse_arguments(PARSE_ARGV 0 _vtk_json
109 if (_vtk_json_UNPARSED_ARGUMENTS)
111 "Unparsed arguments for vtk_module_json: "
112 "${_vtk_json_UNPARSED_ARGUMENTS}")
115 if (NOT DEFINED _vtk_json_OUTPUT)
117 "The `OUTPUT` argument is required.")
120 if (NOT _vtk_json_MODULES)
121 message(FATAL_ERROR "No modules given to output.")
124 if (NOT IS_ABSOLUTE "${_vtk_json_OUTPUT}
")
125 string(PREPEND _vtk_json_OUTPUT "${CMAKE_BINARY_DIR}/
")
130 set(_vtk_json_contents "{
")
131 string(APPEND _vtk_json_contents "\
"modules\": {")
132 foreach (_vtk_json_module IN LISTS _vtk_json_MODULES)
133 get_property(_vtk_json_description GLOBAL
134 PROPERTY
"_vtk_module_${_vtk_json_module}_description")
135 get_property(_vtk_json_implementable GLOBAL
136 PROPERTY
"_vtk_module_${_vtk_json_module}_implementable")
137 get_property(_vtk_json_third_party GLOBAL
138 PROPERTY
"_vtk_module_${_vtk_json_module}_third_party")
139 get_property(_vtk_json_wrap_exclude GLOBAL
140 PROPERTY
"_vtk_module_${_vtk_json_module}_wrap_exclude")
141 get_property(_vtk_json_kit GLOBAL
142 PROPERTY
"_vtk_module_${_vtk_json_module}_kit")
143 get_property(_vtk_json_depends GLOBAL
144 PROPERTY
"_vtk_module_${_vtk_json_module}_depends")
145 get_property(_vtk_json_private_depends GLOBAL
146 PROPERTY
"_vtk_module_${_vtk_json_module}_private_depends")
147 get_property(_vtk_json_optional_depends GLOBAL
148 PROPERTY
"_vtk_module_${_vtk_json_module}_optional_depends")
149 get_property(_vtk_json_implements GLOBAL
150 PROPERTY
"_vtk_module_${_vtk_json_module}_implements")
151 get_property(_vtk_json_library_name GLOBAL
152 PROPERTY
"_vtk_module_${_vtk_json_module}_library_name")
153 get_property(_vtk_json_module_file GLOBAL
154 PROPERTY
"_vtk_module_${_vtk_json_module}_file")
156 set(_vtk_json_kit_name
"null")
158 list(APPEND _vtk_json_kits
160 set(_vtk_json_kit_name
"\"${_vtk_json_kit}\"")
162 set(_vtk_json_headers "")
163 if (TARGET "${_vtk_json_module}
")
164 _vtk_module_get_module_property("${_vtk_json_module}
"
166 VARIABLE _vtk_json_headers)
167 get_filename_component(_vtk_json_module_dir "${_vtk_json_module_file}
" DIRECTORY)
168 file(RELATIVE_PATH _vtk_json_module_subdir "${CMAKE_SOURCE_DIR}
" "${_vtk_json_module_dir}
")
169 string(REPLACE "${CMAKE_SOURCE_DIR}/${_vtk_json_module_subdir}/
" "" _vtk_json_headers "${_vtk_json_headers}
")
170 string(REPLACE "${CMAKE_BINARY_DIR}/${_vtk_json_module_subdir}/
" "" _vtk_json_headers "${_vtk_json_headers}
")
173 string(APPEND _vtk_json_contents "\
"${_vtk_json_module}\": {")
174 string(APPEND _vtk_json_contents
"\"library_name\": \"${_vtk_json_library_name}\", ")
175 string(APPEND _vtk_json_contents
"\"description\": \"${_vtk_json_description}\", ")
176 _vtk_json_bool(_vtk_json_contents
"enabled" "TARGET;${_vtk_json_module}")
177 _vtk_json_bool(_vtk_json_contents
"implementable" _vtk_json_implementable)
178 _vtk_json_bool(_vtk_json_contents
"third_party" _vtk_json_third_party)
179 _vtk_json_bool(_vtk_json_contents
"wrap_exclude" _vtk_json_wrap_exclude)
180 string(APPEND _vtk_json_contents
"\"kit\": ${_vtk_json_kit_name}, ")
186 string(APPEND _vtk_json_contents
"}, ")
188 string(APPEND _vtk_json_contents "}, ")
190 string(APPEND _vtk_json_contents "\"kits\": {
")
191 foreach (_vtk_json_kit IN LISTS _vtk_json_kits)
192 set(_vtk_json_library_name "null
")
193 if (TARGET "${_vtk_json_kit}
")
194 get_property(_vtk_json_library
195 TARGET "${_vtk_json_kit}
"
196 PROPERTY LIBRARY_OUTPUT_NAME)
197 set(_vtk_json_library_name "\
"${_vtk_json_library}\"")
200 string(APPEND _vtk_json_contents "\"${_vtk_json_kit}\
": {")
201 string(APPEND _vtk_json_contents
"\"library_name\": ${_vtk_json_library_name}, ")
202 _vtk_json_bool(_vtk_json_contents
"enabled" "TARGET;${_vtk_json_kit}")
203 string(APPEND _vtk_json_contents
"}, ")
205 string(APPEND _vtk_json_contents "}, ")
207 string(APPEND _vtk_json_contents "}")
208 string(REPLACE ", ]" "]" _vtk_json_contents "${_vtk_json_contents}
")
209 string(REPLACE ", }
" "}
" _vtk_json_contents "${_vtk_json_contents}
")
211 OUTPUT "${_vtk_json_OUTPUT}
"
212 CONTENT "${_vtk_json_contents}
")
macro _vtk_json_string_list(output, name, var)
Output a string list to JSON.
macro _vtk_json_bool(output, name, cond)
Output a boolean to JSON.
function vtk_module_json()
JSON metadata representation of modules.