4 ParaView uses XML files to describe filters available in its user interface.
5 Modules may add filters to the UI by providing XML files.
7 TODO: Document the ServerManager XML format.
11 cmake_policy(SET CMP0057 NEW)
14 ## Adding XMLs to modules 16 Modules may have associated XML files. They can be added to the module
target 25 cmake_parse_arguments(_paraview_add_sm
31 if (_paraview_add_sm_UNPARSED_ARGUMENTS)
33 "Unparsed arguments for paraview_add_server_manager_xmls: " 34 "${_paraview_add_sm_UNPARSED_ARGUMENTS}")
37 if (NOT _paraview_add_sm_XMLS)
39 "The `XMLS` argument is required.")
42 if (NOT DEFINED _paraview_add_sm_MODULE)
43 set(_paraview_add_sm_MODULE
"${_vtk_build_module}")
46 foreach (_paraview_add_sm_xml IN LISTS _paraview_add_sm_XMLS)
47 if (NOT IS_ABSOLUTE
"${_paraview_add_sm_xml}")
48 string(PREPEND _paraview_add_sm_xml
"${CMAKE_CURRENT_SOURCE_DIR}/")
52 PROPERTY
"paraview_server_manager_xml" 53 VALUE
"${_paraview_add_sm_xml}")
60 There are two functions offered to build server manager XML files. The first
67 [INSTALL_EXPORT <export>]
69 [XML_FILES <variable>])
72 The `MODULES` argument contains the modules to include in the server manager
73 target. The
function gathers the XML files declared
using 76 files are required, they may be passed via `FILES`.
78 If `XML_FILES` is given, the list of process XML files are
set on the given
81 If `INSTALL_EXPORT` is given, the
interface target will be added to the given
85 cmake_parse_arguments(_paraview_sm_process
87 "TARGET;XML_FILES;INSTALL_EXPORT" 91 if (_paraview_sm_process_UNPARSED_ARGUMENTS)
93 "Unparsed arguments for paraview_server_manager_process: " 94 "${_paraview_sm_process_UNPARSED_ARGUMENTS}")
97 if (NOT _paraview_sm_process_MODULES)
99 "The `MODULES` argument is required.")
102 if (NOT DEFINED _paraview_sm_process_TARGET)
104 "The `TARGET` argument is required.")
107 # Topologically sort modules so that XML definitions that depend on each 108 # other are loaded in the right order. 109 set(_paraview_sm_process_sorted_modules ${_paraview_sm_process_MODULES})
110 set(_paraview_sm_process_module_stack ${_paraview_sm_process_MODULES})
111 set(_paraview_sm_process_module_seen)
112 while (_paraview_sm_process_module_stack)
113 list(GET _paraview_sm_process_module_stack 0 _paraview_sm_process_module)
114 list(REMOVE_AT _paraview_sm_process_module_stack 0)
115 if (_paraview_sm_process_module IN_LIST _paraview_sm_process_module_seen)
118 list(APPEND _paraview_sm_process_module_seen
119 "${_paraview_sm_process_module}")
121 get_property(_paraview_sm_process_module_is_imported
122 TARGET
"${_paraview_sm_process_module}" 124 if (_paraview_sm_process_module_is_imported)
127 VARIABLE
"_paraview_sm_process_depends")
129 PROPERTY
"private_depends" 130 VARIABLE
"_paraview_sm_process_private_depends")
132 PROPERTY
"optional_depends" 133 VARIABLE
"_paraview_sm_process_optional_depends")
135 get_property(
"_paraview_sm_process_depends" GLOBAL
136 PROPERTY
"_vtk_module_${_paraview_sm_process_module}_depends")
137 get_property(
"_paraview_sm_process_private_depends" GLOBAL
138 PROPERTY
"_vtk_module_${_paraview_sm_process_module}_private_depends")
139 get_property(
"_paraview_sm_process_optional_depends" GLOBAL
140 PROPERTY
"_vtk_module_${_paraview_sm_process_module}_optional_depends")
143 # Prune optional dependencies that do not exist. 144 set(_paraview_sm_process_optional_depends_exists)
145 foreach (_paraview_sm_process_optional_depend IN LISTS _paraview_sm_process_optional_depends)
146 if (TARGET
"${_paraview_sm_process_optional_depend}")
147 list(APPEND _paraview_sm_process_optional_depends_exists
148 "${_paraview_sm_process_optional_depend}")
152 # Put all of the dependencies into a single variable. 153 set(
"_paraview_sm_process_${_paraview_sm_process_module}_all_depends" 154 ${_paraview_sm_process_depends}
155 ${_paraview_sm_process_private_depends}
156 ${_paraview_sm_process_optional_depends_exists})
157 list(APPEND _paraview_sm_process_module_stack
158 ${_paraview_sm_process_depends}
159 ${_paraview_sm_process_private_depends}
160 ${_paraview_sm_process_optional_depends_exists})
163 # Topologically sort according to dependencies. 164 vtk_topological_sort(_paraview_sm_process_sorted_modules
"_paraview_sm_process_" "_all_depends")
166 # Limit the sorted modules to those that are actually in the pass module list. 167 set(_paraview_sm_process_modules)
168 foreach (_paraview_sm_process_sorted_module IN LISTS _paraview_sm_process_sorted_modules)
169 if (_paraview_sm_process_sorted_module IN_LIST _paraview_sm_process_MODULES)
170 list(APPEND _paraview_sm_process_modules
171 "${_paraview_sm_process_sorted_module}")
175 set(_paraview_sm_process_files)
176 foreach (_paraview_sm_process_module IN LISTS _paraview_sm_process_modules)
178 PROPERTY
"paraview_server_manager_xml" 179 VARIABLE _paraview_sm_process_module_files)
180 list(APPEND _paraview_sm_process_files
181 ${_paraview_sm_process_module_files})
184 list(APPEND _paraview_sm_process_files
185 ${_paraview_sm_process_FILES})
187 set(_paraview_sm_process_export_args)
188 if (DEFINED _paraview_sm_process_INSTALL_EXPORT)
189 list(APPEND _paraview_sm_process_export_args
190 INSTALL_EXPORT
"${_paraview_sm_process_INSTALL_EXPORT}")
194 TARGET ${_paraview_sm_process_TARGET}
195 FILES ${_paraview_sm_process_files}
196 ${_paraview_sm_process_export_args})
198 if (DEFINED _paraview_sm_process_XML_FILES)
199 set(
"${_paraview_sm_process_XML_FILES}" 200 "${_paraview_sm_process_files}" 206 The second way to process XML files directly.
212 [INSTALL_EXPORT <export>])
215 The files passed to the `FILES` argument will be processed in to functions
216 which are then consumed by ParaView applications.
218 The
name of the
target is given to the `TARGET` argument. By
default, the
219 filename is `<TARGET>.h` and it contains a
function named
220 `<TARGET>_initialize`. They may be changed
using the `FILE_NAME` and
221 `FUNCTION_NAME` arguments. The
target has an
interface usage requirement that
222 will allow the generated header to be included.
224 If `INSTALL_EXPORT` is given, the interface target will be added to the given
228 cmake_parse_arguments(_paraview_sm_process_files
230 "TARGET;INSTALL_EXPORT" 234 if (_paraview_sm_process_files_UNPARSED_ARGUMENTS)
236 "Unparsed arguments for paraview_server_manager_process_files: " 237 "${_paraview_sm_process_files_UNPARSED_ARGUMENTS}")
240 if (NOT DEFINED _paraview_sm_process_files_TARGET)
242 "The `TARGET` argument is required.")
245 set(_paraview_sm_process_files_output_dir
246 "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_paraview_sm_process_files_TARGET}")
247 set(_paraview_sm_process_files_output
248 "${_paraview_sm_process_files_output_dir}/${_paraview_sm_process_files_TARGET}_data.h")
249 set(_paraview_sm_process_files_response_file
250 "${_paraview_sm_process_files_output_dir}/${_paraview_sm_process_files_TARGET}.args")
252 string(REPLACE
";" "\n" _paraview_sm_process_files_input_file_content
253 "${_paraview_sm_process_files_FILES}")
255 OUTPUT
"${_paraview_sm_process_files_response_file}" 256 CONTENT
"${_paraview_sm_process_files_input_file_content}")
259 OUTPUT
"${_paraview_sm_process_files_output}" 260 DEPENDS ${_paraview_sm_process_files_FILES}
261 "$<TARGET_FILE:ParaView::ProcessXML>" 262 "${_paraview_sm_process_files_response_file}" 263 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR}
264 $<TARGET_FILE:ParaView::ProcessXML>
265 "${_paraview_sm_process_files_output}" 266 "${_paraview_sm_process_files_TARGET}" 269 "@${_paraview_sm_process_files_response_file}" 270 COMMENT
"Generating server manager headers for ${_paraview_sm_process_files_TARGET}.")
271 add_custom_target(
"${_paraview_sm_process_files_TARGET}_xml_content" 273 "${_paraview_sm_process_files_output}")
275 set(_paraview_sm_process_files_init_content
276 "#ifndef ${_paraview_sm_process_files_TARGET}_h 277 #define ${_paraview_sm_process_files_TARGET}_h 279 #include \"${_paraview_sm_process_files_TARGET}_data.h\" 283 void ${_paraview_sm_process_files_TARGET}_initialize(std::vector<std::string>& xmls) 285 foreach (_paraview_sm_process_files_file IN LISTS _paraview_sm_process_files_FILES)
286 get_filename_component(_paraview_sm_process_files_name
"${_paraview_sm_process_files_file}" NAME_WE)
287 string(APPEND _paraview_sm_process_files_init_content
289 char *init_string = ${_paraview_sm_process_files_TARGET}${_paraview_sm_process_files_name}GetInterfaces(); 290 xmls.push_back(init_string); 291 delete [] init_string; 294 string(APPEND _paraview_sm_process_files_init_content
300 OUTPUT
"${_paraview_sm_process_files_output_dir}/${_paraview_sm_process_files_TARGET}.h" 301 CONTENT
"${_paraview_sm_process_files_init_content}")
303 add_library(
"${_paraview_sm_process_files_TARGET}" INTERFACE)
304 add_dependencies(
"${_paraview_sm_process_files_TARGET}" 305 "${_paraview_sm_process_files_TARGET}_xml_content")
306 target_include_directories(
"${_paraview_sm_process_files_TARGET}" 308 "$<BUILD_INTERFACE:${_paraview_sm_process_files_output_dir}>")
310 if (DEFINED _paraview_sm_process_files_INSTALL_EXPORT)
311 set(_vtk_build_INSTALL_EXPORT
312 "${_paraview_sm_process_files_INSTALL_EXPORT}")
boost::graph_traits< vtkGraph *>::vertex_descriptor target(boost::graph_traits< vtkGraph *>::edge_descriptor e, vtkGraph *)
function _vtk_module_get_module_property(module)
Get a module property.
function vtk_topological_sort(LIST, PREFIX, SUFFIX)
function paraview_add_server_manager_xmls()
.md Server Manager XMLs
function _vtk_module_apply_properties(target)
Apply properties to a module.
function _vtk_module_install(target)
Install a module target.
function _vtk_module_set_module_property(module)
Set a module property.
function paraview_server_manager_process()
.md Building XML files
function paraview_server_manager_process_files()
.md The second way to process XML files directly.