ParaViewPlugin.cmake
Go to the documentation of this file.
1 cmake_policy(PUSH)
2 cmake_policy(SET CMP0057 NEW)
3 
4 set(_ParaViewPlugin_cmake_dir "${CMAKE_CURRENT_LIST_DIR}")
5 
6 #[==[.md
7 # ParaView Plugin CMake API
8 
9 # TODO
10 
11 #]==]
12 
13 #[==[
14 ## Conditionally output debug statements
15 
16 The `_paraview_plugin_debug` function is provided to assist in debugging. It is
17 controlled by the `_paraview_plugin_log` variable which contains a list of
18 "domains" to debug.
19 
20 ~~~
21 _paraview_plugin_debug(<domain> <format>)
22 ~~~
23 
24 If the `domain` is enabled for debugging, the `format` argument is configured
25 and printed. It should contain `@` variable expansions to replace rather than
26 it being done outside. This helps to avoid the cost of generating large strings
27 when debugging is disabled.
28 #]==]
29 function (_paraview_plugin_debug domain format)
30  if (NOT _paraview_plugin_log STREQUAL "ALL" AND
31  NOT domain IN_LIST _paraview_plugin_log)
32  return ()
33  endif ()
34 
35  string(CONFIGURE "${format}" _paraview_plugin_debug_msg)
36  if (_paraview_plugin_debug_msg)
37  message(STATUS
38  "ParaView plugin debug ${domain}: ${_paraview_plugin_debug_msg}")
39  endif ()
40 endfunction ()
41 
42 #[==[.md
43 ## Finding plugins
44 
45 Similar to VTK modules, plugins first have to be discovered. The
46 `paraview_plugin_find_plugins` function does this. The output variable is the
47 list of discovered `paraview.plugin` files.
48 
49 ```
50 paraview_plugin_find_plugins(<output> [<directory>...])
51 ```
52 #]==]
53 function (paraview_plugin_find_plugins output)
54  set(_paraview_find_plugins_all)
55  foreach (_paraview_find_plugins_directory IN LISTS ARGN)
56  file(GLOB_RECURSE _paraview_find_plugins_plugins
57  "${_paraview_find_plugins_directory}/paraview.plugin")
58  list(APPEND _paraview_find_plugins_all
59  ${_paraview_find_plugins_plugins})
60  endforeach ()
61  set("${output}" ${_paraview_find_plugins_all} PARENT_SCOPE)
62 endfunction ()
63 
64 #[==[.md
65 ## Plugin files
66 
67 The `paraview.plugin` file is parsed and used as arguments to a CMake function.
68 
69 Example:
70 
71 ```
72 NAME
73  AdiosReaderPixie
74 CONDITION
75  PARAVIEW_USE_MPI
76 DESCRIPTION
77  Pixie file reader using ADIOS
78 REQUIRES_MODULES
79  VTK:CommonCore
80 ```
81 
82 The supported arguments are:
83 
84  * `NAME`: (Required) The name of the plugin.
85  * `DESCRIPTION`: (Recommended) Short text describing what the plugin does.
86  * `CONDITION`: Arguments to CMake's `if` command which may be used to hide
87  the plugin for certain platforms or other reasons. If the expression is
88  false, the module is completely ignored.
89  * `REQUIRES_MODULES`: If the plugin is enabled, these modules will be listed
90  as those required to build the enabled plugins.
91 #]==]
92 macro (_paraview_plugin_parse_args name_output)
93  cmake_parse_arguments("_name"
94  ""
95  "NAME"
96  ""
97  ${ARGN})
98 
99  if (NOT _name_NAME)
100  message(FATAL_ERROR
101  "A ParaView plugin requires a name (from ${_paraview_scan_plugin_file}).")
102  endif ()
103  set("${name_output}" "${_name_NAME}")
104 
105  cmake_parse_arguments("${_name_NAME}"
106  ""
107  "NAME"
108  "DESCRIPTION;REQUIRES_MODULES;CONDITION"
109  ${ARGN})
110 
111  if (${_name_NAME}_UNPARSED_ARGUMENTS)
112  message(FATAL_ERROR
113  "Unparsed arguments for ${_name_NAME}: "
114  "${${_name_NAME}_UNPARSED_ARGUMENTS}")
115  endif ()
116 
117  if (NOT ${_name_NAME}_DESCRIPTION)
118  message(WARNING "The ${_name_NAME} module should have a description")
119  endif ()
120  string(REPLACE ";" " " "${_name_NAME}_DESCRIPTION" "${${_name_NAME}_DESCRIPTION}")
121 endmacro ()
122 
123 #[==[.md
124 ## Scanning plugins
125 
126 Once the `paraview.plugin` files have been found, they need to be scanned to
127 determine which should be built. Generally, plugins should be scanned first in
128 order to use the `REQUIRES_MODULES` list to enable them during the scan for
129 their required modules.
130 
131 ```
132 paraview_plugin_scan(
133  PLUGIN_FILES <file>...
134  PROVIDES_PLUGINS <variable>
135  [ENABLE_BY_DEFAULT <ON|OFF>]
136  [HIDE_PLUGINS_FROM_CACHE <ON|OFF>]
137  [REQUIRES_MODULES <module>...])
138 ```
139 
140  * `PLUGIN_FILES`: (Required) The list of plugin files to scan.
141  * `PROVIDES_PLUGINS`: (Required) This variable contains a list of the plugins
142  to be built.
143  * `ENABLE_BY_DEFAULT`: (Defaults to `OFF`) Whether to enable plugins by
144  default or not.
145  * `HIDE_PLUGINS_FROM_CACHE`: (Defaults to `OFF`) Whether to display options
146  to enable and disable plugins in the cache or not.
147  * `REQUIRES_MODULES`: The list of modules required by the enabled plugins.
148 #]==]
149 
150 function (paraview_plugin_scan)
151  cmake_parse_arguments(_paraview_scan
152  ""
153  "ENABLE_BY_DEFAULT;HIDE_PLUGINS_FROM_CACHE;REQUIRES_MODULES;PROVIDES_PLUGINS"
154  "PLUGIN_FILES"
155  ${ARGN})
156 
157  if (_paraview_scan_UNPARSED_ARGUMENTS)
158  message(FATAL_ERROR
159  "Unparsed arguments for paraview_plugin_scan: "
160  "${_paraview_scan_UNPARSED_ARGUMENTS}")
161  endif ()
162 
163  if (NOT DEFINED _paraview_scan_ENABLE_BY_DEFAULT)
164  set(_paraview_scan_ENABLE_BY_DEFAULT OFF)
165  endif ()
166 
167  if (NOT DEFINED _paraview_scan_HIDE_PLUGINS_FROM_CACHE)
168  set(_paraview_scan_HIDE_PLUGINS_FROM_CACHE OFF)
169  endif ()
170 
171  if (NOT DEFINED _paraview_scan_PROVIDES_PLUGINS)
172  message(FATAL_ERROR
173  "The `PROVIDES_PLUGINS` argument is required.")
174  endif ()
175 
176  if (NOT _paraview_scan_PLUGIN_FILES)
177  message(FATAL_ERROR
178  "No plugin files given to scan.")
179  endif ()
180 
181  set(_paraview_scan_option_default_type BOOL)
182  if (_paraview_scan_HIDE_PLUGINS_FROM_CACHE)
183  set(_paraview_scan_option_default_type INTERNAL)
184  endif ()
185 
186  set(_paraview_scan_provided_plugins)
187  set(_paraview_scan_required_modules)
188 
189  foreach (_paraview_scan_plugin_file IN LISTS _paraview_scan_PLUGIN_FILES)
190  if (NOT IS_ABSOLUTE "${_paraview_scan_plugin_file}")
191  set(_paraview_scan_plugin_file
192  "${CMAKE_CURRENT_SOURCE_DIR}/${_paraview_scan_plugin_file}")
193  endif ()
194 
195  set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND
196  PROPERTY
197  CMAKE_CONFIGURE_DEPENDS "${_paraview_scan_plugin_file}")
198 
199  file(READ "${_paraview_scan_plugin_file}" _paraview_scan_plugin_args)
200  # Replace comments.
201  string(REGEX REPLACE "#[^\n]*\n" "\n" _paraview_scan_plugin_args "${_paraview_scan_plugin_args}")
202  # Use argument splitting.
203  string(REGEX REPLACE "( |\n)+" ";" _paraview_scan_plugin_args "${_paraview_scan_plugin_args}")
204  _paraview_plugin_parse_args(_paraview_scan_plugin_name ${_paraview_scan_plugin_args})
205  _paraview_plugin_debug(plugin "@_paraview_scan_plugin_name@ declared by @_paraview_scan_plugin_file@")
206 
207  list(APPEND _paraview_scan_all_plugins
208  "${_paraview_scan_plugin_name}")
209 
210  set(_paraview_scan_plugin_default "${_paraview_scan_ENABLE_BY_DEFAULT}")
211  if (DEFINED "_paraview_plugin_default_${_paraview_scan_plugin_name}")
212  set(_paraview_scan_plugin_default "${_paraview_plugin_default_${_paraview_scan_plugin_name}}")
213  endif ()
214  option("PARAVIEW_PLUGIN_ENABLE_${_paraview_scan_plugin_name}"
215  "Enable the ${_paraview_scan_plugin_name} plugin. ${${_paraview_scan_plugin_name}_DESCRIPTION}"
216  "${_paraview_scan_plugin_default}")
217  set("_paraview_scan_enable_${_paraview_scan_plugin_name}"
218  "${PARAVIEW_PLUGIN_ENABLE_${_paraview_scan_plugin_name}}")
219 
220  set_property(CACHE "PARAVIEW_PLUGIN_ENABLE_${_paraview_scan_plugin_name}"
221  PROPERTY
222  TYPE "${_paraview_scan_option_default_type}")
223 
224  if (DEFINED ${_paraview_scan_plugin_name}_CONDITION)
225  if (NOT (${${_paraview_scan_plugin_name}_CONDITION}))
226  if (DEFINED "PARAVIEW_PLUGIN_ENABLE_${_paraview_scan_plugin_name}")
227  set_property(CACHE "PARAVIEW_PLUGIN_ENABLE_${_paraview_scan_plugin_name}"
228  PROPERTY
229  TYPE INTERNAL)
230  endif ()
231  _paraview_plugin_debug(plugin "@_paraview_scan_plugin_name@ hidden by its `CONDITION`")
232  continue ()
233  endif ()
234  endif ()
235 
236  if (_paraview_scan_enable_${_paraview_scan_plugin_name})
237  _paraview_plugin_debug(plugin "@_paraview_scan_plugin_name@ requested via cache value")
238  list(APPEND _paraview_scan_provided_plugins
239  "${_paraview_scan_plugin_name}")
240  list(APPEND _paraview_scan_required_modules
241  ${${_paraview_scan_plugin_name}_REQUIRES_MODULES})
242  endif ()
243 
244  set_property(GLOBAL
245  PROPERTY
246  "_paraview_plugin_${_paraview_scan_plugin_name}_file" "${_paraview_scan_plugin_file}")
247  set_property(GLOBAL
248  PROPERTY
249  "_paraview_plugin_${_paraview_scan_plugin_name}_description" "${${_paraview_scan_plugin_name}_DESCRIPTION}")
250  set_property(GLOBAL
251  PROPERTY
252  "_paraview_plugin_${_paraview_scan_plugin_name}_required_modules" "${${_paraview_scan_plugin_name}_REQUIRES_MODULES}")
253  endforeach ()
254 
255  if (DEFINED _paraview_scan_REQUIRES_MODULES)
256  set("${_paraview_scan_REQUIRES_MODULES}"
257  ${_paraview_scan_required_modules}
258  PARENT_SCOPE)
259  endif ()
260 
261  set("${_paraview_scan_PROVIDES_PLUGINS}"
262  ${_paraview_scan_provided_plugins}
263  PARENT_SCOPE)
264 endfunction ()
265 
266 function (_paraview_plugin_check_destdir variable)
267  if (NOT DEFINED "${variable}")
268  message(FATAL_ERROR
269  "It appears as though ${variable} is not defined, but is needed to "
270  "default a destination directory for build artifacts. Usually this is "
271  "resolved by `include(GNUInstallDirs)` at the top of the project.")
272  endif ()
273 endfunction ()
274 
275 #[==[.md
276 ## Building plugins
277 
278 Once all plugins have been scanned, they need to be built.
279 
280 ```
281 paraview_plugin_build(
282  PLUGINS <plugin>...
283  [AUTOLOAD <plugin>...]
284  [DELAYED_LOAD <plugin>...]
285  [PLUGINS_COMPONENT <component>]
286 
287  [TARGET <target>]
288  [INSTALL_EXPORT <export>]
289  [CMAKE_DESTINATION <destination>]
290  [TARGET_COMPONENT <component>]
291  [INSTALL_HEADERS <ON|OFF>]
292  [USE_FILE_SETS <ON|OFF>]
293 
294  [HEADERS_DESTINATION <destination>]
295  [RUNTIME_DESTINATION <destination>]
296  [LIBRARY_DESTINATION <destination>]
297  [LIBRARY_SUBDIRECTORY <subdirectory>]
298  [ADD_INSTALL_RPATHS <ON|OFF>]
299 
300  [PLUGINS_FILE_NAME <filename>]
301  [DISABLE_XML_DOCUMENTATION <ON|OFF>])
302 
303  [GENERATE_SPDX <ON|OFF>]
304  [SPDX_DOCUMENT_NAMESPACE <uri>]
305  [SPDX_DOWNLOAD_LOCATION <url>]
306 ```
307 
308  * `PLUGINS`: (Required) The list of plugins to build. May be empty.
309  * `AUTOLOAD`: A list of plugins to mark for autoloading.
310  * `DELAYED_LOAD`: A list of plugins to mark for delayed loading. A delayed load
311  plugin is a plugin where only the XMLs are loaded on load, while the actual
312  shared library of the plugin is loaded only when a proxy defined in these XMLs
313  is used.
314  * `PLUGINS_COMPONENT`: (Defaults to `paraview_plugins`) The installation
315  component to use for installed plugins.
316  * `TARGET`: (Recommended) The name of an interface target to generate. This
317  provides. an initialization function `<TARGET>_initialize` which
318  initializes static plugins. The function is provided, but is a no-op for
319  shared plugin builds.
320  * `INSTALL_EXPORT`: If provided, the generated target will be added to the
321  named export set.
322  * `CMAKE_DESTINATION`: If provided, the plugin target's properties will be
323  written to a file named `<TARGET>-paraview-plugin-properties.cmake` in the
324  specified destination.
325  * `TARGET_COMPONENT`: (Defaults to `development`) The component to use for
326  `<TARGET>`.
327  * `INSTALL_HEADERS`: (Defaults to `ON`) Whether to install headers or not.
328  * `USE_FILE_SETS`: (Defaults to `OFF`) Whether to use `FILE_SET` source
329  specification or not.
330  * `HEADERS_DESTINATION`: (Defaults to `${CMAKE_INSTALL_INCLUDEDIR}`) Where to
331  install include files.
332  * `RUNTIME_DESTINATION`: (Defaults to `${CMAKE_INSTALL_BINDIR}`) Where to
333  install runtime files.
334  * `LIBRARY_DESTINATION`: (Defaults to `${CMAKE_INSTALL_LIBDIR}`) Where to
335  install modules built by plugins.
336  * `LIBRARY_SUBDIRECTORY`: (Defaults to `""`) Where to install the plugins
337  themselves. Each plugin lives in a directory of its name in
338  `<RUNTIME_DESTINATION>/<LIBRARY_SUBDIRECTORY>` (for Windows) or
339  `<LIBRARY_DESTINATION>/<LIBRARY_SUBDIRECTORY>` for other platforms.
340  * `ADD_INSTALL_RPATHS`: (Defaults to `ON`) If specified, an RPATH to load
341  dependent libraries from the `LIBRARY_DESTINATION` from the plugins will be
342  added.
343  * `PLUGINS_FILE_NAME`: The name of the XML plugin file to generate for the
344  built plugins. This file will be placed under
345  `<LIBRARY_DESTINATION>/<LIBRARY_SUBDIRECTORY>`. It will be installed with
346  the `plugin` component.
347  * `DISABLE_XML_DOCUMENTATION`: (Defaults to `OFF`) Whether to forcefully
348  disable XML documentation or not.
349  * ``GENERATE_SPDX``: (Defaults to ``OFF``) Whether or not to generate and install
350  SPDX file for each modules.
351  * ``SPDX_DOCUMENT_NAMESPACE``: (Defaults to ``""``) Document namespace to use when
352  generating SPDX files.
353  * ``SPDX_DOWNLOAD_LOCATION``: (Defaults to ``""``) Download location to use when
354  generating SPDX files.
355 #]==]
356 function (paraview_plugin_build)
357  cmake_parse_arguments(_paraview_build
358  ""
359  "HEADERS_DESTINATION;RUNTIME_DESTINATION;LIBRARY_DESTINATION;LIBRARY_SUBDIRECTORY;TARGET;PLUGINS_FILE_NAME;INSTALL_EXPORT;CMAKE_DESTINATION;PLUGINS_COMPONENT;TARGET_COMPONENT;ADD_INSTALL_RPATHS;INSTALL_HEADERS;DISABLE_XML_DOCUMENTATION;GENERATE_SPDX;SPDX_DOCUMENT_NAMESPACE;SPDX_DOWNLOAD_LOCATION;USE_FILE_SETS"
360  "PLUGINS;AUTOLOAD;DELAYED_LOAD"
361  ${ARGN})
362 
363  if (_paraview_build_UNPARSED_ARGUMENTS)
364  message(FATAL_ERROR
365  "Unparsed arguments for paraview_plugin_build: "
366  "${_paraview_build_UNPARSED_ARGUMENTS}")
367  endif ()
368 
369  if (NOT DEFINED _paraview_build_HEADERS_DESTINATION)
370  _paraview_plugin_check_destdir(CMAKE_INSTALL_INCLUDEDIR)
371  set(_paraview_build_HEADERS_DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
372  endif ()
373 
374  if (NOT DEFINED _paraview_build_RUNTIME_DESTINATION)
375  _paraview_plugin_check_destdir(CMAKE_INSTALL_BINDIR)
376  set(_paraview_build_RUNTIME_DESTINATION "${CMAKE_INSTALL_BINDIR}")
377  endif ()
378 
379  if (NOT DEFINED _paraview_build_LIBRARY_DESTINATION)
380  _paraview_plugin_check_destdir(CMAKE_INSTALL_LIBDIR)
381  set(_paraview_build_LIBRARY_DESTINATION "${CMAKE_INSTALL_LIBDIR}")
382  endif ()
383 
384  if (NOT DEFINED _paraview_build_LIBRARY_SUBDIRECTORY)
385  set(_paraview_build_LIBRARY_SUBDIRECTORY "")
386  endif ()
387 
388  if (NOT _paraview_build_DISABLE_XML_DOCUMENTATION)
389  set(_paraview_build_DISABLE_XML_DOCUMENTATION OFF)
390  endif ()
391 
392  if (NOT DEFINED _paraview_build_GENERATE_SPDX)
393  set(_paraview_build_GENERATE_SPDX OFF)
394  endif ()
395 
396  if (NOT _paraview_build_SPDX_DOCUMENT_NAMESPACE)
397  set(_paraview_build_SPDX_DOCUMENT_NAMESPACE "")
398  endif ()
399 
400  if (NOT _paraview_build_SPDX_DOWNLOAD_LOCATION)
401  set(_paraview_build_SPDX_DOWNLOAD_LOCATION "")
402  endif ()
403 
404  if (NOT DEFINED _paraview_build_INSTALL_HEADERS)
405  set(_paraview_build_INSTALL_HEADERS ON)
406  endif ()
407 
408  if (NOT DEFINED _paraview_build_USE_FILE_SETS)
409  set(_paraview_build_USE_FILE_SETS OFF)
410  endif ()
411 
412  if (NOT DEFINED _paraview_build_ADD_INSTALL_RPATHS)
413  set(_paraview_build_ADD_INSTALL_RPATHS ON)
414  endif ()
415  if (_paraview_build_ADD_INSTALL_RPATHS)
416  if (NOT _paraview_build_LIBRARY_SUBDIRECTORY STREQUAL "")
417  file(RELATIVE_PATH _paraview_build_relpath
418  "/prefix/${_paraview_build_LIBRARY_DESTINATION}/${_paraview_build_LIBRARY_SUBDIRECTORY}/plugin"
419  "/prefix/${_paraview_build_LIBRARY_DESTINATION}")
420  else ()
421  file(RELATIVE_PATH _paraview_build_relpath
422  "/prefix/${_paraview_build_LIBRARY_DESTINATION}/plugin"
423  "/prefix/${_paraview_build_LIBRARY_DESTINATION}")
424  endif ()
425  if (APPLE)
426  list(APPEND CMAKE_INSTALL_RPATH
427  "@loader_path/${_paraview_build_relpath}")
428  elseif (UNIX)
429  list(APPEND CMAKE_INSTALL_RPATH
430  "$ORIGIN/${_paraview_build_relpath}")
431  endif ()
432  endif ()
433 
434  if (DEFINED _paraview_build_INSTALL_EXPORT
435  AND NOT DEFINED _paraview_build_TARGET)
436  message(FATAL_ERROR
437  "The `INSTALL_EXPORT` argument requires the `TARGET` argument.")
438  endif ()
439 
440  if (DEFINED _paraview_build_INSTALL_EXPORT
441  AND NOT DEFINED _paraview_build_CMAKE_DESTINATION)
442  message(FATAL_ERROR
443  "The `INSTALL_EXPORT` argument requires the `CMAKE_DESTINATION` argument.")
444  endif ()
445 
446  set(_paraview_build_extra_destinations)
447  if (DEFINED _paraview_build_CMAKE_DESTINATION)
448  list(APPEND _paraview_build_extra_destinations
449  CMAKE_DESTINATION)
450  if (NOT DEFINED _paraview_build_TARGET)
451  message(FATAL_ERROR
452  "The `CMAKE_DESTINATION` argument requires the `TARGET` argument.")
453  endif ()
454  endif ()
455 
456  if (DEFINED _paraview_build_TARGET)
457  _vtk_module_split_module_name("${_paraview_build_TARGET}" _paraview_build)
458  string(REPLACE "::" "_" _paraview_build_target_safe "${_paraview_build_TARGET}")
459  endif ()
460 
461  _vtk_module_check_destinations(_paraview_build_
462  HEADERS_DESTINATION
463  RUNTIME_DESTINATION
464  LIBRARY_DESTINATION
465  LIBRARY_SUBDIRECTORY
466  ${_paraview_build_extra_destinations})
467 
468  if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
469  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${_paraview_build_RUNTIME_DESTINATION}")
470  endif ()
471  if (NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
472  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${_paraview_build_LIBRARY_DESTINATION}")
473  endif ()
474  if (NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
475  set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${_paraview_build_LIBRARY_DESTINATION}")
476  endif ()
477 
478  if (WIN32)
479  set(_paraview_build_plugin_destination "${_paraview_build_RUNTIME_DESTINATION}")
480  else ()
481  set(_paraview_build_plugin_destination "${_paraview_build_LIBRARY_DESTINATION}")
482  endif ()
483  if (NOT _paraview_build_LIBRARY_SUBDIRECTORY STREQUAL "")
484  string(APPEND _paraview_build_plugin_destination "/${_paraview_build_LIBRARY_SUBDIRECTORY}")
485  endif ()
486 
487  foreach (_paraview_build_plugin IN LISTS _paraview_build_PLUGINS)
488  get_property(_paraview_build_plugin_file GLOBAL
489  PROPERTY "_paraview_plugin_${_paraview_build_plugin}_file")
490  if (NOT _paraview_build_plugin_file)
491  message(FATAL_ERROR
492  "The requested ${_paraview_build_plugin} plugin is not a ParaView plugin.")
493  endif ()
494 
495  _paraview_plugin_debug(building "@_paraview_build_plugin@ is being built")
496 
497  # Make a variable for where the plugin should go.
498  set(_paraview_build_plugin_directory
499  "${_paraview_build_plugin_destination}/${_paraview_build_plugin}")
500 
501  # TODO: Support external plugins?
502  get_filename_component(_paraview_build_plugin_dir "${_paraview_build_plugin_file}" DIRECTORY)
503  file(RELATIVE_PATH _paraview_build_plugin_subdir "${CMAKE_SOURCE_DIR}" "${_paraview_build_plugin_dir}")
504  add_subdirectory(
505  "${CMAKE_SOURCE_DIR}/${_paraview_build_plugin_subdir}"
506  "${CMAKE_BINARY_DIR}/${_paraview_build_plugin_subdir}")
507  endforeach ()
508 
509  if (DEFINED _paraview_build_TARGET)
510  add_library("${_paraview_build_TARGET_NAME}" INTERFACE)
511  if (_paraview_build_NAMESPACE)
512  add_library("${_paraview_build_TARGET}" ALIAS "${_paraview_build_TARGET_NAME}")
513  endif ()
514  target_include_directories("${_paraview_build_TARGET_NAME}"
515  INTERFACE
516  "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_paraview_build_target_safe}>"
517  "$<INSTALL_INTERFACE:${_paraview_build_HEADERS_DESTINATION}>")
518  set(_paraview_build_include_file
519  "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_paraview_build_target_safe}/${_paraview_build_target_safe}.h")
520 
521  set(_paraview_static_plugins)
522  foreach (_paraview_build_plugin IN LISTS _paraview_build_PLUGINS)
523  get_property(_paraview_build_plugin_type
524  TARGET "${_paraview_build_plugin}"
525  PROPERTY TYPE)
526  if (_paraview_build_plugin_type STREQUAL "STATIC_LIBRARY")
527  list(APPEND _paraview_static_plugins
528  "${_paraview_build_plugin}")
529  endif ()
530  endforeach ()
531 
532  if (_paraview_static_plugins)
533  target_link_libraries("${_paraview_build_TARGET_NAME}"
534  INTERFACE
535  ParaView::RemotingCore
536  ${_paraview_static_plugins})
537 
538  set(_paraview_build_declarations)
539  set(_paraview_build_calls)
540  set(_paraview_build_names)
541  foreach (_paraview_build_plugin IN LISTS _paraview_static_plugins)
542  string(APPEND _paraview_build_declarations
543  "PV_PLUGIN_IMPORT_INIT(${_paraview_build_plugin});\n")
544  string(APPEND _paraview_build_calls
545  " if (sname == \"${_paraview_build_plugin}\")
546  {
547  if (load)
548  {
549  static bool loaded = false;
550  if (!loaded)
551  {
552  loaded = PV_PLUGIN_IMPORT(${_paraview_build_plugin});
553  }
554  }
555  return true;
556  }\n\n")
557  string(APPEND _paraview_build_names
558  " names.emplace_back(\"${_paraview_build_plugin}\");\n")
559  endforeach ()
560 
561  set(_paraview_build_include_content
562  "#ifndef ${_paraview_build_target_safe}_h
563 #define ${_paraview_build_target_safe}_h
564 
565 #define PARAVIEW_BUILDING_PLUGIN
566 #define PARAVIEW_PLUGIN_BUILT_SHARED 0
567 #include \"vtkPVPlugin.h\"
568 #include \"vtkPVPluginLoader.h\"
569 #include \"vtkPVPluginTracker.h\"
570 #include <string>
571 
572 ${_paraview_build_declarations}
573 static bool ${_paraview_build_target_safe}_static_plugins_load(const char* name);
574 static bool ${_paraview_build_target_safe}_static_plugins_search(const char* name);
575 static void ${_paraview_build_target_safe}_static_plugins_list(const char* appname, std::vector<std::string>& names);
576 
577 static void ${_paraview_build_target_safe}_initialize()
578 {
579  vtkPVPluginLoader::RegisterLoadPluginCallback(${_paraview_build_target_safe}_static_plugins_load);
580  vtkPVPluginTracker::RegisterStaticPluginSearchFunction(${_paraview_build_target_safe}_static_plugins_search);
581  vtkPVPluginTracker::RegisterStaticPluginListFunction(${_paraview_build_target_safe}_static_plugins_list);
582 }
583 
584 static bool ${_paraview_build_target_safe}_static_plugins_func(const char* name, bool load);
585 
586 static bool ${_paraview_build_target_safe}_static_plugins_load(const char* name)
587 {
588  return ${_paraview_build_target_safe}_static_plugins_func(name, true);
589 }
590 
591 static bool ${_paraview_build_target_safe}_static_plugins_search(const char* name)
592 {
593  return ${_paraview_build_target_safe}_static_plugins_func(name, false);
594 }
595 
596 static void ${_paraview_build_target_safe}_static_plugins_list(const char* appname, std::vector<std::string>& names)
597 {
598 ${_paraview_build_names}
599  (void) appname;
600  (void) names;
601 }
602 
603 static bool ${_paraview_build_target_safe}_static_plugins_func(const char* name, bool load)
604 {
605  std::string const sname = name;
606 
607 ${_paraview_build_calls}
608  return false;
609 }
610 
611 #endif\n")
612  else ()
613  set(_paraview_build_include_content
614  "#ifndef ${_paraview_build_target_safe}_h
615 #define ${_paraview_build_target_safe}_h
616 
617 static void ${_paraview_build_target_safe}_initialize()
618 {
619 }
620 
621 #endif\n")
622  endif ()
623 
624  file(GENERATE
625  OUTPUT "${_paraview_build_include_file}"
626  CONTENT "${_paraview_build_include_content}")
627  if (_paraview_build_INSTALL_HEADERS)
628  install(
629  FILES "${_paraview_build_include_file}"
630  DESTINATION "${_paraview_build_HEADERS_DESTINATION}"
631  COMPONENT "${_paraview_build_TARGET_COMPONENT}")
632  endif ()
633 
634  if (DEFINED _paraview_build_INSTALL_EXPORT)
635  install(
636  TARGETS "${_paraview_build_TARGET_NAME}"
637  EXPORT "${_paraview_build_INSTALL_EXPORT}"
638  COMPONENT "${_paraview_build_TARGET_COMPONENT}")
639 
640  set(_paraview_build_required_exports_include_file_name "${_paraview_build_INSTALL_EXPORT}-${_paraview_build_TARGET_NAME}-targets-depends.cmake")
641  set(_paraview_build_required_exports_include_build_file
642  "${CMAKE_BINARY_DIR}/${_paraview_build_CMAKE_DESTINATION}/${_paraview_build_required_exports_include_file_name}")
643  set(_paraview_build_required_exports_include_contents "")
644  get_property(_paraview_build_required_exports GLOBAL
645  PROPERTY "paraview_plugin_${_paraview_build_TARGET}_required_exports")
646  if (_paraview_build_required_exports)
647  foreach (_paraview_build_required_export IN LISTS _paraview_build_required_exports)
648  string(APPEND _paraview_build_required_exports_include_contents
649  "include(\"\${CMAKE_CURRENT_LIST_DIR}/${_paraview_build_required_export}-targets.cmake\")\n"
650  "include(\"\${CMAKE_CURRENT_LIST_DIR}/${_paraview_build_required_export}-vtk-module-properties.cmake\")\n"
651  "\n")
652 
653  get_property(_paraview_build_modules GLOBAL
654  PROPERTY "paraview_plugin_${_paraview_build_required_export}_modules")
655  if (_paraview_build_modules)
656  vtk_module_export_find_packages(
657  CMAKE_DESTINATION "${_paraview_build_CMAKE_DESTINATION}"
658  FILE_NAME "${_paraview_build_required_export}-vtk-module-find-packages.cmake"
659  MODULES ${_paraview_build_modules})
660 
661  # TODO: The list of modules should be checked for their `_FOUND`
662  # variables being false and propagate it up through the parent
663  # project's `_FOUND` variable.
664  string(APPEND _paraview_build_required_exports_include_contents
665  "set(CMAKE_FIND_PACKAGE_NAME_save \"\${CMAKE_FIND_PACKAGE_NAME}\")\n"
666  "set(${_paraview_build_required_export}_FIND_QUIETLY \"\${\${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY}\")\n"
667  "set(${_paraview_build_required_export}_FIND_COMPONENTS)\n"
668  "set(CMAKE_FIND_PACKAGE_NAME \"${_paraview_build_required_export}\")\n"
669  "include(\"\${CMAKE_CURRENT_LIST_DIR}/${_paraview_build_required_export}-vtk-module-find-packages.cmake\")\n"
670  "set(CMAKE_FIND_PACKAGE_NAME \"\${CMAKE_FIND_PACKAGE_NAME_save}\")\n"
671  "unset(${_paraview_build_required_export}_FIND_QUIETLY)\n"
672  "unset(${_paraview_build_required_export}_FIND_COMPONENTS)\n"
673  "unset(CMAKE_FIND_PACKAGE_NAME_save)\n"
674  "\n"
675  "\n")
676  endif ()
677  endforeach ()
678  endif ()
679  file(GENERATE
680  OUTPUT "${_paraview_build_required_exports_include_build_file}"
681  CONTENT "${_paraview_build_required_exports_include_contents}")
682  if (_paraview_build_INSTALL_HEADERS)
683  install(
684  FILES "${_paraview_build_required_exports_include_build_file}"
685  DESTINATION "${_paraview_build_CMAKE_DESTINATION}"
686  COMPONENT "${_paraview_build_TARGET_COMPONENT}")
687  endif ()
688 
689  set(_paraview_build_namespace_args)
690  if (_paraview_build_NAMESPACE)
691  list(APPEND _paraview_build_namespace_args
692  NAMESPACE "${_paraview_build_NAMESPACE}::")
693  endif ()
694 
695  if (_paraview_build_INSTALL_HEADERS)
696  export(
697  EXPORT "${_paraview_build_INSTALL_EXPORT}"
698  ${_paraview_build_namespace_args}
699  FILE "${CMAKE_BINARY_DIR}/${_paraview_build_CMAKE_DESTINATION}/${_paraview_build_INSTALL_EXPORT}-targets.cmake")
700  install(
701  EXPORT "${_paraview_build_INSTALL_EXPORT}"
702  DESTINATION "${_paraview_build_CMAKE_DESTINATION}"
703  ${_paraview_build_namespace_args}
704  FILE "${_paraview_build_INSTALL_EXPORT}-targets.cmake"
705  COMPONENT "${_paraview_build_TARGET_COMPONENT}")
706  endif ()
707  endif ()
708  endif ()
709 
710  if (DEFINED _paraview_build_PLUGINS_FILE_NAME)
711  set(_paraview_build_xml_file
712  "${CMAKE_BINARY_DIR}/${_paraview_build_plugin_destination}/${_paraview_build_PLUGINS_FILE_NAME}")
713  set(_paraview_build_xml_content
714  "<?xml version=\"1.0\"?>\n<Plugins>\n")
715  foreach (_paraview_build_plugin IN LISTS _paraview_build_PLUGINS)
716 
717  # Make a variable for where the plugin should go.
718  set(_paraview_build_plugin_directory
719  "${_paraview_build_plugin_destination}/${_paraview_build_plugin}")
720 
721  # Recover different attributes of the plugin
722  set(_paraview_build_autoload 0)
723  if (_paraview_build_plugin IN_LIST _paraview_build_AUTOLOAD)
724  set(_paraview_build_autoload 1)
725  endif ()
726  set(_paraview_build_delayed_load 0)
727  if (_paraview_build_plugin IN_LIST _paraview_build_DELAYED_LOAD)
728  set(_paraview_build_delayed_load 1)
729  endif ()
730  get_property(_paraview_build_plugin_version GLOBAL
731  PROPERTY "_paraview_plugin_${_paraview_build_plugin}_version")
732  get_property(_paraview_build_plugin_description GLOBAL
733  PROPERTY "_paraview_plugin_${_paraview_build_plugin}_description")
734 
735  string(APPEND _paraview_build_xml_content
736  " <Plugin name=\"${_paraview_build_plugin}\" auto_load=\"${_paraview_build_autoload}\" delayed_load=\"${_paraview_build_delayed_load}\" version=\"${_paraview_build_plugin_version}\" description=\"${_paraview_build_plugin_description}\"")
737 
738  if (_paraview_build_delayed_load)
739  string(APPEND _paraview_build_xml_content ">\n")
740 
741  get_property(_paraview_build_plugin_delayed_load_xmls GLOBAL
742  PROPERTY "_paraview_plugin_${_paraview_build_plugin}_xmls")
743  foreach (_paraview_build_plugin_delayed_load_xml IN LISTS _paraview_build_plugin_delayed_load_xmls)
744  # Copy XML to build for easier usage
745  configure_file(${_paraview_build_plugin_delayed_load_xml} "${CMAKE_BINARY_DIR}/${_paraview_build_plugin_directory}" COPYONLY)
746 
747  # Add XML relative path to to plugin config file
748  cmake_path(GET _paraview_build_plugin_delayed_load_xml FILENAME _paraview_build_plugin_delayed_load_xml_name)
749  string(APPEND _paraview_build_xml_content " <XML filename=\"${_paraview_build_plugin}/${_paraview_build_plugin_delayed_load_xml_name}\"/>\n")
750  endforeach ()
751  string(APPEND _paraview_build_xml_content " </Plugin>\n")
752 
753  # Install XMLs
754  install(
755  FILES ${_paraview_build_plugin_delayed_load_xmls}
756  DESTINATION "${_paraview_build_plugin_directory}"
757  COMPONENT "${_paraview_build_TARGET_COMPONENT}")
758  else ()
759  string(APPEND _paraview_build_xml_content "/>\n")
760  endif ()
761 
762  endforeach ()
763  string(APPEND _paraview_build_xml_content
764  "</Plugins>\n")
765 
766  file(GENERATE
767  OUTPUT "${_paraview_build_xml_file}"
768  CONTENT "${_paraview_build_xml_content}")
769  install(
770  FILES "${_paraview_build_xml_file}"
771  DESTINATION "${_paraview_build_plugin_destination}"
772  COMPONENT "${_paraview_build_TARGET_COMPONENT}")
773 
774  if (DEFINED _paraview_build_INSTALL_EXPORT)
775  set_property(TARGET "${_paraview_build_TARGET_NAME}"
776  PROPERTY
777  "INTERFACE_paraview_plugin_plugins_file" "${_paraview_build_xml_file}")
778 
779  if (DEFINED _paraview_build_RUNTIME_DESTINATION)
780  set_property(TARGET "${_paraview_build_TARGET_NAME}"
781  PROPERTY
782  "INTERFACE_paraview_plugin_plugins_file_install" "${_paraview_build_plugin_destination}/${_paraview_build_PLUGINS_FILE_NAME}")
783  endif ()
784 
785  if (DEFINED _paraview_build_CMAKE_DESTINATION)
786  set(_paraview_build_properties_filename "${_paraview_build_INSTALL_EXPORT}-paraview-plugin-properties.cmake")
787  set(_paraview_build_properties_build_file
788  "${CMAKE_BINARY_DIR}/${_paraview_build_CMAKE_DESTINATION}/${_paraview_build_properties_filename}")
789  set(_paraview_build_properties_install_file
790  "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_paraview_build_properties_filename}.install")
791 
792  file(WRITE "${_paraview_build_properties_build_file}")
793  file(WRITE "${_paraview_build_properties_install_file}")
794 
795  _vtk_module_write_import_prefix(
796  "${_paraview_build_properties_install_file}"
797  "${_paraview_build_CMAKE_DESTINATION}")
798 
799  file(APPEND "${_paraview_build_properties_build_file}"
800  "set_property(TARGET \"${_paraview_build_TARGET}\"
801  PROPERTY
802  INTERFACE_paraview_plugin_plugins_file \"${_paraview_build_xml_file}\")\n")
803  file(APPEND "${_paraview_build_properties_install_file}"
804  "set_property(TARGET \"${_paraview_build_TARGET}\"
805  PROPERTY
806  INTERFACE_paraview_plugin_plugins_file \"\${_vtk_module_import_prefix}/${_paraview_build_plugin_destination}/${_paraview_build_PLUGINS_FILE_NAME}\")
807 unset(_vtk_module_import_prefix)\n")
808 
809  if (_paraview_build_INSTALL_HEADERS)
810  install(
811  FILES "${_paraview_build_properties_install_file}"
812  DESTINATION "${_paraview_build_CMAKE_DESTINATION}"
813  RENAME "${_paraview_build_properties_filename}"
814  COMPONENT "${_paraview_build_TARGET_COMPONENT}")
815  endif ()
816  endif ()
817  endif ()
818  endif ()
819 endfunction ()
820 
821 #[==[.md
822 ## Plugin configuration files
823 
824 Applications will want to consume plugin targets by discovering their locations
825 at runtime. In order to facilitate this, ParaView supports loading a `conf`
826 file which contains the locations of plugin targets' XML files. The plugins
827 specified in that file is then
828 
829 ```
831  NAME <name>
832  PLUGINS_TARGETS <target>...
833  BUILD_DESTINATION <destination>
834 
835  [INSTALL_DESTINATION <destination>]
836  [COMPONENT <component>])
837 ```
838 
839  * `NAME`: (Required) The base name of the configuration file.
840  * `PLUGINS_TARGETS`: (Required) The list of plugin targets to add to the
841  configuration file.
842  * `BUILD_DESTINATION`: (Required) Where to place the configuration file in
843  the build tree.
844  * `INSTALL_DESTINATION`: Where to install the configuration file in the
845  install tree. If not provided, the configuration file will not be
846  installed.
847  * `COMPONENT`: (Defaults to `runtime`) The component to use when installing
848  the configuration file.
849 #]==]
851  cmake_parse_arguments(_paraview_plugin_conf
852  ""
853  "NAME;BUILD_DESTINATION;INSTALL_DESTINATION;COMPONENT"
854  "PLUGINS_TARGETS"
855  ${ARGN})
856 
857  if (_paraview_plugin_conf_UNPARSED_ARGUMENTS)
858  message(FATAL_ERROR
859  "Unparsed arguments for paraview_plugin_write_conf: "
860  "${_paraview_plugin_conf_UNPARSED_ARGUMENTS}")
861  endif ()
862 
863  if (NOT _paraview_plugin_conf_NAME)
864  message(FATAL_ERROR
865  "The `NAME` must not be empty.")
866  endif ()
867 
868  if (NOT DEFINED _paraview_plugin_conf_BUILD_DESTINATION)
869  message(FATAL_ERROR
870  "The `BUILD_DESTINATION` argument is required.")
871  endif ()
872 
873  if (NOT DEFINED _paraview_plugin_conf_PLUGINS_TARGETS)
874  message(FATAL_ERROR
875  "The `PLUGINS_TARGETS` argument is required.")
876  endif ()
877 
878  if (NOT DEFINED _paraview_plugin_conf_COMPONENT)
879  set(_paraview_plugin_conf_COMPONENT "runtime")
880  endif ()
881 
882  set(_paraview_plugin_conf_file_name
883  "${_paraview_plugin_conf_NAME}.conf")
884  set(_paraview_plugin_conf_build_file
885  "${CMAKE_BINARY_DIR}/${_paraview_plugin_conf_BUILD_DESTINATION}/${_paraview_plugin_conf_file_name}")
886  set(_paraview_plugin_conf_install_file
887  "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_paraview_plugin_conf_file_name}.install")
888  set(_paraview_plugin_conf_build_contents)
889  set(_paraview_plugin_conf_install_contents)
890  foreach (_paraview_plugin_conf_target IN LISTS _paraview_plugin_conf_PLUGINS_TARGETS)
891  get_property(_paraview_plugin_conf_plugins_target_is_imported
892  TARGET "${_paraview_plugin_conf_target}"
893  PROPERTY IMPORTED)
894  if (_paraview_plugin_conf_plugins_target_is_imported)
895  get_property(_paraview_plugin_conf_plugins_target_xml_build
896  TARGET "${_paraview_plugin_conf_target}"
897  PROPERTY "INTERFACE_paraview_plugin_plugins_file")
898  set(_paraview_plugin_conf_plugins_target_xml_install
899  "${_paraview_plugin_conf_plugins_target_xml_build}")
900 
901  file(RELATIVE_PATH _paraview_plugin_conf_rel_path
902  "/prefix/${CMAKE_INSTALL_PREFIX}"
903  "/prefix/${_paraview_plugin_conf_plugins_target_xml_install}")
904  # If the external plugins XML file is under our installation destination,
905  # use a relative path to it, otherwise keep the absolute path.
906  if (NOT _paraview_plugin_conf_rel_path MATCHES "^\.\./")
907  file(RELATIVE_PATH _paraview_plugin_conf_plugins_target_xml_install
908  "/prefix/${CMAKE_INSTALL_PREFIX}/${_paraview_plugin_conf_INSTALL_DESTINATION}"
909  "/prefix/${_paraview_plugin_conf_plugins_target_xml_install}")
910  endif ()
911  else ()
912  get_property(_paraview_plugin_conf_plugins_target_is_alias
913  TARGET "${_paraview_plugin_conf_target}"
914  PROPERTY ALIASED_TARGET
915  SET)
916  if (_paraview_plugin_conf_plugins_target_is_alias)
917  get_property(_paraview_plugin_conf_target
918  TARGET "${_paraview_plugin_conf_target}"
919  PROPERTY ALIASED_TARGET)
920  endif ()
921  get_property(_paraview_plugin_conf_plugins_target_xml_build
922  TARGET "${_paraview_plugin_conf_target}"
923  PROPERTY "INTERFACE_paraview_plugin_plugins_file")
924  get_property(_paraview_plugin_conf_plugins_target_xml_install
925  TARGET "${_paraview_plugin_conf_target}"
926  PROPERTY "INTERFACE_paraview_plugin_plugins_file_install")
927 
928  if (_paraview_plugin_conf_plugins_target_xml_install)
929  # Compute the relative path within the install tree.
930  file(RELATIVE_PATH _paraview_plugin_conf_plugins_target_xml_install
931  "/prefix/${_paraview_plugin_conf_INSTALL_DESTINATION}"
932  "/prefix/${_paraview_plugin_conf_plugins_target_xml_install}")
933  endif ()
934  endif ()
935 
936  # TODO: Write out in JSON instead.
937  if (_paraview_plugin_conf_plugins_target_xml_build)
938  string(APPEND _paraview_plugin_conf_build_contents
939  "${_paraview_plugin_conf_plugins_target_xml_build}\n")
940  endif ()
941  if (_paraview_plugin_conf_plugins_target_xml_install)
942  string(APPEND _paraview_plugin_conf_install_contents
943  "${_paraview_plugin_conf_plugins_target_xml_install}\n")
944  endif ()
945  endforeach ()
946 
947  file(GENERATE
948  OUTPUT "${_paraview_plugin_conf_build_file}"
949  CONTENT "${_paraview_plugin_conf_build_contents}")
950 
951  if (_paraview_plugin_conf_INSTALL_DESTINATION)
952  file(GENERATE
953  OUTPUT "${_paraview_plugin_conf_install_file}"
954  CONTENT "${_paraview_plugin_conf_install_contents}")
955  install(
956  FILES "${_paraview_plugin_conf_install_file}"
957  DESTINATION "${_paraview_plugin_conf_INSTALL_DESTINATION}"
958  RENAME "${_paraview_plugin_conf_file_name}"
959  COMPONENT "${_paraview_plugin_conf_COMPONENT}")
960  endif ()
961 endfunction ()
962 
963 set(_paraview_plugin_source_dir "${CMAKE_CURRENT_LIST_DIR}")
964 
965 #[==[.md
966 ## Adding a plugin
967 
968 TODO: Describe.
969 
970 ```
972  [REQUIRED_ON_SERVER] [REQUIRED_ON_CLIENT]
973  VERSION <version>
974 
975  [MODULE_FILES <vtk.module>...]
976  [MODULE_ARGS <arg>...]
977  [MODULES <module>...]
978  [SOURCES <source>...]
979  [SERVER_MANAGER_XML <xml>...]
980  [MODULE_INSTALL_EXPORT <export>]
981 
982  [UI_INTERFACES <interface>...]
983  [UI_RESOURCES <resource>...]
984  [UI_FILES <file>...]
985 
986  [PYTHON_MODULES <module>...]
987 
988  [INITIALIZERS <initializerFunction>...]
989 
990  [EXTRA_INCLUDES <file>...]
991 
992  [REQUIRED_PLUGINS <plugin>...]
993 
994  [EULA <eula>]
995  [XML_DOCUMENTATION <ON|OFF>]
996  [DOCUMENTATION_DIR <directory>]
997  [DOCUMENTATION_ADD_PATTERNS <pattern>...]
998  [DOCUMENTATION_TOC <string>]
999  [DOCUMENTATION_DEPENDENCIES <target>...]
1000 
1001  [FORCE_STATIC <ON|OFF>])
1002 
1003  [TRANSLATIONS_DIRECTORY <directory>]
1004  [TRANSLATIONS_TARGET <target>]
1005 ```
1006 
1007  * `REQUIRED_ON_SERVER`: The plugin is required to be loaded on the server for
1008  proper functionality.
1009  * `REQUIRED_ON_CLIENT`: The plugin is required to be loaded on the client for
1010  proper functionality.
1011  * `VERSION`: (Required) The version number of the plugin.
1012  * `MODULE_FILES`: Paths to `vtk.module` files describing modules to include
1013  in the plugin.
1014  * `MODULE_ARGS`: Arguments to pass to `vtk_module_build` for included modules.
1015  * `MODULES`: Modules to include in the plugin. These modules will be wrapped
1016  using client server and have their server manager XML files processed.
1017  * `SOURCES`: Source files for the plugin.
1018  * `SERVER_MANAGER_XML`: Server manager XML files for the plugin.
1019  * `UI_INTERFACES`: Interfaces to initialize, in the given order. See the
1020  plugin interfaces section for more details.
1021  * `MODULE_INSTALL_EXPORT`: (Defaults to `<name>`) If provided, any modules
1022  will be added to the given export set.
1023  * `UI_RESOURCES`: Qt resource files to include with the plugin.
1024  * `UI_FILES`: Qt `.ui` files to include with the plugin.
1025  * `PYTHON_MODULES`: Python modules to embed into the plugin. Each entry should be a valid single-file Python plugin.
1026  Relative import between them is not supported. Thus Python packages are not supported.
1027  * `INITIALIZERS`: An ordered list of free functions (declared in `EXTRA_INCLUDES`
1028  if needed) to be invoked when the plugin is loaded. Each function must be
1029  callable with no arguments.
1030  * `EXTRA_INCLUDES`: Headers needed by the generated plugin code (such as `INITIALIZERS`).
1031  Filename paths passed without quotes will be double-quoted (e.g., \verbatim`#include "foo.h"`\endverbatim),
1032  while paths that start with angle- or double-quotes will not be.
1033  * `REQUIRED_PLUGINS`: Plugins which must be loaded for this plugin to
1034  function. These plugins do not need to be available at build time and are
1035  therefore their existence is not checked here.
1036  * `EULA`: A file with content to display as an end-user license agreement
1037  before the plugin is initialized at runtime.
1038  * `XML_DOCUMENTATION`: (Defaults to `ON`) If set, documentation will be
1039  generated for the associated XML files.
1040  * `DOCUMENTATION_DIR`: If specified, `*.html`, `*.css`, `*.png`, `*.js`, and `*.jpg`
1041  files in this directory will be copied and made available to the
1042  documentation.
1043  * `DOCUMENTATION_ADD_PATTERNS`: If specified, adds patterns for the documentation files
1044  within `DOCUMENTATION_DIR` other than the default ones (see `DOCUMENTATION_DIR` help)
1045  * `DOCUMENTATION_TOC`: If specified, use this string for describing the table of
1046  content for the documentation.
1047  * `DOCUMENTATION_DEPENDENCIES`: Targets that are needed to be built before
1048  building the documentation.
1049  * `EXPORT`: (Deprecated) Use `paraview_plugin_build(INSTALL_EXPORT)` instead.
1050  * `FORCE_STATIC`: (Defaults to `OFF`) If set, the plugin will be built
1051  statically so that it can be embedded into an application.
1052  * `TRANSLATIONS_DIRECTORY`: (Defaults to `${CMAKE_CURRENT_BINARY_DIR}/Translations`)
1053  The path of the directory where translation source files are stored.
1054  * `TRANSLATION_TARGET` : The name of the target on which to add the ts file as
1055  dependency.
1056 #]==]
1058  if (NOT name STREQUAL _paraview_build_plugin)
1059  message(FATAL_ERROR
1060  "The ${_paraview_build_plugin}'s CMakeLists.txt may not add the ${name} "
1061  "plugin.")
1062  endif ()
1063 
1064  cmake_parse_arguments(_paraview_add_plugin
1065  "REQUIRED_ON_SERVER;REQUIRED_ON_CLIENT"
1066  "VERSION;EULA;EXPORT;MODULE_INSTALL_EXPORT;XML_DOCUMENTATION;DOCUMENTATION_DIR;FORCE_STATIC;DOCUMENTATION_TOC;TRANSLATIONS_DIRECTORY;TRANSLATIONS_TARGET"
1067  "REQUIRED_PLUGINS;SERVER_MANAGER_XML;SOURCES;MODULES;UI_INTERFACES;UI_RESOURCES;UI_FILES;PYTHON_MODULES;MODULE_FILES;MODULE_ARGS;DOCUMENTATION_ADD_PATTERNS;DOCUMENTATION_DEPENDENCIES;INITIALIZERS;EXTRA_INCLUDES"
1068  ${ARGN})
1069 
1070  if (_paraview_add_plugin_UNPARSED_ARGUMENTS)
1071  message(FATAL_ERROR
1072  "Unparsed arguments for paraview_add_plugin: "
1073  "${_paraview_add_plugin_UNPARSED_ARGUMENTS}")
1074  endif ()
1075 
1076  if (NOT DEFINED _paraview_add_plugin_VERSION)
1077  message(FATAL_ERROR
1078  "The `VERSION` argument is required.")
1079  endif ()
1080  set_property(GLOBAL
1081  PROPERTY
1082  "_paraview_plugin_${name}_version" "${_paraview_add_plugin_VERSION}")
1083 
1084  if (NOT DEFINED _paraview_add_plugin_XML_DOCUMENTATION)
1085  set(_paraview_add_plugin_XML_DOCUMENTATION ON)
1086  endif ()
1087  if (DEFINED _paraview_add_plugin_DOCUMENTATION_DIR AND
1088  NOT _paraview_add_plugin_XML_DOCUMENTATION)
1089  message(FATAL_ERROR
1090  "Specifying `DOCUMENTATION_DIR` and turning off `XML_DOCUMENTATION` "
1091  "makes no sense.")
1092  endif ()
1093  if (_paraview_build_DISABLE_XML_DOCUMENTATION)
1094  set(_paraview_add_plugin_XML_DOCUMENTATION OFF)
1095  endif ()
1096 
1097  if (NOT DEFINED _paraview_add_plugin_FORCE_STATIC)
1098  set(_paraview_add_plugin_FORCE_STATIC OFF)
1099  endif ()
1100 
1101  if (DEFINED _paraview_add_plugin_EXPORT)
1102  message(FATAL_ERROR
1103  "The `paraview_add_plugin(EXPORT)` argument is ignored in favor of "
1104  "`paraview_plugin_build(INSTALL_EXPORT)`.")
1105  endif ()
1106 
1107  if (_paraview_add_plugin_MODULE_ARGS)
1108  if (NOT _paraview_add_plugin_MODULE_FILES OR
1109  NOT _paraview_add_plugin_MODULES)
1110  message(FATAL_ERROR
1111  "The `MODULE_ARGS` argument requires `MODULE_FILES` and `MODULES` to be provided.")
1112  endif ()
1113  endif ()
1114 
1115  if (_paraview_add_plugin_UI_INTERFACES OR _paraview_add_plugin_UI_FILES OR _paraview_add_plugin_UI_RESOURCES)
1116  if (NOT PARAVIEW_USE_QT)
1117  message(FATAL_ERROR "UI_INTERFACES, UI_FILES and UI_RESOURCES require ParaView to be built with Qt enabled.")
1118  endif()
1119  endif()
1120 
1121  if (DEFINED _paraview_build_INSTALL_EXPORT AND
1122  NOT DEFINED _paraview_add_plugin_MODULE_INSTALL_EXPORT)
1123  set(_paraview_add_plugin_MODULE_INSTALL_EXPORT
1124  "${name}")
1125  endif ()
1126 
1127  if (_paraview_add_plugin_MODULE_FILES)
1128  if (NOT _paraview_add_plugin_MODULES)
1129  message(FATAL_ERROR
1130  "The `MODULE_FILES` argument requires `MODULES` to be provided.")
1131  endif ()
1132 
1133  if (_paraview_build_ADD_INSTALL_RPATHS)
1134  if (APPLE)
1135  list(INSERT CMAKE_INSTALL_RPATH 0
1136  "@loader_path")
1137  elseif (UNIX)
1138  list(INSERT CMAKE_INSTALL_RPATH 0
1139  "$ORIGIN")
1140  endif ()
1141  endif ()
1142 
1143  set(_paraview_add_plugin_module_install_export_args)
1144  if (DEFINED _paraview_add_plugin_MODULE_INSTALL_EXPORT)
1145  list(APPEND _paraview_add_plugin_module_install_export_args
1146  INSTALL_EXPORT "${_paraview_add_plugin_MODULE_INSTALL_EXPORT}")
1147  if (DEFINED _paraview_build_TARGET)
1148  set_property(GLOBAL APPEND
1149  PROPERTY
1150  "paraview_plugin_${_paraview_build_TARGET}_required_exports" "${_paraview_add_plugin_MODULE_INSTALL_EXPORT}")
1151  endif ()
1152  endif ()
1153 
1154  vtk_module_scan(
1155  MODULE_FILES ${_paraview_add_plugin_MODULE_FILES}
1156  REQUEST_MODULES ${_paraview_add_plugin_MODULES}
1157  PROVIDES_MODULES plugin_modules
1158  REQUIRES_MODULES required_modules
1159  HIDE_MODULES_FROM_CACHE ON)
1160 
1161  if (required_modules)
1162  foreach (required_module IN LISTS required_modules)
1163  if (NOT TARGET "${required_module}")
1164  message(FATAL_ERROR
1165  "Failed to find the required module ${required_module}.")
1166  endif ()
1167  endforeach ()
1168  endif ()
1169 
1170  if (WIN32)
1171  set(_paraview_plugin_subdir "${_paraview_build_RUNTIME_DESTINATION}")
1172  else ()
1173  set(_paraview_plugin_subdir "${_paraview_build_LIBRARY_DESTINATION}")
1174  endif ()
1175  if (NOT _paraview_build_LIBRARY_SUBDIRECTORY STREQUAL "")
1176  string(APPEND _paraview_plugin_subdir "/${_paraview_build_LIBRARY_SUBDIRECTORY}")
1177  endif ()
1178  string(APPEND _paraview_plugin_subdir "/${_paraview_build_plugin}")
1179  set(_paraview_plugin_CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
1180  set(_paraview_plugin_CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
1181  set(_paraview_plugin_CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}")
1182  set(_paraview_plugin_CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_NAME_DIR}")
1183  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${_paraview_plugin_subdir}")
1184  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${_paraview_plugin_subdir}")
1185  set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${_paraview_plugin_subdir}")
1186  set(CMAKE_INSTALL_NAME_DIR "@loader_path")
1187 
1188  vtk_module_build(
1189  MODULES ${plugin_modules}
1190  PACKAGE "${_paraview_build_plugin}"
1191  USE_FILE_SETS "${_paraview_build_USE_FILE_SETS}"
1192  ${_paraview_add_plugin_module_install_export_args}
1193  INSTALL_HEADERS "${_paraview_build_INSTALL_HEADERS}"
1194  TARGETS_COMPONENT "${_paraview_build_PLUGINS_COMPONENT}"
1195  HEADERS_DESTINATION "${_paraview_build_HEADERS_DESTINATION}/${_paraview_build_target_safe}"
1196  ARCHIVE_DESTINATION "${_paraview_plugin_subdir}"
1197  LIBRARY_DESTINATION "${_paraview_plugin_subdir}"
1198  RUNTIME_DESTINATION "${_paraview_plugin_subdir}"
1199  CMAKE_DESTINATION "${_paraview_build_CMAKE_DESTINATION}"
1200  ${_paraview_add_plugin_MODULE_ARGS}
1201  GENERATE_SPDX "${_paraview_build_GENERATE_SPDX}"
1202  SPDX_DOCUMENT_NAMESPACE "${_paraview_build_SPDX_DOCUMENT_NAMESPACE}"
1203  SPDX_DOWNLOAD_LOCATION "${_paraview_build_SPDX_DOWNLOAD_LOCATION}")
1204 
1205  set_property(GLOBAL APPEND
1206  PROPERTY
1207  "paraview_plugin_${_paraview_add_plugin_MODULE_INSTALL_EXPORT}_modules" "${plugin_modules}")
1208 
1209  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${_paraview_plugin_CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
1210  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${_paraview_plugin_CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
1211  set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${_paraview_plugin_CMAKE_ARCHIVE_OUTPUT_DIRECTORY}")
1212  set(CMAKE_INSTALL_NAME_DIR "${_paraview_plugin_CMAKE_INSTALL_NAME_DIR}")
1213  unset(_paraview_plugin_CMAKE_RUNTIME_OUTPUT_DIRECTORY)
1214  unset(_paraview_plugin_CMAKE_LIBRARY_OUTPUT_DIRECTORY)
1215  unset(_paraview_plugin_CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
1216  unset(_paraview_plugin_CMAKE_INSTALL_NAME_DIR)
1217  endif ()
1218 
1219  # TODO: resource initialization for static builds
1220 
1221  if (_paraview_add_plugin_REQUIRED_ON_SERVER)
1222  set(_paraview_add_plugin_required_on_server "true")
1223  else ()
1224  set(_paraview_add_plugin_required_on_server "false")
1225  endif ()
1226 
1227  if (_paraview_add_plugin_REQUIRED_ON_CLIENT)
1228  set(_paraview_add_plugin_required_on_client "true")
1229  else ()
1230  set(_paraview_add_plugin_required_on_client "false")
1231  endif ()
1232 
1233  set(_paraview_add_plugin_export_args)
1234  set(_paraview_add_plugin_install_export_args)
1235  if (DEFINED _paraview_build_INSTALL_EXPORT)
1236  list(APPEND _paraview_add_plugin_export_args
1237  EXPORT "${_paraview_build_INSTALL_EXPORT}")
1238  list(APPEND _paraview_add_plugin_install_export_args
1239  INSTALL_EXPORT "${_paraview_build_INSTALL_EXPORT}")
1240  endif ()
1241 
1242  set(_paraview_add_plugin_includes)
1243  set(_paraview_add_plugin_required_libraries)
1244 
1245  if (_paraview_add_plugin_EXTRA_INCLUDES)
1246  foreach (_include IN LISTS _paraview_add_plugin_EXTRA_INCLUDES)
1247  if ((${_include} MATCHES "^\".*\"$") OR (${_include} MATCHES "^<.*>$"))
1248  string(APPEND _paraview_add_plugin_includes "#include ${_include}\n")
1249  else ()
1250  string(APPEND _paraview_add_plugin_includes "#include \"${_include}\"\n")
1251  endif ()
1252  endforeach ()
1253  endif ()
1254 
1255  set(_paraview_add_plugin_module_xmls)
1257  if (_paraview_add_plugin_MODULES)
1259 
1260  list(APPEND _paraview_add_plugin_required_libraries
1261  ${_paraview_add_plugin_MODULES})
1262 
1264  MODULES ${_paraview_add_plugin_MODULES}
1265  TARGET "${_paraview_build_plugin}_client_server"
1266  ${_paraview_add_plugin_install_export_args})
1267 
1268  if (NOT DEFINED _paraview_add_plugin_TRANSLATIONS_DIRECTORY)
1269  set(_paraview_add_plugin_TRANSLATIONS_DIRECTORY
1270  "${CMAKE_CURRENT_BINARY_DIR}/Translations")
1271  endif ()
1272  set(_paraview_add_plugin_translation_args)
1273  if (_paraview_add_plugin_TRANSLATIONS_DIRECTORY AND _paraview_add_plugin_TRANSLATIONS_TARGET)
1274  list(APPEND _paraview_add_plugin_translation_args
1275  TRANSLATIONS_DIRECTORY "${_paraview_add_plugin_TRANSLATIONS_DIRECTORY}")
1276  list(APPEND _paraview_add_plugin_translation_args
1277  TRANSLATIONS_TARGET "${_paraview_add_plugin_TRANSLATIONS_TARGET}")
1278  endif ()
1279 
1281  MODULES ${_paraview_add_plugin_MODULES}
1282  TARGET "${_paraview_build_plugin}_server_manager_modules"
1283  ${_paraview_add_plugin_install_export_args}
1284  XML_FILES _paraview_add_plugin_module_xmls
1285  ${_paraview_add_plugin_translation_args})
1286 
1287  list(APPEND _paraview_add_plugin_required_libraries
1288  "${_paraview_build_plugin}_client_server"
1289  "${_paraview_build_plugin}_server_manager_modules")
1290  endif ()
1291 
1292  set(_paraview_add_plugin_binary_resources "")
1293  set(_paraview_add_plugin_binary_headers)
1294  if (_paraview_add_plugin_SERVER_MANAGER_XML)
1296 
1297  set(_paraview_add_plugin_xmls)
1298  foreach (_paraview_add_plugin_xml IN LISTS _paraview_add_plugin_SERVER_MANAGER_XML)
1299  if (NOT IS_ABSOLUTE "${_paraview_add_plugin_xml}")
1300  set(_paraview_add_plugin_xml "${CMAKE_CURRENT_SOURCE_DIR}/${_paraview_add_plugin_xml}")
1301  endif ()
1302 
1303  list(APPEND _paraview_add_plugin_xmls
1304  "${_paraview_add_plugin_xml}")
1305  endforeach ()
1306 
1307  set_property(GLOBAL APPEND
1308  PROPERTY
1309  "_paraview_plugin_${_paraview_build_plugin}_xmls" "${_paraview_add_plugin_xmls}")
1310 
1312  TARGET "${_paraview_build_plugin}_server_manager"
1313  ${_paraview_add_plugin_install_export_args}
1314  FILES ${_paraview_add_plugin_xmls})
1315  list(APPEND _paraview_add_plugin_required_libraries
1316  "${_paraview_build_plugin}_server_manager")
1317  endif ()
1318 
1319  if ((_paraview_add_plugin_module_xmls OR _paraview_add_plugin_xmls) AND
1320  PARAVIEW_USE_QT AND _paraview_add_plugin_XML_DOCUMENTATION)
1321  set(_paraview_build_plugin_docdir
1322  "${CMAKE_CURRENT_BINARY_DIR}/paraview_help")
1323 
1325  TARGET "${_paraview_build_plugin}_doc"
1326  OUTPUT_DIR "${_paraview_build_plugin_docdir}"
1327  XMLS ${_paraview_add_plugin_module_xmls}
1328  ${_paraview_add_plugin_xmls})
1329 
1330  set(_paraview_build_plugin_doc_source_args)
1331  if (DEFINED _paraview_add_plugin_DOCUMENTATION_DIR)
1332  list(APPEND _paraview_build_plugin_doc_source_args
1333  SOURCE_DIR "${_paraview_add_plugin_DOCUMENTATION_DIR}")
1334  endif ()
1335 
1337  NAME "${_paraview_build_plugin}"
1338  OUTPUT_PATH _paraview_build_plugin_qch_path
1339  OUTPUT_DIR "${_paraview_build_plugin_docdir}"
1340  TARGET "${_paraview_build_plugin}_qch"
1341  ${_paraview_build_plugin_doc_source_args}
1342  TABLE_OF_CONTENTS "${_paraview_add_plugin_DOCUMENTATION_TOC}"
1343  DEPENDS "${_paraview_build_plugin}_doc"
1344  "${_paraview_add_plugin_DOCUMENTATION_DEPENDENCIES}"
1345  PATTERNS "*.html" "*.css" "*.png" "*.jpg" "*.js"
1346  ${_paraview_add_plugin_DOCUMENTATION_ADD_PATTERNS})
1347 
1348  set(_paraview_add_plugin_depends_args)
1349  if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.27")
1350  list(APPEND _paraview_add_plugin_depends_args
1351  DEPENDS_EXPLICIT_ONLY)
1352  endif ()
1353 
1354  list(APPEND _paraview_add_plugin_extra_include_dirs
1355  "${CMAKE_CURRENT_BINARY_DIR}")
1356  set(_paraview_add_plugin_qch_output
1357  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_build_plugin}_qch.h")
1358  list(APPEND _paraview_add_plugin_binary_headers
1359  "${_paraview_add_plugin_qch_output}")
1360  add_custom_command(
1361  OUTPUT "${_paraview_add_plugin_qch_output}"
1362  COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR}
1363  "$<TARGET_FILE:ParaView::ProcessXML>"
1364  -base64
1365  "${_paraview_add_plugin_qch_output}"
1366  \"\"
1367  "_qch"
1368  "_qch"
1369  "${_paraview_build_plugin_qch_path}"
1370  DEPENDS "${_paraview_build_plugin_qch_path}"
1371  "${_paraview_build_plugin}_qch"
1372  "$<TARGET_FILE:ParaView::ProcessXML>"
1373  COMMENT "Generating header for ${_paraview_build_plugin} documentation"
1374  ${_paraview_add_plugin_depends_args})
1375  set_property(SOURCE "${_paraview_add_plugin_qch_output}"
1376  PROPERTY
1377  SKIP_AUTOMOC 1)
1378 
1379  string(APPEND _paraview_add_plugin_includes
1380  "#include \"${_paraview_build_plugin}_qch.h\"\n")
1381  string(APPEND _paraview_add_plugin_binary_resources
1382  " {
1383  const char *text = ${_paraview_build_plugin}_qch();
1384  resources.emplace_back(text);
1385  delete [] text;
1386  }\n")
1387  endif ()
1388 
1389  set(_paraview_add_plugin_eula_sources)
1390  if (_paraview_add_plugin_EULA)
1391  vtk_encode_string(
1392  INPUT "${_paraview_add_plugin_EULA}"
1393  NAME "${_paraview_build_plugin}_EULA"
1394  HEADER_OUTPUT _paraview_add_plugin_eula_header
1395  SOURCE_OUTPUT _paraview_add_plugin_eula_source)
1396  list(APPEND _paraview_add_plugin_eula_sources
1397  "${_paraview_add_plugin_eula_header}"
1398  "${_paraview_add_plugin_eula_source}")
1399  endif ()
1400 
1402  set(_paraview_add_plugin_ui_sources)
1403  if (_paraview_add_plugin_UI_INTERFACES)
1405  set(CMAKE_AUTOMOC 1)
1406  set(_paraview_add_plugin_push_back_interfaces
1407  "#define PARAVIEW_ADD_INTERFACES(arg) \\\n")
1408  set(_paraview_add_plugin_include_interfaces "")
1409 
1410  foreach (_paraview_add_plugin_ui_interface IN LISTS _paraview_add_plugin_UI_INTERFACES)
1411  string(APPEND _paraview_add_plugin_push_back_interfaces
1412  " (arg).push_back(new ${_paraview_add_plugin_ui_interface}(this)); \\\n")
1413  string(APPEND _paraview_add_plugin_include_interfaces
1414  "#include \"${_paraview_add_plugin_ui_interface}.h\"\n")
1415  endforeach ()
1416  list(APPEND _paraview_add_plugin_required_libraries
1417  ParaView::pqComponents)
1418  endif ()
1419 
1421  if (_paraview_add_plugin_INITIALIZERS)
1423  set(_paraview_add_plugin_invoke_initializers)
1424 
1425  foreach (_paraview_add_plugin_initializer IN LISTS _paraview_add_plugin_INITIALIZERS)
1426  string(APPEND _paraview_add_plugin_invoke_initializers
1427  " ${_paraview_add_plugin_initializer}();\n")
1428  endforeach ()
1429  endif ()
1430 
1431  set(_paraview_add_plugin_with_resources 0)
1432  set(_paraview_add_plugin_resources_init)
1433  if (_paraview_add_plugin_UI_RESOURCES)
1434  set(_paraview_add_plugin_with_resources 1)
1435  set(CMAKE_AUTORCC 1)
1436  if (NOT BUILD_SHARED_LIBS OR _paraview_add_plugin_FORCE_STATIC)
1437  foreach (_paraview_add_plugin_ui_resource IN LISTS _paraview_add_plugin_UI_RESOURCES)
1438  get_filename_component(_paraview_add_plugin_ui_resource_base "${_paraview_add_plugin_ui_resource}" NAME_WE)
1439  string(APPEND _paraview_add_plugin_resources_init
1440  " Q_INIT_RESOURCE(${_paraview_add_plugin_ui_resource_base});\n")
1441  endforeach ()
1442  endif ()
1443  list(APPEND _paraview_add_plugin_ui_sources
1444  ${_paraview_add_plugin_UI_RESOURCES})
1445  endif ()
1446 
1447  set(_paraview_add_plugin_qt_extra_components)
1448  if (_paraview_add_plugin_UI_FILES)
1450  set(CMAKE_AUTOUIC 1)
1451  list(APPEND _paraview_add_plugin_qt_extra_components
1452  Widgets)
1453  list(APPEND _paraview_add_plugin_required_libraries
1454  "Qt${PARAVIEW_QT_MAJOR_VERSION}::Widgets")
1455  list(APPEND _paraview_add_plugin_ui_sources
1456  ${_paraview_add_plugin_UI_FILES})
1457  endif ()
1458 
1459  if (_paraview_add_plugin_with_ui OR _paraview_add_plugin_with_resources)
1460  include("${_ParaViewPlugin_cmake_dir}/paraview-find-package-helpers.cmake" OPTIONAL)
1461  find_package("Qt${PARAVIEW_QT_MAJOR_VERSION}" QUIET REQUIRED COMPONENTS Core ${_paraview_add_plugin_qt_extra_components})
1462  list(APPEND _paraview_add_plugin_required_libraries
1463  "Qt${PARAVIEW_QT_MAJOR_VERSION}::Core")
1465  list(APPEND _paraview_add_plugin_required_libraries
1466  ParaView::pqCore)
1467  endif ()
1468 
1469  # CMake 3.13 started using Qt5's version variables to detect what version
1470  # of Qt's tools to run for automoc, autouic, and autorcc. However, they are
1471  # looked up using the target's directory scope, but these are here in a
1472  # local scope and unset when AutoGen gets around to asking about the
1473  # variables at generate time.
1474 
1475  # Fix for 3.13.0–3.13.3. Does not work if `paraview_add_plugin` is called
1476  # from another function.
1477  set("Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MAJOR" "${Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MAJOR}" PARENT_SCOPE)
1478  set("Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MINOR" "${Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MINOR}" PARENT_SCOPE)
1479  # Fix for 3.13.4+.
1480  set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
1481  PROPERTY
1482  "Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MAJOR" "${Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MAJOR}")
1483  set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
1484  PROPERTY
1485  "Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MINOR" "${Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MAJOR}")
1486  endif ()
1487 
1489  set(_paraview_add_plugin_python_sources)
1490  set(_paraview_add_plugin_python_includes)
1491  set(_paraview_add_plugin_python_modules)
1492  set(_paraview_add_plugin_python_module_sources)
1493  set(_paraview_add_plugin_python_package_flags)
1494  set(_paraview_add_plugin_python_libraries)
1495  if (_paraview_add_plugin_PYTHON_MODULES)
1497  # python code may include servermanager XML
1499  list(APPEND _paraview_add_plugin_python_libraries "ParaView::RemotingServerManagerPython")
1500  foreach (_paraview_add_plugin_python_module IN LISTS _paraview_add_plugin_PYTHON_MODULES)
1501  set(_paraview_add_plugin_python_path
1502  "${CMAKE_CURRENT_SOURCE_DIR}/${_paraview_add_plugin_python_module}")
1503  get_filename_component(_paraview_add_plugin_python_package "${_paraview_add_plugin_python_module}" PATH)
1504  get_filename_component(_paraview_add_plugin_python_name "${_paraview_add_plugin_python_module}" NAME_WE)
1505  if (_paraview_add_plugin_python_package)
1506  set(_paraview_add_plugin_python_full_name
1507  "${_paraview_add_plugin_python_package}.${_paraview_add_plugin_python_name}")
1508  else ()
1509  set(_paraview_add_plugin_python_full_name
1510  "${_paraview_add_plugin_python_name}")
1511  endif ()
1512  string(REPLACE "." "_" _paraview_add_plugin_python_module_mangled "${_paraview_add_plugin_python_full_name}")
1513  set(_paraview_add_plugin_python_is_package 0)
1514  set(_paraview_add_plugin_python_import
1515  "${_paraview_add_plugin_python_full_name}")
1516  if (_paraview_add_plugin_python_name STREQUAL "__init__")
1517  set(_paraview_add_plugin_python_is_package 1)
1518  set(_paraview_add_plugin_python_import
1519  "${_paraview_add_plugin_python_package}")
1520  endif ()
1521  set(_paraview_add_plugin_python_header_name
1522  "WrappedPython_${_paraview_build_plugin}_${_paraview_add_plugin_python_module_mangled}.h")
1523  set(_paraview_add_plugin_python_header
1524  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_add_plugin_python_header_name}")
1525 
1526  set(_paraview_add_plugin_python_depends_args)
1527  if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.27")
1528  list(APPEND _paraview_add_plugin_python_depends_args
1529  DEPENDS_EXPLICIT_ONLY)
1530  endif ()
1531 
1532  add_custom_command(
1533  OUTPUT "${_paraview_add_plugin_python_header}"
1534  COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR}
1535  "$<TARGET_FILE:ParaView::ProcessXML>"
1536  "${_paraview_add_plugin_python_header}"
1537  "module_${_paraview_add_plugin_python_module_mangled}_"
1538  "_string"
1539  "_source"
1540  "${_paraview_add_plugin_python_path}"
1541  DEPENDS "${_paraview_add_plugin_python_path}"
1542  "$<TARGET_FILE:ParaView::ProcessXML>"
1543  COMMENT "Convert Python module ${_paraview_add_plugin_python_module_name} for ${_paraview_build_plugin}"
1544  ${_paraview_add_plugin_python_depends_args})
1545 
1546  list(APPEND _paraview_add_plugin_python_sources
1547  "${_paraview_add_plugin_python_header}")
1548  string(APPEND _paraview_add_plugin_python_includes
1549  "#include \"${_paraview_add_plugin_python_header_name}\"\n")
1550  string(APPEND _paraview_add_plugin_python_modules
1551  " \"${_paraview_add_plugin_python_import}\",\n")
1552  string(APPEND _paraview_add_plugin_python_module_sources
1553  " module_${_paraview_add_plugin_python_module_mangled}_${_paraview_add_plugin_python_name}_source(),\n")
1554  string(APPEND _paraview_add_plugin_python_package_flags
1555  " ${_paraview_add_plugin_python_is_package},\n")
1556  endforeach ()
1557 
1558  # Add terminators to the list.
1559  string(APPEND _paraview_add_plugin_python_modules
1560  " nullptr")
1561  string(APPEND _paraview_add_plugin_python_module_sources
1562  " nullptr")
1563  string(APPEND _paraview_add_plugin_python_package_flags
1564  " -1")
1565  endif ()
1566 
1567  set(_paraview_add_plugin_header
1568  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_build_plugin}Plugin.h")
1569  set(_paraview_add_plugin_source
1570  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_build_plugin}Plugin.cxx")
1571 
1572  get_property(_paraview_add_plugin_description GLOBAL
1573  PROPERTY "_paraview_plugin_${_paraview_build_plugin}_description")
1574 
1575  set(_paraview_build_plugin_type MODULE)
1577  if (NOT BUILD_SHARED_LIBS OR _paraview_add_plugin_FORCE_STATIC)
1578  set(_paraview_build_plugin_type STATIC)
1580  endif ()
1581 
1582  configure_file(
1583  "${_paraview_plugin_source_dir}/paraview_plugin.h.in"
1584  "${_paraview_add_plugin_header}")
1585  configure_file(
1586  "${_paraview_plugin_source_dir}/paraview_plugin.cxx.in"
1587  "${_paraview_add_plugin_source}")
1588 
1589  if (WIN32)
1590  # On Windows, we want `MODULE` libraries to go to the runtime directory,
1591  # but CMake always uses `CMAKE_LIBRARY_OUTPUT_DIRECTORY`.
1592  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
1593  endif ()
1594  if (NOT _paraview_build_LIBRARY_SUBDIRECTORY STREQUAL "")
1595  string(APPEND CMAKE_LIBRARY_OUTPUT_DIRECTORY "/${_paraview_build_LIBRARY_SUBDIRECTORY}")
1596  endif ()
1597  string(APPEND CMAKE_LIBRARY_OUTPUT_DIRECTORY "/${_paraview_build_plugin}")
1598 
1599  # Place static plugins in the same place they would be if they were shared.
1600  if (NOT _paraview_build_LIBRARY_SUBDIRECTORY STREQUAL "")
1601  string(APPEND CMAKE_ARCHIVE_OUTPUT_DIRECTORY "/${_paraview_build_LIBRARY_SUBDIRECTORY}")
1602  endif ()
1603  string(APPEND CMAKE_ARCHIVE_OUTPUT_DIRECTORY "/${_paraview_build_plugin}")
1604 
1605  add_library("${_paraview_build_plugin}" "${_paraview_build_plugin_type}")
1606  target_sources("${_paraview_build_plugin}"
1607  PRIVATE
1608  ${_paraview_add_plugin_source}
1609  ${_paraview_add_plugin_eula_sources}
1610  ${_paraview_add_plugin_ui_sources}
1611  ${_paraview_add_plugin_python_sources}
1612  ${_paraview_add_plugin_SOURCES})
1613  # Forward the file set option internally.
1614  set(_vtk_build_USE_FILE_SETS "${_paraview_build_USE_FILE_SETS}")
1615  _vtk_module_add_file_set("${_paraview_build_plugin}"
1616  NAME paraview_plugin_headers
1617  VIS PRIVATE
1618  BASE_DIRS "${CMAKE_CURRENT_BINARY_DIR}"
1619  FILES ${_paraview_add_plugin_header}
1620  ${_paraview_add_plugin_binary_headers})
1621  if (NOT BUILD_SHARED_LIBS OR _paraview_add_plugin_FORCE_STATIC)
1622  target_compile_definitions("${_paraview_build_plugin}"
1623  PRIVATE
1624  QT_STATICPLUGIN)
1625  endif ()
1626  target_link_libraries("${_paraview_build_plugin}"
1627  PRIVATE
1628  ParaView::RemotingCore
1629  ${_paraview_add_plugin_python_libraries}
1630  ${_paraview_add_plugin_required_libraries})
1631  target_include_directories("${_paraview_build_plugin}"
1632  PRIVATE
1633  "${CMAKE_CURRENT_SOURCE_DIR}"
1634  ${_paraview_add_plugin_extra_include_dirs})
1635  set_property(TARGET "${_paraview_build_plugin}"
1636  PROPERTY
1637  PREFIX "")
1638 
1639  set(_paraview_add_plugin_destination
1640  "${_paraview_build_plugin_destination}/${_paraview_build_plugin}")
1641  install(
1642  TARGETS "${_paraview_build_plugin}"
1643  ${_paraview_add_plugin_export_args}
1644  COMPONENT "${_paraview_build_PLUGINS_COMPONENT}"
1645  ARCHIVE DESTINATION "${_paraview_add_plugin_destination}"
1646  LIBRARY DESTINATION "${_paraview_add_plugin_destination}")
1647 endfunction ()
1648 
1649 #[==[.md
1650 ## Plugin interfaces
1651 
1652 ParaView plugins may satisfy a number of interfaces. These functions all take a
1653 `INTERFACES` argument which takes the name of a variable to set with the name
1654 of the interface generated. This variable's should be passed to
1655 `paraview_add_plugin`'s `UI_INTERFACES` argument.
1656 #]==]
1657 
1658 #[==[.md
1659 ### Property widget
1660 
1661 TODO: What is a property widget?
1662 
1663 ```
1665  KIND <WIDGET|GROUP_WIDGET|WIDGET_DECORATOR>
1666  TYPE <type>
1667  CLASS_NAME <name>
1668  INTERFACES <variable>
1669  SOURCES <variable>)
1670 ```
1671 
1672  * `KIND`: The kind of widget represented.
1673  * `TYPE`: The name of the property type.
1674  * `CLASS_NAME`: The name of the property widget class.
1675  * `INTERFACES`: The name of the generated interface.
1676  * `SOURCES`: The source files generated by the interface.
1677 #]==]
1679  cmake_parse_arguments(_paraview_property_widget
1680  ""
1681  "KIND;TYPE;CLASS_NAME;INTERFACES;SOURCES"
1682  ""
1683  ${ARGN})
1684 
1685  if (_paraview_property_widget_UNPARSED_ARGUMENTS)
1686  message(FATAL_ERROR
1687  "Unparsed arguments for paraview_plugin_add_property_widget: "
1688  "${_paraview_property_widget_UNPARSED_ARGUMENTS}")
1689  endif ()
1690 
1691  set(_paraview_property_widget_kind_widget 0)
1692  set(_paraview_property_widget_kind_group_widget 0)
1693  set(_paraview_property_widget_kind_widget_decorator 0)
1694  if (_paraview_property_widget_KIND STREQUAL "WIDGET")
1695  set(_paraview_property_widget_kind_widget 1)
1696  elseif (_paraview_property_widget_KIND STREQUAL "GROUP_WIDGET")
1697  set(_paraview_property_widget_kind_group_widget 1)
1698  elseif (_paraview_property_widget_KIND STREQUAL "WIDGET_DECORATOR")
1699  set(_paraview_property_widget_kind_widget_decorator 1)
1700  else ()
1701  message(FATAL_ERROR
1702  "The `KIND` argument must be one of `WIDGET`, `GROUP_WIDGET`, or "
1703  "`WIDGET_DECORATOR`.")
1704  endif ()
1705 
1706  if (NOT DEFINED _paraview_property_widget_TYPE)
1707  message(FATAL_ERROR
1708  "The `TYPE` argument is required.")
1709  endif ()
1710 
1711  if (NOT DEFINED _paraview_property_widget_CLASS_NAME)
1712  message(FATAL_ERROR
1713  "The `CLASS_NAME` argument is required.")
1714  endif ()
1715 
1716  if (NOT DEFINED _paraview_property_widget_INTERFACES)
1717  message(FATAL_ERROR
1718  "The `INTERFACES` argument is required.")
1719  endif ()
1720 
1721  if (NOT DEFINED _paraview_property_widget_SOURCES)
1722  message(FATAL_ERROR
1723  "The `SOURCES` argument is required.")
1724  endif ()
1725 
1726  configure_file(
1727  "${_ParaViewPlugin_cmake_dir}/pqPropertyWidgetInterface.h.in"
1728  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_property_widget_CLASS_NAME}PWIImplementation.h"
1729  @ONLY)
1730  configure_file(
1731  "${_ParaViewPlugin_cmake_dir}/pqPropertyWidgetInterface.cxx.in"
1732  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_property_widget_CLASS_NAME}PWIImplementation.cxx"
1733  @ONLY)
1734 
1735  set("${_paraview_property_widget_INTERFACES}"
1736  "${_paraview_property_widget_CLASS_NAME}PWIImplementation"
1737  PARENT_SCOPE)
1738 
1739  set("${_paraview_property_widget_SOURCES}"
1740  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_property_widget_CLASS_NAME}PWIImplementation.cxx"
1741  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_property_widget_CLASS_NAME}PWIImplementation.h"
1742  PARENT_SCOPE)
1743 endfunction ()
1744 
1745 #[==[.md
1746 ### Dock window
1747 
1748 TODO: What is a dock window?
1749 
1750 ```
1752  CLASS_NAME <name>
1753  [DOCK_AREA <Right|Left|Top|Bottom>]
1754  INTERFACES <variable>
1755  SOURCES <variable>)
1756 ```
1757 
1758  * `CLASS_NAME`: The name of the dock window class.
1759  * `DOCK_AREA`: (Default `Left`) Where to dock the window within the
1760  application.
1761  * `INTERFACES`: The name of the generated interface.
1762  * `SOURCES`: The source files generated by the interface.
1763 #]==]
1765  cmake_parse_arguments(_paraview_dock_window
1766  ""
1767  "DOCK_AREA;CLASS_NAME;INTERFACES;SOURCES"
1768  ""
1769  ${ARGN})
1770 
1771  if (_paraview_dock_window_UNPARSED_ARGUMENTS)
1772  message(FATAL_ERROR
1773  "Unparsed arguments for paraview_plugin_add_dock_window: "
1774  "${_paraview_dock_window_UNPARSED_ARGUMENTS}")
1775  endif ()
1776 
1777  if (NOT DEFINED _paraview_dock_window_CLASS_NAME)
1778  message(FATAL_ERROR
1779  "The `CLASS_NAME` argument is required.")
1780  endif ()
1781 
1782  if (NOT DEFINED _paraview_dock_window_INTERFACES)
1783  message(FATAL_ERROR
1784  "The `INTERFACES` argument is required.")
1785  endif ()
1786 
1787  if (NOT DEFINED _paraview_dock_window_SOURCES)
1788  message(FATAL_ERROR
1789  "The `SOURCES` argument is required.")
1790  endif ()
1791 
1792  if (NOT DEFINED _paraview_dock_window_DOCK_AREA)
1793  set(_paraview_dock_window_DOCK_AREA "Left")
1794  endif ()
1795 
1796  if (NOT _paraview_dock_window_DOCK_AREA STREQUAL "Left" AND
1797  NOT _paraview_dock_window_DOCK_AREA STREQUAL "Right" AND
1798  NOT _paraview_dock_window_DOCK_AREA STREQUAL "Top" AND
1799  NOT _paraview_dock_window_DOCK_AREA STREQUAL "Bottom")
1800  message(FATAL_ERROR
1801  "`DOCK_AREA` must be one of `Left`, `Right`, `Top`, or `Bottom`. Got "
1802  "`${_paraview_dock_window_DOCK_AREA}`.")
1803  endif ()
1804 
1805  configure_file(
1806  "${_ParaViewPlugin_cmake_dir}/pqDockWindowImplementation.h.in"
1807  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_dock_window_CLASS_NAME}Implementation.h"
1808  @ONLY)
1809  configure_file(
1810  "${_ParaViewPlugin_cmake_dir}/pqDockWindowImplementation.cxx.in"
1811  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_dock_window_CLASS_NAME}Implementation.cxx"
1812  @ONLY)
1813 
1814  set("${_paraview_dock_window_INTERFACES}"
1815  "${_paraview_dock_window_CLASS_NAME}Implementation"
1816  PARENT_SCOPE)
1817 
1818  set("${_paraview_dock_window_SOURCES}"
1819  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_dock_window_CLASS_NAME}Implementation.cxx"
1820  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_dock_window_CLASS_NAME}Implementation.h"
1821  PARENT_SCOPE)
1822 endfunction ()
1823 
1824 #[==[.md
1825 ### Action group
1826 
1827 TODO: What is an action group?
1828 
1829 ```
1831  CLASS_NAME <name>
1832  GROUP_NAME <name>
1833  INTERFACES <variable>
1834  SOURCES <variable>)
1835 ```
1836 
1837  * `CLASS_NAME`: The name of the action group class.
1838  * `GROUP_NAME`: The name of the action group.
1839  * `INTERFACES`: The name of the generated interface.
1840  * `SOURCES`: The source files generated by the interface.
1841 #]==]
1843  cmake_parse_arguments(_paraview_action_group
1844  ""
1845  "CLASS_NAME;GROUP_NAME;INTERFACES;SOURCES"
1846  ""
1847  ${ARGN})
1848 
1849  if (_paraview_action_group_UNPARSED_ARGUMENTS)
1850  message(FATAL_ERROR
1851  "Unparsed arguments for paraview_plugin_add_action_group: "
1852  "${_paraview_action_group_UNPARSED_ARGUMENTS}")
1853  endif ()
1854 
1855  if (NOT DEFINED _paraview_action_group_CLASS_NAME)
1856  message(FATAL_ERROR
1857  "The `CLASS_NAME` argument is required.")
1858  endif ()
1859 
1860  if (NOT DEFINED _paraview_action_group_GROUP_NAME)
1861  message(FATAL_ERROR
1862  "The `GROUP_NAME` argument is required.")
1863  endif ()
1864 
1865  if (NOT DEFINED _paraview_action_group_INTERFACES)
1866  message(FATAL_ERROR
1867  "The `INTERFACES` argument is required.")
1868  endif ()
1869 
1870  if (NOT DEFINED _paraview_action_group_SOURCES)
1871  message(FATAL_ERROR
1872  "The `SOURCES` argument is required.")
1873  endif ()
1874 
1875  configure_file(
1876  "${_ParaViewPlugin_cmake_dir}/pqActionGroupImplementation.h.in"
1877  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_action_group_CLASS_NAME}Implementation.h"
1878  @ONLY)
1879  configure_file(
1880  "${_ParaViewPlugin_cmake_dir}/pqActionGroupImplementation.cxx.in"
1881  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_action_group_CLASS_NAME}Implementation.cxx"
1882  @ONLY)
1883 
1884  set("${_paraview_action_group_INTERFACES}"
1885  "${_paraview_action_group_CLASS_NAME}Implementation"
1886  PARENT_SCOPE)
1887 
1888  set("${_paraview_action_group_SOURCES}"
1889  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_action_group_CLASS_NAME}Implementation.cxx"
1890  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_action_group_CLASS_NAME}Implementation.h"
1891  PARENT_SCOPE)
1892 endfunction ()
1893 
1894 #[==[.md
1895 ### Toolbar
1896 
1897 TODO: What is a toolbar?
1898 
1899 ```
1901  CLASS_NAME <name>
1902  INTERFACES <variable>
1903  SOURCES <variable>)
1904 ```
1905 
1906  * `CLASS_NAME`: The name of the toolbar class.
1907  * `INTERFACES`: The name of the generated interface.
1908  * `SOURCES`: The source files generated by the interface.
1909 #]==]
1911  cmake_parse_arguments(_paraview_toolbar
1912  ""
1913  "CLASS_NAME;INTERFACES;SOURCES"
1914  ""
1915  ${ARGN})
1916 
1917  if (_paraview_toolbar_UNPARSED_ARGUMENTS)
1918  message(FATAL_ERROR
1919  "Unparsed arguments for paraview_plugin_add_toolbar: "
1920  "${_paraview_toolbar_UNPARSED_ARGUMENTS}")
1921  endif ()
1922 
1923  if (NOT DEFINED _paraview_toolbar_CLASS_NAME)
1924  message(FATAL_ERROR
1925  "The `CLASS_NAME` argument is required.")
1926  endif ()
1927 
1928  if (NOT DEFINED _paraview_toolbar_INTERFACES)
1929  message(FATAL_ERROR
1930  "The `INTERFACES` argument is required.")
1931  endif ()
1932 
1933  if (NOT DEFINED _paraview_toolbar_SOURCES)
1934  message(FATAL_ERROR
1935  "The `SOURCES` argument is required.")
1936  endif ()
1937 
1938  configure_file(
1939  "${_ParaViewPlugin_cmake_dir}/pqToolBarImplementation.h.in"
1940  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_toolbar_CLASS_NAME}Implementation.h"
1941  @ONLY)
1942  configure_file(
1943  "${_ParaViewPlugin_cmake_dir}/pqToolBarImplementation.cxx.in"
1944  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_toolbar_CLASS_NAME}Implementation.cxx"
1945  @ONLY)
1946 
1947  set("${_paraview_toolbar_INTERFACES}"
1948  "${_paraview_toolbar_CLASS_NAME}Implementation"
1949  PARENT_SCOPE)
1950 
1951  set("${_paraview_toolbar_SOURCES}"
1952  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_toolbar_CLASS_NAME}Implementation.cxx"
1953  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_toolbar_CLASS_NAME}Implementation.h"
1954  PARENT_SCOPE)
1955 endfunction ()
1956 
1957 #[==[.md
1958 ### Auto start
1959 
1960 TODO: What is an auto start?
1961 
1962 ```
1964  CLASS_NAME <name>
1965  [STARTUP <function>]
1966  [SHUTDOWN <function>]
1967  INTERFACES <variable>
1968  SOURCES <variable>)
1969 ```
1970 
1971  * `CLASS_NAME`: The name of the auto start class.
1972  * `STARTUP`: (Defaults to `startup`) The name of the method to call on
1973  startup.
1974  * `SHUTDOWN`: (Defaults to `shutdown`) The name of the method to call on
1975  shutdown.
1976  * `INTERFACES`: The name of the generated interface.
1977  * `SOURCES`: The source files generated by the interface.
1978 #]==]
1980  cmake_parse_arguments(_paraview_auto_start
1981  ""
1982  "CLASS_NAME;INTERFACES;SOURCES;STARTUP;SHUTDOWN"
1983  ""
1984  ${ARGN})
1985 
1986  if (_paraview_auto_start_UNPARSED_ARGUMENTS)
1987  message(FATAL_ERROR
1988  "Unparsed arguments for paraview_plugin_add_auto_start: "
1989  "${_paraview_auto_start_UNPARSED_ARGUMENTS}")
1990  endif ()
1991 
1992  if (NOT DEFINED _paraview_auto_start_CLASS_NAME)
1993  message(FATAL_ERROR
1994  "The `CLASS_NAME` argument is required.")
1995  endif ()
1996 
1997  if (NOT DEFINED _paraview_auto_start_INTERFACES)
1998  message(FATAL_ERROR
1999  "The `INTERFACES` argument is required.")
2000  endif ()
2001 
2002  if (NOT DEFINED _paraview_auto_start_SOURCES)
2003  message(FATAL_ERROR
2004  "The `SOURCES` argument is required.")
2005  endif ()
2006 
2007  if (NOT DEFINED _paraview_auto_start_STARTUP)
2008  set(_paraview_auto_start_STARTUP "startup")
2009  endif ()
2010 
2011  if (NOT DEFINED _paraview_auto_start_SHUTDOWN)
2012  set(_paraview_auto_start_SHUTDOWN "shutdown")
2013  endif ()
2014 
2015  configure_file(
2016  "${_ParaViewPlugin_cmake_dir}/pqAutoStartImplementation.h.in"
2017  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_auto_start_CLASS_NAME}Implementation.h"
2018  @ONLY)
2019  configure_file(
2020  "${_ParaViewPlugin_cmake_dir}/pqAutoStartImplementation.cxx.in"
2021  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_auto_start_CLASS_NAME}Implementation.cxx"
2022  @ONLY)
2023 
2024  set("${_paraview_auto_start_INTERFACES}"
2025  "${_paraview_auto_start_CLASS_NAME}Implementation"
2026  PARENT_SCOPE)
2027 
2028  set("${_paraview_auto_start_SOURCES}"
2029  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_auto_start_CLASS_NAME}Implementation.cxx"
2030  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_auto_start_CLASS_NAME}Implementation.h"
2031  PARENT_SCOPE)
2032 endfunction ()
2033 
2034 #[==[.md
2035 ### Location
2036 
2037 The filesystem location of dynamically-loaded plugin.
2038 
2039 ```
2041  CLASS_NAME <name>
2042  [STORE <function>]
2043  INTERFACES <variable>
2044  SOURCES <variable>)
2045 ```
2046 
2047  * `CLASS_NAME`: The name of the location class.
2048  * `STORE`: (Defaults to `StoreLocation`) The name of the method to call on
2049  startup, passing in the plugin location (const char*).
2050  * `INTERFACES`: The name of the generated interface.
2051  * `SOURCES`: The source files generated by the interface.
2052 #]==]
2054  cmake_parse_arguments(_paraview_location
2055  ""
2056  "CLASS_NAME;INTERFACES;SOURCES;STORE"
2057  ""
2058  ${ARGN})
2059 
2060  if (_paraview_location_UNPARSED_ARGUMENTS)
2061  message(FATAL_ERROR
2062  "Unparsed arguments for paraview_plugin_add_location: "
2063  "${_paraview_location_UNPARSED_ARGUMENTS}")
2064  endif ()
2065 
2066  if (NOT DEFINED _paraview_location_CLASS_NAME)
2067  message(FATAL_ERROR
2068  "The `CLASS_NAME` argument is required.")
2069  endif ()
2070 
2071  if (NOT DEFINED _paraview_location_INTERFACES)
2072  message(FATAL_ERROR
2073  "The `INTERFACES` argument is required.")
2074  endif ()
2075 
2076  if (NOT DEFINED _paraview_location_SOURCES)
2077  message(FATAL_ERROR
2078  "The `SOURCES` argument is required.")
2079  endif ()
2080 
2081  if (NOT DEFINED _paraview_location_STORE)
2082  set(_paraview_location_STORE "StoreLocation")
2083  endif ()
2084 
2085  configure_file(
2086  "${_ParaViewPlugin_cmake_dir}/pqPluginLocationImplementation.h.in"
2087  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_location_CLASS_NAME}Implementation.h"
2088  @ONLY)
2089  configure_file(
2090  "${_ParaViewPlugin_cmake_dir}/pqPluginLocationImplementation.cxx.in"
2091  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_location_CLASS_NAME}Implementation.cxx"
2092  @ONLY)
2093 
2094  set("${_paraview_location_INTERFACES}"
2095  "${_paraview_location_CLASS_NAME}Implementation"
2096  PARENT_SCOPE)
2097 
2098  set("${_paraview_location_SOURCES}"
2099  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_location_CLASS_NAME}Implementation.cxx"
2100  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_location_CLASS_NAME}Implementation.h"
2101  PARENT_SCOPE)
2102 endfunction ()
2103 
2104 #[==[.md
2105 ### Tree layout strategy
2106 
2107 TODO: What is a tree layout strategy?
2108 
2109 ```
2111  STRATEGY_TYPE <type>
2112  STRATEGY_LABEL <label>
2113  INTERFACES <variable>
2114  SOURCES <variable>)
2115 ```
2116 
2117  * `STRATEGY_TYPE`: The name of the tree layout strategy class.
2118  * `STRATEGY_LABEL`: The label to use for the strategy.
2119  * `INTERFACES`: The name of the generated interface.
2120  * `SOURCES`: The source files generated by the interface.
2121 #]==]
2123  cmake_parse_arguments(_paraview_tree_layout_strategy
2124  ""
2125  "INTERFACES;SOURCES;STRATEGY_TYPE;STRATEGY_LABEL"
2126  ""
2127  ${ARGN})
2128 
2129  if (_paraview_tree_layout_strategy_UNPARSED_ARGUMENTS)
2130  message(FATAL_ERROR
2131  "Unparsed arguments for paraview_plugin_add_tree_layout_strategy: "
2132  "${_paraview_tree_layout_strategy_UNPARSED_ARGUMENTS}")
2133  endif ()
2134 
2135  if (NOT DEFINED _paraview_tree_layout_strategy_STRATEGY_TYPE)
2136  message(FATAL_ERROR
2137  "The `STRATEGY_TYPE` argument is required.")
2138  endif ()
2139 
2140  if (NOT DEFINED _paraview_tree_layout_strategy_STRATEGY_LABEL)
2141  message(FATAL_ERROR
2142  "The `STRATEGY_LABEL` argument is required.")
2143  endif ()
2144 
2145  if (NOT DEFINED _paraview_tree_layout_strategy_INTERFACES)
2146  message(FATAL_ERROR
2147  "The `INTERFACES` argument is required.")
2148  endif ()
2149 
2150  if (NOT DEFINED _paraview_tree_layout_strategy_SOURCES)
2151  message(FATAL_ERROR
2152  "The `SOURCES` argument is required.")
2153  endif ()
2154 
2155  configure_file(
2156  "${_ParaViewPlugin_cmake_dir}/pqTreeLayoutStrategyImplementation.h.in"
2157  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_tree_layout_strategy_STRATEGY_TYPE}Implementation.h"
2158  @ONLY)
2159  configure_file(
2160  "${_ParaViewPlugin_cmake_dir}/pqTreeLayoutStrategyImplementation.cxx.in"
2161  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_tree_layout_strategy_STRATEGY_TYPE}Implementation.cxx"
2162  @ONLY)
2163 
2164  set("${_paraview_tree_layout_strategy_INTERFACES}"
2165  "${_paraview_tree_layout_strategy_STRATEGY_TYPE}Implementation"
2166  PARENT_SCOPE)
2167 
2168  set("${_paraview_tree_layout_strategy_SOURCES}"
2169  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_tree_layout_strategy_STRATEGY_TYPE}Implementation.cxx"
2170  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_tree_layout_strategy_STRATEGY_TYPE}Implementation.h"
2171  PARENT_SCOPE)
2172 endfunction ()
2173 
2174 #[==[.md
2175 ### Proxy
2176 
2177 TODO: What is a proxy?
2178 
2179 ```
2181  NAME <name>
2182  INTERFACES <variable>
2183  SOURCES <variable>
2184  [PROXY_TYPE <type>
2185  [CLASS_NAME <class>]
2186  XML_GROUP <group>
2187  <XML_NAME|XML_NAME_REGEX> <name>]...)
2188 ```
2189 
2190  * `NAME`: The name of the proxy.
2191  * `INTERFACES`: The name of the generated interface.
2192  * `SOURCES`: The source files generated by the interface.
2193 
2194 At least one `PROXY_TYPE` must be specified. Each proxy type must be given an
2195 `XML_GROUP` and either an `XML_NAME` or `XML_NAME_REGEX`. If `CLASS_NAME` is
2196 not given, the `PROXY_TYPE` name is used instead.
2197 #]==]
2199  cmake_parse_arguments(_paraview_proxy
2200  ""
2201  "INTERFACES;SOURCES;NAME"
2202  ""
2203  ${ARGN})
2204 
2205  if (NOT DEFINED _paraview_proxy_INTERFACES)
2206  message(FATAL_ERROR
2207  "The `INTERFACES` argument is required.")
2208  endif ()
2209 
2210  if (NOT DEFINED _paraview_proxy_SOURCES)
2211  message(FATAL_ERROR
2212  "The `SOURCES` argument is required.")
2213  endif ()
2214 
2215  if (NOT DEFINED _paraview_proxy_NAME)
2216  message(FATAL_ERROR
2217  "The `NAME` argument is required.")
2218  endif ()
2219 
2220  set(_paraview_proxy_parse "")
2221  set(_paraview_proxy_type)
2222  set(_paraview_proxy_types)
2223  foreach (_paraview_proxy_arg IN LISTS _paraview_proxy_UNPARSED_ARGUMENTS)
2224  if (_paraview_proxy_parse STREQUAL "")
2225  set(_paraview_proxy_parse "${_paraview_proxy_arg}")
2226  elseif (_paraview_proxy_parse STREQUAL "PROXY_TYPE")
2227  set(_paraview_proxy_type "${_paraview_proxy_arg}")
2228  list(APPEND _paraview_proxy_types "${_paraview_proxy_type}")
2229  set(_paraview_proxy_parse "")
2230  elseif (_paraview_proxy_parse STREQUAL "CLASS_NAME")
2231  if (NOT _paraview_proxy_type)
2232  message(FATAL_ERROR
2233  "Missing `PROXY_TYPE` for `CLASS_NAME`")
2234  endif ()
2235  if (DEFINED "_paraview_proxy_type_${_paraview_proxy_type}_class_name")
2236  message(FATAL_ERROR
2237  "Duplicate `CLASS_NAME` for `${_paraview_proxy_type}`")
2238  endif ()
2239  set("_paraview_proxy_type_${_paraview_proxy_type}_class_name"
2240  "${_paraview_proxy_arg}")
2241  set(_paraview_proxy_parse "")
2242  elseif (_paraview_proxy_parse STREQUAL "XML_GROUP")
2243  if (NOT _paraview_proxy_type)
2244  message(FATAL_ERROR
2245  "Missing `PROXY_TYPE` for `XML_GROUP`")
2246  endif ()
2247  if (DEFINED "_paraview_proxy_type_${_paraview_proxy_type}_xml_group")
2248  message(FATAL_ERROR
2249  "Duplicate `XML_GROUP` for `${_paraview_proxy_type}`")
2250  endif ()
2251  set("_paraview_proxy_type_${_paraview_proxy_type}_xml_group"
2252  "${_paraview_proxy_arg}")
2253  set(_paraview_proxy_parse "")
2254  elseif (_paraview_proxy_parse STREQUAL "XML_NAME")
2255  if (NOT _paraview_proxy_type)
2256  message(FATAL_ERROR
2257  "Missing `PROXY_TYPE` for `XML_NAME`")
2258  endif ()
2259  if (DEFINED "_paraview_proxy_type_${_paraview_proxy_type}_xml_name" OR
2260  DEFINED "_paraview_proxy_type_${_paraview_proxy_type}_xml_name_regex")
2261  message(FATAL_ERROR
2262  "Duplicate `XML_NAME` or `XML_NAME_REGEX` for `${_paraview_proxy_type}`")
2263  endif ()
2264  set("_paraview_proxy_type_${_paraview_proxy_type}_xml_name"
2265  "${_paraview_proxy_arg}")
2266  set(_paraview_proxy_parse "")
2267  elseif (_paraview_proxy_parse STREQUAL "XML_NAME_REGEX")
2268  if (NOT _paraview_proxy_type)
2269  message(FATAL_ERROR
2270  "Missing `PROXY_TYPE` for `XML_NAME_REGEX`")
2271  endif ()
2272  if (DEFINED "_paraview_proxy_type_${_paraview_proxy_type}_xml_name" OR
2273  DEFINED "_paraview_proxy_type_${_paraview_proxy_type}_xml_name_regex")
2274  message(FATAL_ERROR
2275  "Duplicate `XML_NAME` or `XML_NAME_REGEX` for `${_paraview_proxy_type}`")
2276  endif ()
2277  set("_paraview_proxy_type_${_paraview_proxy_type}_xml_name_regex"
2278  "${_paraview_proxy_arg}")
2279  set(_paraview_proxy_parse "")
2280  else ()
2281  message(FATAL_ERROR
2282  "Unknown argument `${_paraview_proxy_parse}`")
2283  endif ()
2284  endforeach ()
2285 
2286  if (_paraview_proxy_parse)
2287  message(FATAL_ERROR
2288  "Missing argument for `${_paraview_proxy_parse}`")
2289  endif ()
2290 
2291  if (NOT _paraview_proxy_types)
2292  message(FATAL_ERROR
2293  "No `PROXY_TYPE` arguments given")
2294  endif ()
2295 
2296  set(_paraview_proxy_includes)
2297  set(_paraview_proxy_body)
2298  foreach (_paraview_proxy_type IN LISTS _paraview_proxy_types)
2299  if (NOT DEFINED "_paraview_proxy_type_${_paraview_proxy_type}_xml_group")
2300  message(FATAL_ERROR
2301  "Missing `XML_GROUP` for `${_paraview_proxy_type}`")
2302  endif ()
2303  if (NOT DEFINED "_paraview_proxy_type_${_paraview_proxy_type}_xml_name" AND
2304  NOT DEFINED "_paraview_proxy_type_${_paraview_proxy_type}_xml_name_regex")
2305  message(FATAL_ERROR
2306  "Missing `XML_NAME` or `XML_NAME_REGEX` for `${_paraview_proxy_type}`")
2307  endif ()
2308  if (DEFINED "_paraview_proxy_type_${_paraview_proxy_type}_class_name")
2309  set(_paraview_proxy_class
2310  "${_paraview_proxy_type_${_paraview_proxy_type}_class_name}")
2311  else ()
2312  set(_paraview_proxy_class
2313  "${_paraview_proxy_type}")
2314  endif ()
2315 
2316  set(_paraview_proxy_group "${_paraview_proxy_type_${_paraview_proxy_type}_xml_group}")
2317  if (DEFINED "_paraview_proxy_type_${_paraview_proxy_type}_xml_name")
2318  set(_paraview_proxy_name "${_paraview_proxy_type_${_paraview_proxy_type}_xml_name}")
2319  set(_paraview_proxy_name_type "QString")
2320  set(_paraview_proxy_cmp "name == proxy->GetXMLName()")
2321  else ()
2322  set(_paraview_proxy_name "${_paraview_proxy_type_${_paraview_proxy_type}_xml_name_regex}")
2323  set(_paraview_proxy_name_type "QRegularExpression")
2324  set(_paraview_proxy_cmp "QString(proxy->GetXMLName()).contains(name)")
2325  endif ()
2326 
2327  if (NOT DEFINED "_paraview_proxy_included_${_paraview_proxy_class}")
2328  string(APPEND _paraview_proxy_includes
2329  "#include \"${_paraview_proxy_class}.h\"\n")
2330  set("_paraview_proxy_included_${_paraview_proxy_class}" 1)
2331  endif ()
2332  string(APPEND _paraview_proxy_body
2333  " {
2334  static const QString group(\"${_paraview_proxy_group}\");
2335  static const ${_paraview_proxy_name_type} name(\"${_paraview_proxy_name}\");
2336  if (group == proxy->GetXMLGroup() && ${_paraview_proxy_cmp})
2337  {
2338  return new ${_paraview_proxy_class}(regGroup, regName, proxy, server, nullptr);
2339  }
2340  }\n")
2341  endforeach ()
2342 
2343  configure_file(
2344  "${_ParaViewPlugin_cmake_dir}/pqServerManagerModelImplementation.h.in"
2345  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_proxy_NAME}ServerManagerModelImplementation.h"
2346  @ONLY)
2347  configure_file(
2348  "${_ParaViewPlugin_cmake_dir}/pqServerManagerModelImplementation.cxx.in"
2349  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_proxy_NAME}ServerManagerModelImplementation.cxx"
2350  @ONLY)
2351 
2352  set("${_paraview_proxy_INTERFACES}"
2353  "${_paraview_proxy_NAME}ServerManagerModelImplementation"
2354  PARENT_SCOPE)
2355 
2356  set("${_paraview_proxy_SOURCES}"
2357  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_proxy_NAME}ServerManagerModelImplementation.cxx"
2358  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_proxy_NAME}ServerManagerModelImplementation.h"
2359  PARENT_SCOPE)
2360 endfunction ()
2361 
2362 cmake_policy(POP)
description
function paraview_server_manager_process_files()
.md The second way to process XML files directly.
function paraview_plugin_add_tree_layout_strategy()
.md Tree layout strategy
function paraview_plugin_build()
.md Building plugins
location
component
content
#define _paraview_add_plugin_with_ui
order
#define _paraview_add_plugin_with_initializers
#define _paraview_add_plugin_with_xml
type
function paraview_plugin_add_action_group()
.md Action group
on
function paraview_plugin_add_auto_start()
.md Auto start
version
function paraview_plugin_add_dock_window()
.md Dock window
#define _paraview_add_plugin_built_shared
EXPORT
function paraview_server_manager_process()
.md Building XML files
string
function paraview_plugin_add_proxy()
.md Proxy
std::string replace(std::string source, const std::string &search, const std::string &replace, bool all)
function paraview_plugin_add_toolbar()
.md Toolbar
name
function paraview_plugin_add_property_widget()
.md Plugin interfaces
function
time
function vtk_module_wrap_client_server()
.md Wrapping a set of VTK modules for ClientServer
#define VERSION
Definition: jconfigint.h:17
function paraview_plugin_add_location()
.md Location
function paraview_plugin_write_conf()
.md Plugin configuration files
#define BUILD_SHARED_LIBS
Definition: config.h:45
function paraview_plugin_scan()
.md Scanning plugins
source
function paraview_client_generate_help()
.md Generating help documentation
#define PACKAGE
Definition: expat_config.h:67
function paraview_client_documentation()
.md Documentation from XML files
function paraview_add_plugin(name)
.md Adding a plugin
enabled
top
documentation
value
#define _paraview_add_plugin_with_python
function _paraview_plugin_debug(domain, format)
.md ParaView Plugin CMake API