ParaViewServerManager.cmake
Go to the documentation of this file.
1 #[==[.md
2 # Server Manager XMLs
3 
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.
6 
7 TODO: Document the ServerManager XML format.
8 #]==]
9 
10 #[==[.md
11 ## Adding XMLs to modules
12 
13 Modules may have associated XML files. They can be added to the module target
14 using this function.
15 
16 ```
18  XMLS <xml>...)
19 ```
20 #]==]
22  cmake_parse_arguments(_paraview_add_sm
23  ""
24  "MODULE"
25  "XMLS"
26  ${ARGN})
27 
28  if (_paraview_add_sm_UNPARSED_ARGUMENTS)
29  message(FATAL_ERROR
30  "Unparsed arguments for paraview_add_server_manager_xmls: "
31  "${_paraview_add_sm_UNPARSED_ARGUMENTS}")
32  endif ()
33 
34  if (NOT _paraview_add_sm_XMLS)
35  message(FATAL_ERROR
36  "The `XMLS` argument is required.")
37  endif ()
38 
39  if (NOT DEFINED _paraview_add_sm_MODULE)
40  set(_paraview_add_sm_MODULE "${_vtk_build_module}")
41  endif ()
42 
43  foreach (_paraview_add_sm_xml IN LISTS _paraview_add_sm_XMLS)
44  if (NOT IS_ABSOLUTE "${_paraview_add_sm_xml}")
45  set(_paraview_add_sm_xml "${CMAKE_CURRENT_SOURCE_DIR}/${_paraview_add_sm_xml}")
46  endif ()
47 
48  _vtk_module_set_module_property("${_paraview_add_sm_MODULE}" APPEND
49  PROPERTY "paraview_server_manager_xml"
50  VALUE "${_paraview_add_sm_xml}")
51  endforeach ()
52 endfunction ()
53 
54 #[==[.md
55 ## Building XML files
56 
57 There are two functions offered to build server manager XML files. The first
58 uses modules:
59 
60 ```
62  MODULES <module>...
63  TARGET <target>
64  [INSTALL_EXPORT <export>]
65  [FILES <file>...]
66  [XML_FILES <variable>])
67 ```
68 
69 The `MODULES` argument contains the modules to include in the server manager
70 target. The function gathers the XML files declared using
71 `paraview_add_server_manager_xmls` and then calls
72 `paraview_server_manager_process_files`. If additional, non-module related XML
73 files are required, they may be passed via `FILES`.
74 
75 If `XML_FILES` is given, the list of process XML files are set on the given
76 variable.
77 
78 If `INSTALL_EXPORT` is given, the interface target will be added to the given
79 export set.
80 #]==]
82  cmake_parse_arguments(_paraview_sm_process
83  ""
84  "TARGET;XML_FILES;INSTALL_EXPORT"
85  "MODULES;FILES"
86  ${ARGN})
87 
88  if (_paraview_sm_process_UNPARSED_ARGUMENTS)
89  message(FATAL_ERROR
90  "Unparsed arguments for paraview_server_manager_process: "
91  "${_paraview_sm_process_UNPARSED_ARGUMENTS}")
92  endif ()
93 
94  if (NOT _paraview_sm_process_MODULES)
95  message(FATAL_ERROR
96  "The `MODULES` argument is required.")
97  endif ()
98 
99  if (NOT DEFINED _paraview_sm_process_TARGET)
100  message(FATAL_ERROR
101  "The `TARGET` argument is required.")
102  endif ()
103 
104  set(_paraview_sm_process_files)
105  foreach (_paraview_sm_process_module IN LISTS _paraview_sm_process_MODULES)
106  _vtk_module_get_module_property("${_paraview_sm_process_module}"
107  PROPERTY "paraview_server_manager_xml"
108  VARIABLE _paraview_sm_process_module_files)
109  list(APPEND _paraview_sm_process_files
110  ${_paraview_sm_process_module_files})
111  endforeach ()
112 
113  list(APPEND _paraview_sm_process_files
114  ${_paraview_sm_process_FILES})
115 
116  set(_paraview_sm_process_export_args)
117  if (DEFINED _paraview_sm_process_INSTALL_EXPORT)
118  set(_paraview_sm_process_export_args
119  INSTALL_EXPORT "${_paraview_sm_process_INSTALL_EXPORT}")
120  endif ()
121 
123  TARGET ${_paraview_sm_process_TARGET}
124  FILES ${_paraview_sm_process_files}
125  ${_paraview_sm_process_export_args})
126 
127  if (DEFINED _paraview_sm_process_XML_FILES)
128  set("${_paraview_sm_process_XML_FILES}"
129  "${_paraview_sm_process_files}"
130  PARENT_SCOPE)
131  endif ()
132 endfunction ()
133 
134 #[==[.md
135 The second way to process XML files directly.
136 
137 ```
139  FILES <file>...
140  TARGET <target>
141  [INSTALL_EXPORT <export>])
142 ```
143 
144 The files passed to the `FILES` argument will be processed in to functions
145 which are then consumed by ParaView applications.
146 
147 The name of the target is given to the `TARGET` argument. By default, the
148 filename is `<TARGET>.h` and it contains a function named
149 `<TARGET>_initialize`. They may be changed using the `FILE_NAME` and
150 `FUNCTION_NAME` arguments. The target has an interface usage requirement that
151 will allow the generated header to be included.
152 
153 If `INSTALL_EXPORT` is given, the interface target will be added to the given
154 export set.
155 #]==]
157  cmake_parse_arguments(_paraview_sm_process_files
158  ""
159  "TARGET;INSTALL_EXPORT"
160  "FILES"
161  ${ARGN})
162 
163  if (_paraview_sm_process_files_UNPARSED_ARGUMENTS)
164  message(FATAL_ERROR
165  "Unparsed arguments for paraview_server_manager_process_files: "
166  "${_paraview_sm_process_files_UNPARSED_ARGUMENTS}")
167  endif ()
168 
169  if (NOT DEFINED _paraview_sm_process_files_TARGET)
170  message(FATAL_ERROR
171  "The `TARGET` argument is required.")
172  endif ()
173 
174  set(_paraview_sm_process_files_output_dir
175  "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_paraview_sm_process_files_TARGET}")
176  set(_paraview_sm_process_files_output
177  "${_paraview_sm_process_files_output_dir}/${_paraview_sm_process_files_TARGET}_data.h")
178  add_custom_command(
179  OUTPUT "${_paraview_sm_process_files_output}"
180  DEPENDS ${_paraview_sm_process_files_FILES}
181  "$<TARGET_FILE:ParaView::ProcessXML>"
182  COMMAND ParaView::ProcessXML
183  "${_paraview_sm_process_files_output}"
184  "${_paraview_sm_process_files_TARGET}"
185  "Interface"
186  "GetInterfaces"
187  ${_paraview_sm_process_files_FILES}
188  COMMENT "Generating server manager headers for ${_paraview_sm_process_files_TARGET}.")
189  add_custom_target("${_paraview_sm_process_files_TARGET}_xml_content"
190  DEPENDS
191  "${_paraview_sm_process_files_output}")
192 
193  set(_paraview_sm_process_files_init_content
194  "#ifndef ${_paraview_sm_process_files_TARGET}_h
195 #define ${_paraview_sm_process_files_TARGET}_h
196 
197 #include \"${_paraview_sm_process_files_TARGET}_data.h\"
198 #include <string>
199 #include <vector>
200 
201 void ${_paraview_sm_process_files_TARGET}_initialize(std::vector<std::string>& xmls)
202 {\n (void)xmls;\n")
203  foreach (_paraview_sm_process_files_file IN LISTS _paraview_sm_process_files_FILES)
204  get_filename_component(_paraview_sm_process_files_name "${_paraview_sm_process_files_file}" NAME_WE)
205  string(APPEND _paraview_sm_process_files_init_content
206  " {
207  char *init_string = ${_paraview_sm_process_files_TARGET}${_paraview_sm_process_files_name}GetInterfaces();
208  xmls.push_back(init_string);
209  delete [] init_string;
210  }\n")
211  endforeach ()
212  string(APPEND _paraview_sm_process_files_init_content
213  "}
214 
215 #endif\n")
216 
217  file(GENERATE
218  OUTPUT "${_paraview_sm_process_files_output_dir}/${_paraview_sm_process_files_TARGET}.h"
219  CONTENT "${_paraview_sm_process_files_init_content}")
220 
221  add_library("${_paraview_sm_process_files_TARGET}" INTERFACE)
222  add_dependencies("${_paraview_sm_process_files_TARGET}"
223  "${_paraview_sm_process_files_TARGET}_xml_content")
224  target_include_directories("${_paraview_sm_process_files_TARGET}"
225  INTERFACE
226  "$<BUILD_INTERFACE:${_paraview_sm_process_files_output_dir}>")
227  _vtk_module_apply_properties("${_paraview_sm_process_files_TARGET}")
228  if (DEFINED _paraview_sm_process_files_INSTALL_EXPORT)
229  set(_vtk_build_INSTALL_EXPORT
230  "${_paraview_sm_process_files_INSTALL_EXPORT}")
231  endif ()
232  _vtk_module_install("${_paraview_sm_process_files_TARGET}")
233 endfunction ()
boost::graph_traits< vtkGraph *>::vertex_descriptor target(boost::graph_traits< vtkGraph *>::edge_descriptor e, vtkGraph *)
on
function paraview_server_manager_process_files()
.md The second way to process XML files directly.
string
function paraview_add_server_manager_xmls()
.md Server Manager XMLs
name
function paraview_server_manager_process()
.md Building XML files