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.
1026  * `INITIALIZERS`: An ordered list of free functions (declared in `EXTRA_INCLUDES`
1027  if needed) to be invoked when the plugin is loaded. Each function must be
1028  callable with no arguments.
1029  * `EXTRA_INCLUDES`: Headers needed by the generated plugin code (such as `INITIALIZERS`).
1030  Filename paths passed without quotes will be double-quoted (e.g., \verbatim`#include "foo.h"`\endverbatim),
1031  while paths that start with angle- or double-quotes will not be.
1032  * `REQUIRED_PLUGINS`: Plugins which must be loaded for this plugin to
1033  function. These plugins do not need to be available at build time and are
1034  therefore their existence is not checked here.
1035  * `EULA`: A file with content to display as an end-user license agreement
1036  before the plugin is initialized at runtime.
1037  * `XML_DOCUMENTATION`: (Defaults to `ON`) If set, documentation will be
1038  generated for the associated XML files.
1039  * `DOCUMENTATION_DIR`: If specified, `*.html`, `*.css`, `*.png`, `*.js`, and `*.jpg`
1040  files in this directory will be copied and made available to the
1041  documentation.
1042  * `DOCUMENTATION_ADD_PATTERNS`: If specified, adds patterns for the documentation files
1043  within `DOCUMENTATION_DIR` other than the default ones (see `DOCUMENTATION_DIR` help)
1044  * `DOCUMENTATION_TOC`: If specified, use this string for describing the table of
1045  content for the documentation.
1046  * `DOCUMENTATION_DEPENDENCIES`: Targets that are needed to be built before
1047  building the documentation.
1048  * `EXPORT`: (Deprecated) Use `paraview_plugin_build(INSTALL_EXPORT)` instead.
1049  * `FORCE_STATIC`: (Defaults to `OFF`) If set, the plugin will be built
1050  statically so that it can be embedded into an application.
1051  * `TRANSLATIONS_DIRECTORY`: (Defaults to `${CMAKE_CURRENT_BINARY_DIR}/Translations`)
1052  The path of the directory where translation source files are stored.
1053  * `TRANSLATION_TARGET` : The name of the target on which to add the ts file as
1054  dependency.
1055 #]==]
1057  if (NOT name STREQUAL _paraview_build_plugin)
1058  message(FATAL_ERROR
1059  "The ${_paraview_build_plugin}'s CMakeLists.txt may not add the ${name} "
1060  "plugin.")
1061  endif ()
1062 
1063  cmake_parse_arguments(_paraview_add_plugin
1064  "REQUIRED_ON_SERVER;REQUIRED_ON_CLIENT"
1065  "VERSION;EULA;EXPORT;MODULE_INSTALL_EXPORT;XML_DOCUMENTATION;DOCUMENTATION_DIR;FORCE_STATIC;DOCUMENTATION_TOC;TRANSLATIONS_DIRECTORY;TRANSLATIONS_TARGET"
1066  "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"
1067  ${ARGN})
1068 
1069  if (_paraview_add_plugin_UNPARSED_ARGUMENTS)
1070  message(FATAL_ERROR
1071  "Unparsed arguments for paraview_add_plugin: "
1072  "${_paraview_add_plugin_UNPARSED_ARGUMENTS}")
1073  endif ()
1074 
1075  if (NOT DEFINED _paraview_add_plugin_VERSION)
1076  message(FATAL_ERROR
1077  "The `VERSION` argument is required.")
1078  endif ()
1079  set_property(GLOBAL
1080  PROPERTY
1081  "_paraview_plugin_${name}_version" "${_paraview_add_plugin_VERSION}")
1082 
1083  if (NOT DEFINED _paraview_add_plugin_XML_DOCUMENTATION)
1084  set(_paraview_add_plugin_XML_DOCUMENTATION ON)
1085  endif ()
1086  if (DEFINED _paraview_add_plugin_DOCUMENTATION_DIR AND
1087  NOT _paraview_add_plugin_XML_DOCUMENTATION)
1088  message(FATAL_ERROR
1089  "Specifying `DOCUMENTATION_DIR` and turning off `XML_DOCUMENTATION` "
1090  "makes no sense.")
1091  endif ()
1092  if (_paraview_build_DISABLE_XML_DOCUMENTATION)
1093  set(_paraview_add_plugin_XML_DOCUMENTATION OFF)
1094  endif ()
1095 
1096  if (NOT DEFINED _paraview_add_plugin_FORCE_STATIC)
1097  set(_paraview_add_plugin_FORCE_STATIC OFF)
1098  endif ()
1099 
1100  if (DEFINED _paraview_add_plugin_EXPORT)
1101  message(FATAL_ERROR
1102  "The `paraview_add_plugin(EXPORT)` argument is ignored in favor of "
1103  "`paraview_plugin_build(INSTALL_EXPORT)`.")
1104  endif ()
1105 
1106  if (_paraview_add_plugin_MODULE_ARGS)
1107  if (NOT _paraview_add_plugin_MODULE_FILES OR
1108  NOT _paraview_add_plugin_MODULES)
1109  message(FATAL_ERROR
1110  "The `MODULE_ARGS` argument requires `MODULE_FILES` and `MODULES` to be provided.")
1111  endif ()
1112  endif ()
1113 
1114  if (_paraview_add_plugin_UI_INTERFACES OR _paraview_add_plugin_UI_FILES OR _paraview_add_plugin_UI_RESOURCES)
1115  if (NOT PARAVIEW_USE_QT)
1116  message(FATAL_ERROR "UI_INTERFACES, UI_FILES and UI_RESOURCES require ParaView to be built with Qt enabled.")
1117  endif()
1118  endif()
1119 
1120  if (DEFINED _paraview_build_INSTALL_EXPORT AND
1121  NOT DEFINED _paraview_add_plugin_MODULE_INSTALL_EXPORT)
1122  set(_paraview_add_plugin_MODULE_INSTALL_EXPORT
1123  "${name}")
1124  endif ()
1125 
1126  if (_paraview_add_plugin_MODULE_FILES)
1127  if (NOT _paraview_add_plugin_MODULES)
1128  message(FATAL_ERROR
1129  "The `MODULE_FILES` argument requires `MODULES` to be provided.")
1130  endif ()
1131 
1132  if (_paraview_build_ADD_INSTALL_RPATHS)
1133  if (APPLE)
1134  list(INSERT CMAKE_INSTALL_RPATH 0
1135  "@loader_path")
1136  elseif (UNIX)
1137  list(INSERT CMAKE_INSTALL_RPATH 0
1138  "$ORIGIN")
1139  endif ()
1140  endif ()
1141 
1142  set(_paraview_add_plugin_module_install_export_args)
1143  if (DEFINED _paraview_add_plugin_MODULE_INSTALL_EXPORT)
1144  list(APPEND _paraview_add_plugin_module_install_export_args
1145  INSTALL_EXPORT "${_paraview_add_plugin_MODULE_INSTALL_EXPORT}")
1146  if (DEFINED _paraview_build_TARGET)
1147  set_property(GLOBAL APPEND
1148  PROPERTY
1149  "paraview_plugin_${_paraview_build_TARGET}_required_exports" "${_paraview_add_plugin_MODULE_INSTALL_EXPORT}")
1150  endif ()
1151  endif ()
1152 
1153  vtk_module_scan(
1154  MODULE_FILES ${_paraview_add_plugin_MODULE_FILES}
1155  REQUEST_MODULES ${_paraview_add_plugin_MODULES}
1156  PROVIDES_MODULES plugin_modules
1157  REQUIRES_MODULES required_modules
1158  HIDE_MODULES_FROM_CACHE ON)
1159 
1160  if (required_modules)
1161  foreach (required_module IN LISTS required_modules)
1162  if (NOT TARGET "${required_module}")
1163  message(FATAL_ERROR
1164  "Failed to find the required module ${required_module}.")
1165  endif ()
1166  endforeach ()
1167  endif ()
1168 
1169  if (WIN32)
1170  set(_paraview_plugin_subdir "${_paraview_build_RUNTIME_DESTINATION}")
1171  else ()
1172  set(_paraview_plugin_subdir "${_paraview_build_LIBRARY_DESTINATION}")
1173  endif ()
1174  if (NOT _paraview_build_LIBRARY_SUBDIRECTORY STREQUAL "")
1175  string(APPEND _paraview_plugin_subdir "/${_paraview_build_LIBRARY_SUBDIRECTORY}")
1176  endif ()
1177  string(APPEND _paraview_plugin_subdir "/${_paraview_build_plugin}")
1178  set(_paraview_plugin_CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
1179  set(_paraview_plugin_CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
1180  set(_paraview_plugin_CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}")
1181  set(_paraview_plugin_CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_NAME_DIR}")
1182  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${_paraview_plugin_subdir}")
1183  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${_paraview_plugin_subdir}")
1184  set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${_paraview_plugin_subdir}")
1185  set(CMAKE_INSTALL_NAME_DIR "@loader_path")
1186 
1187  vtk_module_build(
1188  MODULES ${plugin_modules}
1189  PACKAGE "${_paraview_build_plugin}"
1190  USE_FILE_SETS "${_paraview_build_USE_FILE_SETS}"
1191  ${_paraview_add_plugin_module_install_export_args}
1192  INSTALL_HEADERS "${_paraview_build_INSTALL_HEADERS}"
1193  TARGETS_COMPONENT "${_paraview_build_PLUGINS_COMPONENT}"
1194  HEADERS_DESTINATION "${_paraview_build_HEADERS_DESTINATION}/${_paraview_build_target_safe}"
1195  ARCHIVE_DESTINATION "${_paraview_plugin_subdir}"
1196  LIBRARY_DESTINATION "${_paraview_plugin_subdir}"
1197  RUNTIME_DESTINATION "${_paraview_plugin_subdir}"
1198  CMAKE_DESTINATION "${_paraview_build_CMAKE_DESTINATION}"
1199  ${_paraview_add_plugin_MODULE_ARGS}
1200  GENERATE_SPDX "${_paraview_build_GENERATE_SPDX}"
1201  SPDX_DOCUMENT_NAMESPACE "${_paraview_build_SPDX_DOCUMENT_NAMESPACE}"
1202  SPDX_DOWNLOAD_LOCATION "${_paraview_build_SPDX_DOWNLOAD_LOCATION}")
1203 
1204  set_property(GLOBAL APPEND
1205  PROPERTY
1206  "paraview_plugin_${_paraview_add_plugin_MODULE_INSTALL_EXPORT}_modules" "${plugin_modules}")
1207 
1208  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${_paraview_plugin_CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
1209  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${_paraview_plugin_CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
1210  set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${_paraview_plugin_CMAKE_ARCHIVE_OUTPUT_DIRECTORY}")
1211  set(CMAKE_INSTALL_NAME_DIR "${_paraview_plugin_CMAKE_INSTALL_NAME_DIR}")
1212  unset(_paraview_plugin_CMAKE_RUNTIME_OUTPUT_DIRECTORY)
1213  unset(_paraview_plugin_CMAKE_LIBRARY_OUTPUT_DIRECTORY)
1214  unset(_paraview_plugin_CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
1215  unset(_paraview_plugin_CMAKE_INSTALL_NAME_DIR)
1216  endif ()
1217 
1218  # TODO: resource initialization for static builds
1219 
1220  if (_paraview_add_plugin_REQUIRED_ON_SERVER)
1221  set(_paraview_add_plugin_required_on_server "true")
1222  else ()
1223  set(_paraview_add_plugin_required_on_server "false")
1224  endif ()
1225 
1226  if (_paraview_add_plugin_REQUIRED_ON_CLIENT)
1227  set(_paraview_add_plugin_required_on_client "true")
1228  else ()
1229  set(_paraview_add_plugin_required_on_client "false")
1230  endif ()
1231 
1232  set(_paraview_add_plugin_export_args)
1233  set(_paraview_add_plugin_install_export_args)
1234  if (DEFINED _paraview_build_INSTALL_EXPORT)
1235  list(APPEND _paraview_add_plugin_export_args
1236  EXPORT "${_paraview_build_INSTALL_EXPORT}")
1237  list(APPEND _paraview_add_plugin_install_export_args
1238  INSTALL_EXPORT "${_paraview_build_INSTALL_EXPORT}")
1239  endif ()
1240 
1241  set(_paraview_add_plugin_includes)
1242  set(_paraview_add_plugin_required_libraries)
1243 
1244  if (_paraview_add_plugin_EXTRA_INCLUDES)
1245  foreach (_include IN LISTS _paraview_add_plugin_EXTRA_INCLUDES)
1246  if ((${_include} MATCHES "^\".*\"$") OR (${_include} MATCHES "^<.*>$"))
1247  string(APPEND _paraview_add_plugin_includes "#include ${_include}\n")
1248  else ()
1249  string(APPEND _paraview_add_plugin_includes "#include \"${_include}\"\n")
1250  endif ()
1251  endforeach ()
1252  endif ()
1253 
1254  set(_paraview_add_plugin_module_xmls)
1256  if (_paraview_add_plugin_MODULES)
1258 
1259  list(APPEND _paraview_add_plugin_required_libraries
1260  ${_paraview_add_plugin_MODULES})
1261 
1263  MODULES ${_paraview_add_plugin_MODULES}
1264  TARGET "${_paraview_build_plugin}_client_server"
1265  ${_paraview_add_plugin_install_export_args})
1266 
1267  if (NOT DEFINED _paraview_add_plugin_TRANSLATIONS_DIRECTORY)
1268  set(_paraview_add_plugin_TRANSLATIONS_DIRECTORY
1269  "${CMAKE_CURRENT_BINARY_DIR}/Translations")
1270  endif ()
1271  set(_paraview_add_plugin_translation_args)
1272  if (_paraview_add_plugin_TRANSLATIONS_DIRECTORY AND _paraview_add_plugin_TRANSLATIONS_TARGET)
1273  list(APPEND _paraview_add_plugin_translation_args
1274  TRANSLATIONS_DIRECTORY "${_paraview_add_plugin_TRANSLATIONS_DIRECTORY}")
1275  list(APPEND _paraview_add_plugin_translation_args
1276  TRANSLATIONS_TARGET "${_paraview_add_plugin_TRANSLATIONS_TARGET}")
1277  endif ()
1278 
1280  MODULES ${_paraview_add_plugin_MODULES}
1281  TARGET "${_paraview_build_plugin}_server_manager_modules"
1282  ${_paraview_add_plugin_install_export_args}
1283  XML_FILES _paraview_add_plugin_module_xmls
1284  ${_paraview_add_plugin_translation_args})
1285 
1286  list(APPEND _paraview_add_plugin_required_libraries
1287  "${_paraview_build_plugin}_client_server"
1288  "${_paraview_build_plugin}_server_manager_modules")
1289  endif ()
1290 
1291  set(_paraview_add_plugin_binary_resources "")
1292  set(_paraview_add_plugin_binary_headers)
1293  if (_paraview_add_plugin_SERVER_MANAGER_XML)
1295 
1296  set(_paraview_add_plugin_xmls)
1297  foreach (_paraview_add_plugin_xml IN LISTS _paraview_add_plugin_SERVER_MANAGER_XML)
1298  if (NOT IS_ABSOLUTE "${_paraview_add_plugin_xml}")
1299  set(_paraview_add_plugin_xml "${CMAKE_CURRENT_SOURCE_DIR}/${_paraview_add_plugin_xml}")
1300  endif ()
1301 
1302  list(APPEND _paraview_add_plugin_xmls
1303  "${_paraview_add_plugin_xml}")
1304  endforeach ()
1305 
1306  set_property(GLOBAL APPEND
1307  PROPERTY
1308  "_paraview_plugin_${_paraview_build_plugin}_xmls" "${_paraview_add_plugin_xmls}")
1309 
1311  TARGET "${_paraview_build_plugin}_server_manager"
1312  ${_paraview_add_plugin_install_export_args}
1313  FILES ${_paraview_add_plugin_xmls})
1314  list(APPEND _paraview_add_plugin_required_libraries
1315  "${_paraview_build_plugin}_server_manager")
1316  endif ()
1317 
1318  if ((_paraview_add_plugin_module_xmls OR _paraview_add_plugin_xmls) AND
1319  PARAVIEW_USE_QT AND _paraview_add_plugin_XML_DOCUMENTATION)
1320  set(_paraview_build_plugin_docdir
1321  "${CMAKE_CURRENT_BINARY_DIR}/paraview_help")
1322 
1324  TARGET "${_paraview_build_plugin}_doc"
1325  OUTPUT_DIR "${_paraview_build_plugin_docdir}"
1326  XMLS ${_paraview_add_plugin_module_xmls}
1327  ${_paraview_add_plugin_xmls})
1328 
1329  set(_paraview_build_plugin_doc_source_args)
1330  if (DEFINED _paraview_add_plugin_DOCUMENTATION_DIR)
1331  list(APPEND _paraview_build_plugin_doc_source_args
1332  SOURCE_DIR "${_paraview_add_plugin_DOCUMENTATION_DIR}")
1333  endif ()
1334 
1336  NAME "${_paraview_build_plugin}"
1337  OUTPUT_PATH _paraview_build_plugin_qch_path
1338  OUTPUT_DIR "${_paraview_build_plugin_docdir}"
1339  TARGET "${_paraview_build_plugin}_qch"
1340  ${_paraview_build_plugin_doc_source_args}
1341  TABLE_OF_CONTENTS "${_paraview_add_plugin_DOCUMENTATION_TOC}"
1342  DEPENDS "${_paraview_build_plugin}_doc"
1343  "${_paraview_add_plugin_DOCUMENTATION_DEPENDENCIES}"
1344  PATTERNS "*.html" "*.css" "*.png" "*.jpg" "*.js"
1345  ${_paraview_add_plugin_DOCUMENTATION_ADD_PATTERNS})
1346 
1347  set(_paraview_add_plugin_depends_args)
1348  if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.27")
1349  list(APPEND _paraview_add_plugin_depends_args
1350  DEPENDS_EXPLICIT_ONLY)
1351  endif ()
1352 
1353  list(APPEND _paraview_add_plugin_extra_include_dirs
1354  "${CMAKE_CURRENT_BINARY_DIR}")
1355  set(_paraview_add_plugin_qch_output
1356  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_build_plugin}_qch.h")
1357  list(APPEND _paraview_add_plugin_binary_headers
1358  "${_paraview_add_plugin_qch_output}")
1359  add_custom_command(
1360  OUTPUT "${_paraview_add_plugin_qch_output}"
1361  COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR}
1362  "$<TARGET_FILE:ParaView::ProcessXML>"
1363  -base64
1364  "${_paraview_add_plugin_qch_output}"
1365  \"\"
1366  "_qch"
1367  "_qch"
1368  "${_paraview_build_plugin_qch_path}"
1369  DEPENDS "${_paraview_build_plugin_qch_path}"
1370  "${_paraview_build_plugin}_qch"
1371  "$<TARGET_FILE:ParaView::ProcessXML>"
1372  COMMENT "Generating header for ${_paraview_build_plugin} documentation"
1373  ${_paraview_add_plugin_depends_args})
1374  set_property(SOURCE "${_paraview_add_plugin_qch_output}"
1375  PROPERTY
1376  SKIP_AUTOMOC 1)
1377 
1378  string(APPEND _paraview_add_plugin_includes
1379  "#include \"${_paraview_build_plugin}_qch.h\"\n")
1380  string(APPEND _paraview_add_plugin_binary_resources
1381  " {
1382  const char *text = ${_paraview_build_plugin}_qch();
1383  resources.emplace_back(text);
1384  delete [] text;
1385  }\n")
1386  endif ()
1387 
1388  set(_paraview_add_plugin_eula_sources)
1389  if (_paraview_add_plugin_EULA)
1390  vtk_encode_string(
1391  INPUT "${_paraview_add_plugin_EULA}"
1392  NAME "${_paraview_build_plugin}_EULA"
1393  HEADER_OUTPUT _paraview_add_plugin_eula_header
1394  SOURCE_OUTPUT _paraview_add_plugin_eula_source)
1395  list(APPEND _paraview_add_plugin_eula_sources
1396  "${_paraview_add_plugin_eula_header}"
1397  "${_paraview_add_plugin_eula_source}")
1398  endif ()
1399 
1401  set(_paraview_add_plugin_ui_sources)
1402  if (_paraview_add_plugin_UI_INTERFACES)
1404  set(CMAKE_AUTOMOC 1)
1405  set(_paraview_add_plugin_push_back_interfaces
1406  "#define PARAVIEW_ADD_INTERFACES(arg) \\\n")
1407  set(_paraview_add_plugin_include_interfaces "")
1408 
1409  foreach (_paraview_add_plugin_ui_interface IN LISTS _paraview_add_plugin_UI_INTERFACES)
1410  string(APPEND _paraview_add_plugin_push_back_interfaces
1411  " (arg).push_back(new ${_paraview_add_plugin_ui_interface}(this)); \\\n")
1412  string(APPEND _paraview_add_plugin_include_interfaces
1413  "#include \"${_paraview_add_plugin_ui_interface}.h\"\n")
1414  endforeach ()
1415  list(APPEND _paraview_add_plugin_required_libraries
1416  ParaView::pqComponents)
1417  endif ()
1418 
1420  if (_paraview_add_plugin_INITIALIZERS)
1422  set(_paraview_add_plugin_invoke_initializers)
1423 
1424  foreach (_paraview_add_plugin_initializer IN LISTS _paraview_add_plugin_INITIALIZERS)
1425  string(APPEND _paraview_add_plugin_invoke_initializers
1426  " ${_paraview_add_plugin_initializer}();\n")
1427  endforeach ()
1428  endif ()
1429 
1430  set(_paraview_add_plugin_with_resources 0)
1431  set(_paraview_add_plugin_resources_init)
1432  if (_paraview_add_plugin_UI_RESOURCES)
1433  set(_paraview_add_plugin_with_resources 1)
1434  set(CMAKE_AUTORCC 1)
1435  if (NOT BUILD_SHARED_LIBS OR _paraview_add_plugin_FORCE_STATIC)
1436  foreach (_paraview_add_plugin_ui_resource IN LISTS _paraview_add_plugin_UI_RESOURCES)
1437  get_filename_component(_paraview_add_plugin_ui_resource_base "${_paraview_add_plugin_ui_resource}" NAME_WE)
1438  string(APPEND _paraview_add_plugin_resources_init
1439  " Q_INIT_RESOURCE(${_paraview_add_plugin_ui_resource_base});\n")
1440  endforeach ()
1441  endif ()
1442  list(APPEND _paraview_add_plugin_ui_sources
1443  ${_paraview_add_plugin_UI_RESOURCES})
1444  endif ()
1445 
1446  set(_paraview_add_plugin_qt_extra_components)
1447  if (_paraview_add_plugin_UI_FILES)
1449  set(CMAKE_AUTOUIC 1)
1450  list(APPEND _paraview_add_plugin_qt_extra_components
1451  Widgets)
1452  list(APPEND _paraview_add_plugin_required_libraries
1453  "Qt${PARAVIEW_QT_MAJOR_VERSION}::Widgets")
1454  list(APPEND _paraview_add_plugin_ui_sources
1455  ${_paraview_add_plugin_UI_FILES})
1456  endif ()
1457 
1458  if (_paraview_add_plugin_with_ui OR _paraview_add_plugin_with_resources)
1459  include("${_ParaViewPlugin_cmake_dir}/paraview-find-package-helpers.cmake" OPTIONAL)
1460  find_package("Qt${PARAVIEW_QT_MAJOR_VERSION}" QUIET REQUIRED COMPONENTS Core ${_paraview_add_plugin_qt_extra_components})
1461  list(APPEND _paraview_add_plugin_required_libraries
1462  "Qt${PARAVIEW_QT_MAJOR_VERSION}::Core")
1464  list(APPEND _paraview_add_plugin_required_libraries
1465  ParaView::pqCore)
1466  endif ()
1467 
1468  # CMake 3.13 started using Qt5's version variables to detect what version
1469  # of Qt's tools to run for automoc, autouic, and autorcc. However, they are
1470  # looked up using the target's directory scope, but these are here in a
1471  # local scope and unset when AutoGen gets around to asking about the
1472  # variables at generate time.
1473 
1474  # Fix for 3.13.0–3.13.3. Does not work if `paraview_add_plugin` is called
1475  # from another function.
1476  set("Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MAJOR" "${Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MAJOR}" PARENT_SCOPE)
1477  set("Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MINOR" "${Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MINOR}" PARENT_SCOPE)
1478  # Fix for 3.13.4+.
1479  set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
1480  PROPERTY
1481  "Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MAJOR" "${Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MAJOR}")
1482  set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
1483  PROPERTY
1484  "Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MINOR" "${Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MAJOR}")
1485  endif ()
1486 
1488  set(_paraview_add_plugin_python_sources)
1489  set(_paraview_add_plugin_python_includes)
1490  set(_paraview_add_plugin_python_modules)
1491  set(_paraview_add_plugin_python_module_sources)
1492  set(_paraview_add_plugin_python_package_flags)
1493  set(_paraview_add_plugin_python_libraries)
1494  if (_paraview_add_plugin_PYTHON_MODULES)
1496  # python code may include servermanager XML
1498  list(APPEND _paraview_add_plugin_python_libraries "ParaView::RemotingServerManagerPython")
1499  foreach (_paraview_add_plugin_python_module IN LISTS _paraview_add_plugin_PYTHON_MODULES)
1500  set(_paraview_add_plugin_python_path
1501  "${CMAKE_CURRENT_SOURCE_DIR}/${_paraview_add_plugin_python_module}")
1502  get_filename_component(_paraview_add_plugin_python_package "${_paraview_add_plugin_python_module}" PATH)
1503  get_filename_component(_paraview_add_plugin_python_name "${_paraview_add_plugin_python_module}" NAME_WE)
1504  if (_paraview_add_plugin_python_package)
1505  set(_paraview_add_plugin_python_full_name
1506  "${_paraview_add_plugin_python_package}.${_paraview_add_plugin_python_name}")
1507  else ()
1508  set(_paraview_add_plugin_python_full_name
1509  "${_paraview_add_plugin_python_name}")
1510  endif ()
1511  string(REPLACE "." "_" _paraview_add_plugin_python_module_mangled "${_paraview_add_plugin_python_full_name}")
1512  set(_paraview_add_plugin_python_is_package 0)
1513  set(_paraview_add_plugin_python_import
1514  "${_paraview_add_plugin_python_full_name}")
1515  if (_paraview_add_plugin_python_name STREQUAL "__init__")
1516  set(_paraview_add_plugin_python_is_package 1)
1517  set(_paraview_add_plugin_python_import
1518  "${_paraview_add_plugin_python_package}")
1519  endif ()
1520  set(_paraview_add_plugin_python_header_name
1521  "WrappedPython_${_paraview_build_plugin}_${_paraview_add_plugin_python_module_mangled}.h")
1522  set(_paraview_add_plugin_python_header
1523  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_add_plugin_python_header_name}")
1524 
1525  set(_paraview_add_plugin_python_depends_args)
1526  if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.27")
1527  list(APPEND _paraview_add_plugin_python_depends_args
1528  DEPENDS_EXPLICIT_ONLY)
1529  endif ()
1530 
1531  add_custom_command(
1532  OUTPUT "${_paraview_add_plugin_python_header}"
1533  COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR}
1534  "$<TARGET_FILE:ParaView::ProcessXML>"
1535  "${_paraview_add_plugin_python_header}"
1536  "module_${_paraview_add_plugin_python_module_mangled}_"
1537  "_string"
1538  "_source"
1539  "${_paraview_add_plugin_python_path}"
1540  DEPENDS "${_paraview_add_plugin_python_path}"
1541  "$<TARGET_FILE:ParaView::ProcessXML>"
1542  COMMENT "Convert Python module ${_paraview_add_plugin_python_module_name} for ${_paraview_build_plugin}"
1543  ${_paraview_add_plugin_python_depends_args})
1544 
1545  list(APPEND _paraview_add_plugin_python_sources
1546  "${_paraview_add_plugin_python_header}")
1547  string(APPEND _paraview_add_plugin_python_includes
1548  "#include \"${_paraview_add_plugin_python_header_name}\"\n")
1549  string(APPEND _paraview_add_plugin_python_modules
1550  " \"${_paraview_add_plugin_python_import}\",\n")
1551  string(APPEND _paraview_add_plugin_python_module_sources
1552  " module_${_paraview_add_plugin_python_module_mangled}_${_paraview_add_plugin_python_name}_source(),\n")
1553  string(APPEND _paraview_add_plugin_python_package_flags
1554  " ${_paraview_add_plugin_python_is_package},\n")
1555  endforeach ()
1556 
1557  # Add terminators to the list.
1558  string(APPEND _paraview_add_plugin_python_modules
1559  " nullptr")
1560  string(APPEND _paraview_add_plugin_python_module_sources
1561  " nullptr")
1562  string(APPEND _paraview_add_plugin_python_package_flags
1563  " -1")
1564  endif ()
1565 
1566  set(_paraview_add_plugin_header
1567  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_build_plugin}Plugin.h")
1568  set(_paraview_add_plugin_source
1569  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_build_plugin}Plugin.cxx")
1570 
1571  get_property(_paraview_add_plugin_description GLOBAL
1572  PROPERTY "_paraview_plugin_${_paraview_build_plugin}_description")
1573 
1574  set(_paraview_build_plugin_type MODULE)
1576  if (NOT BUILD_SHARED_LIBS OR _paraview_add_plugin_FORCE_STATIC)
1577  set(_paraview_build_plugin_type STATIC)
1579  endif ()
1580 
1581  configure_file(
1582  "${_paraview_plugin_source_dir}/paraview_plugin.h.in"
1583  "${_paraview_add_plugin_header}")
1584  configure_file(
1585  "${_paraview_plugin_source_dir}/paraview_plugin.cxx.in"
1586  "${_paraview_add_plugin_source}")
1587 
1588  if (WIN32)
1589  # On Windows, we want `MODULE` libraries to go to the runtime directory,
1590  # but CMake always uses `CMAKE_LIBRARY_OUTPUT_DIRECTORY`.
1591  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
1592  endif ()
1593  if (NOT _paraview_build_LIBRARY_SUBDIRECTORY STREQUAL "")
1594  string(APPEND CMAKE_LIBRARY_OUTPUT_DIRECTORY "/${_paraview_build_LIBRARY_SUBDIRECTORY}")
1595  endif ()
1596  string(APPEND CMAKE_LIBRARY_OUTPUT_DIRECTORY "/${_paraview_build_plugin}")
1597 
1598  # Place static plugins in the same place they would be if they were shared.
1599  if (NOT _paraview_build_LIBRARY_SUBDIRECTORY STREQUAL "")
1600  string(APPEND CMAKE_ARCHIVE_OUTPUT_DIRECTORY "/${_paraview_build_LIBRARY_SUBDIRECTORY}")
1601  endif ()
1602  string(APPEND CMAKE_ARCHIVE_OUTPUT_DIRECTORY "/${_paraview_build_plugin}")
1603 
1604  add_library("${_paraview_build_plugin}" "${_paraview_build_plugin_type}")
1605  target_sources("${_paraview_build_plugin}"
1606  PRIVATE
1607  ${_paraview_add_plugin_source}
1608  ${_paraview_add_plugin_eula_sources}
1609  ${_paraview_add_plugin_ui_sources}
1610  ${_paraview_add_plugin_python_sources}
1611  ${_paraview_add_plugin_SOURCES})
1612  # Forward the file set option internally.
1613  set(_vtk_build_USE_FILE_SETS "${_paraview_build_USE_FILE_SETS}")
1614  _vtk_module_add_file_set("${_paraview_build_plugin}"
1615  NAME paraview_plugin_headers
1616  VIS PRIVATE
1617  BASE_DIRS "${CMAKE_CURRENT_BINARY_DIR}"
1618  FILES ${_paraview_add_plugin_header}
1619  ${_paraview_add_plugin_binary_headers})
1620  if (NOT BUILD_SHARED_LIBS OR _paraview_add_plugin_FORCE_STATIC)
1621  target_compile_definitions("${_paraview_build_plugin}"
1622  PRIVATE
1623  QT_STATICPLUGIN)
1624  endif ()
1625  target_link_libraries("${_paraview_build_plugin}"
1626  PRIVATE
1627  ParaView::RemotingCore
1628  ${_paraview_add_plugin_python_libraries}
1629  ${_paraview_add_plugin_required_libraries})
1630  target_include_directories("${_paraview_build_plugin}"
1631  PRIVATE
1632  "${CMAKE_CURRENT_SOURCE_DIR}"
1633  ${_paraview_add_plugin_extra_include_dirs})
1634  set_property(TARGET "${_paraview_build_plugin}"
1635  PROPERTY
1636  PREFIX "")
1637 
1638  set(_paraview_add_plugin_destination
1639  "${_paraview_build_plugin_destination}/${_paraview_build_plugin}")
1640  install(
1641  TARGETS "${_paraview_build_plugin}"
1642  ${_paraview_add_plugin_export_args}
1643  COMPONENT "${_paraview_build_PLUGINS_COMPONENT}"
1644  ARCHIVE DESTINATION "${_paraview_add_plugin_destination}"
1645  LIBRARY DESTINATION "${_paraview_add_plugin_destination}")
1646 endfunction ()
1647 
1648 #[==[.md
1649 ## Plugin interfaces
1650 
1651 ParaView plugins may satisfy a number of interfaces. These functions all take a
1652 `INTERFACES` argument which takes the name of a variable to set with the name
1653 of the interface generated. This variable's should be passed to
1654 `paraview_add_plugin`'s `UI_INTERFACES` argument.
1655 #]==]
1656 
1657 #[==[.md
1658 ### Property widget
1659 
1660 TODO: What is a property widget?
1661 
1662 ```
1664  KIND <WIDGET|GROUP_WIDGET|WIDGET_DECORATOR>
1665  TYPE <type>
1666  CLASS_NAME <name>
1667  INTERFACES <variable>
1668  SOURCES <variable>)
1669 ```
1670 
1671  * `KIND`: The kind of widget represented.
1672  * `TYPE`: The name of the property type.
1673  * `CLASS_NAME`: The name of the property widget class.
1674  * `INTERFACES`: The name of the generated interface.
1675  * `SOURCES`: The source files generated by the interface.
1676 #]==]
1678  cmake_parse_arguments(_paraview_property_widget
1679  ""
1680  "KIND;TYPE;CLASS_NAME;INTERFACES;SOURCES"
1681  ""
1682  ${ARGN})
1683 
1684  if (_paraview_property_widget_UNPARSED_ARGUMENTS)
1685  message(FATAL_ERROR
1686  "Unparsed arguments for paraview_plugin_add_property_widget: "
1687  "${_paraview_property_widget_UNPARSED_ARGUMENTS}")
1688  endif ()
1689 
1690  set(_paraview_property_widget_kind_widget 0)
1691  set(_paraview_property_widget_kind_group_widget 0)
1692  set(_paraview_property_widget_kind_widget_decorator 0)
1693  if (_paraview_property_widget_KIND STREQUAL "WIDGET")
1694  set(_paraview_property_widget_kind_widget 1)
1695  elseif (_paraview_property_widget_KIND STREQUAL "GROUP_WIDGET")
1696  set(_paraview_property_widget_kind_group_widget 1)
1697  elseif (_paraview_property_widget_KIND STREQUAL "WIDGET_DECORATOR")
1698  set(_paraview_property_widget_kind_widget_decorator 1)
1699  else ()
1700  message(FATAL_ERROR
1701  "The `KIND` argument must be one of `WIDGET`, `GROUP_WIDGET`, or "
1702  "`WIDGET_DECORATOR`.")
1703  endif ()
1704 
1705  if (NOT DEFINED _paraview_property_widget_TYPE)
1706  message(FATAL_ERROR
1707  "The `TYPE` argument is required.")
1708  endif ()
1709 
1710  if (NOT DEFINED _paraview_property_widget_CLASS_NAME)
1711  message(FATAL_ERROR
1712  "The `CLASS_NAME` argument is required.")
1713  endif ()
1714 
1715  if (NOT DEFINED _paraview_property_widget_INTERFACES)
1716  message(FATAL_ERROR
1717  "The `INTERFACES` argument is required.")
1718  endif ()
1719 
1720  if (NOT DEFINED _paraview_property_widget_SOURCES)
1721  message(FATAL_ERROR
1722  "The `SOURCES` argument is required.")
1723  endif ()
1724 
1725  configure_file(
1726  "${_ParaViewPlugin_cmake_dir}/pqPropertyWidgetInterface.h.in"
1727  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_property_widget_CLASS_NAME}PWIImplementation.h"
1728  @ONLY)
1729  configure_file(
1730  "${_ParaViewPlugin_cmake_dir}/pqPropertyWidgetInterface.cxx.in"
1731  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_property_widget_CLASS_NAME}PWIImplementation.cxx"
1732  @ONLY)
1733 
1734  set("${_paraview_property_widget_INTERFACES}"
1735  "${_paraview_property_widget_CLASS_NAME}PWIImplementation"
1736  PARENT_SCOPE)
1737 
1738  set("${_paraview_property_widget_SOURCES}"
1739  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_property_widget_CLASS_NAME}PWIImplementation.cxx"
1740  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_property_widget_CLASS_NAME}PWIImplementation.h"
1741  PARENT_SCOPE)
1742 endfunction ()
1743 
1744 #[==[.md
1745 ### Dock window
1746 
1747 TODO: What is a dock window?
1748 
1749 ```
1751  CLASS_NAME <name>
1752  [DOCK_AREA <Right|Left|Top|Bottom>]
1753  INTERFACES <variable>
1754  SOURCES <variable>)
1755 ```
1756 
1757  * `CLASS_NAME`: The name of the dock window class.
1758  * `DOCK_AREA`: (Default `Left`) Where to dock the window within the
1759  application.
1760  * `INTERFACES`: The name of the generated interface.
1761  * `SOURCES`: The source files generated by the interface.
1762 #]==]
1764  cmake_parse_arguments(_paraview_dock_window
1765  ""
1766  "DOCK_AREA;CLASS_NAME;INTERFACES;SOURCES"
1767  ""
1768  ${ARGN})
1769 
1770  if (_paraview_dock_window_UNPARSED_ARGUMENTS)
1771  message(FATAL_ERROR
1772  "Unparsed arguments for paraview_plugin_add_dock_window: "
1773  "${_paraview_dock_window_UNPARSED_ARGUMENTS}")
1774  endif ()
1775 
1776  if (NOT DEFINED _paraview_dock_window_CLASS_NAME)
1777  message(FATAL_ERROR
1778  "The `CLASS_NAME` argument is required.")
1779  endif ()
1780 
1781  if (NOT DEFINED _paraview_dock_window_INTERFACES)
1782  message(FATAL_ERROR
1783  "The `INTERFACES` argument is required.")
1784  endif ()
1785 
1786  if (NOT DEFINED _paraview_dock_window_SOURCES)
1787  message(FATAL_ERROR
1788  "The `SOURCES` argument is required.")
1789  endif ()
1790 
1791  if (NOT DEFINED _paraview_dock_window_DOCK_AREA)
1792  set(_paraview_dock_window_DOCK_AREA "Left")
1793  endif ()
1794 
1795  if (NOT _paraview_dock_window_DOCK_AREA STREQUAL "Left" AND
1796  NOT _paraview_dock_window_DOCK_AREA STREQUAL "Right" AND
1797  NOT _paraview_dock_window_DOCK_AREA STREQUAL "Top" AND
1798  NOT _paraview_dock_window_DOCK_AREA STREQUAL "Bottom")
1799  message(FATAL_ERROR
1800  "`DOCK_AREA` must be one of `Left`, `Right`, `Top`, or `Bottom`. Got "
1801  "`${_paraview_dock_window_DOCK_AREA}`.")
1802  endif ()
1803 
1804  configure_file(
1805  "${_ParaViewPlugin_cmake_dir}/pqDockWindowImplementation.h.in"
1806  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_dock_window_CLASS_NAME}Implementation.h"
1807  @ONLY)
1808  configure_file(
1809  "${_ParaViewPlugin_cmake_dir}/pqDockWindowImplementation.cxx.in"
1810  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_dock_window_CLASS_NAME}Implementation.cxx"
1811  @ONLY)
1812 
1813  set("${_paraview_dock_window_INTERFACES}"
1814  "${_paraview_dock_window_CLASS_NAME}Implementation"
1815  PARENT_SCOPE)
1816 
1817  set("${_paraview_dock_window_SOURCES}"
1818  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_dock_window_CLASS_NAME}Implementation.cxx"
1819  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_dock_window_CLASS_NAME}Implementation.h"
1820  PARENT_SCOPE)
1821 endfunction ()
1822 
1823 #[==[.md
1824 ### Action group
1825 
1826 TODO: What is an action group?
1827 
1828 ```
1830  CLASS_NAME <name>
1831  GROUP_NAME <name>
1832  INTERFACES <variable>
1833  SOURCES <variable>)
1834 ```
1835 
1836  * `CLASS_NAME`: The name of the action group class.
1837  * `GROUP_NAME`: The name of the action group.
1838  * `INTERFACES`: The name of the generated interface.
1839  * `SOURCES`: The source files generated by the interface.
1840 #]==]
1842  cmake_parse_arguments(_paraview_action_group
1843  ""
1844  "CLASS_NAME;GROUP_NAME;INTERFACES;SOURCES"
1845  ""
1846  ${ARGN})
1847 
1848  if (_paraview_action_group_UNPARSED_ARGUMENTS)
1849  message(FATAL_ERROR
1850  "Unparsed arguments for paraview_plugin_add_action_group: "
1851  "${_paraview_action_group_UNPARSED_ARGUMENTS}")
1852  endif ()
1853 
1854  if (NOT DEFINED _paraview_action_group_CLASS_NAME)
1855  message(FATAL_ERROR
1856  "The `CLASS_NAME` argument is required.")
1857  endif ()
1858 
1859  if (NOT DEFINED _paraview_action_group_GROUP_NAME)
1860  message(FATAL_ERROR
1861  "The `GROUP_NAME` argument is required.")
1862  endif ()
1863 
1864  if (NOT DEFINED _paraview_action_group_INTERFACES)
1865  message(FATAL_ERROR
1866  "The `INTERFACES` argument is required.")
1867  endif ()
1868 
1869  if (NOT DEFINED _paraview_action_group_SOURCES)
1870  message(FATAL_ERROR
1871  "The `SOURCES` argument is required.")
1872  endif ()
1873 
1874  configure_file(
1875  "${_ParaViewPlugin_cmake_dir}/pqActionGroupImplementation.h.in"
1876  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_action_group_CLASS_NAME}Implementation.h"
1877  @ONLY)
1878  configure_file(
1879  "${_ParaViewPlugin_cmake_dir}/pqActionGroupImplementation.cxx.in"
1880  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_action_group_CLASS_NAME}Implementation.cxx"
1881  @ONLY)
1882 
1883  set("${_paraview_action_group_INTERFACES}"
1884  "${_paraview_action_group_CLASS_NAME}Implementation"
1885  PARENT_SCOPE)
1886 
1887  set("${_paraview_action_group_SOURCES}"
1888  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_action_group_CLASS_NAME}Implementation.cxx"
1889  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_action_group_CLASS_NAME}Implementation.h"
1890  PARENT_SCOPE)
1891 endfunction ()
1892 
1893 #[==[.md
1894 ### Toolbar
1895 
1896 TODO: What is a toolbar?
1897 
1898 ```
1900  CLASS_NAME <name>
1901  INTERFACES <variable>
1902  SOURCES <variable>)
1903 ```
1904 
1905  * `CLASS_NAME`: The name of the toolbar class.
1906  * `INTERFACES`: The name of the generated interface.
1907  * `SOURCES`: The source files generated by the interface.
1908 #]==]
1910  cmake_parse_arguments(_paraview_toolbar
1911  ""
1912  "CLASS_NAME;INTERFACES;SOURCES"
1913  ""
1914  ${ARGN})
1915 
1916  if (_paraview_toolbar_UNPARSED_ARGUMENTS)
1917  message(FATAL_ERROR
1918  "Unparsed arguments for paraview_plugin_add_toolbar: "
1919  "${_paraview_toolbar_UNPARSED_ARGUMENTS}")
1920  endif ()
1921 
1922  if (NOT DEFINED _paraview_toolbar_CLASS_NAME)
1923  message(FATAL_ERROR
1924  "The `CLASS_NAME` argument is required.")
1925  endif ()
1926 
1927  if (NOT DEFINED _paraview_toolbar_INTERFACES)
1928  message(FATAL_ERROR
1929  "The `INTERFACES` argument is required.")
1930  endif ()
1931 
1932  if (NOT DEFINED _paraview_toolbar_SOURCES)
1933  message(FATAL_ERROR
1934  "The `SOURCES` argument is required.")
1935  endif ()
1936 
1937  configure_file(
1938  "${_ParaViewPlugin_cmake_dir}/pqToolBarImplementation.h.in"
1939  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_toolbar_CLASS_NAME}Implementation.h"
1940  @ONLY)
1941  configure_file(
1942  "${_ParaViewPlugin_cmake_dir}/pqToolBarImplementation.cxx.in"
1943  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_toolbar_CLASS_NAME}Implementation.cxx"
1944  @ONLY)
1945 
1946  set("${_paraview_toolbar_INTERFACES}"
1947  "${_paraview_toolbar_CLASS_NAME}Implementation"
1948  PARENT_SCOPE)
1949 
1950  set("${_paraview_toolbar_SOURCES}"
1951  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_toolbar_CLASS_NAME}Implementation.cxx"
1952  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_toolbar_CLASS_NAME}Implementation.h"
1953  PARENT_SCOPE)
1954 endfunction ()
1955 
1956 #[==[.md
1957 ### Auto start
1958 
1959 TODO: What is an auto start?
1960 
1961 ```
1963  CLASS_NAME <name>
1964  [STARTUP <function>]
1965  [SHUTDOWN <function>]
1966  INTERFACES <variable>
1967  SOURCES <variable>)
1968 ```
1969 
1970  * `CLASS_NAME`: The name of the auto start class.
1971  * `STARTUP`: (Defaults to `startup`) The name of the method to call on
1972  startup.
1973  * `SHUTDOWN`: (Defaults to `shutdown`) The name of the method to call on
1974  shutdown.
1975  * `INTERFACES`: The name of the generated interface.
1976  * `SOURCES`: The source files generated by the interface.
1977 #]==]
1979  cmake_parse_arguments(_paraview_auto_start
1980  ""
1981  "CLASS_NAME;INTERFACES;SOURCES;STARTUP;SHUTDOWN"
1982  ""
1983  ${ARGN})
1984 
1985  if (_paraview_auto_start_UNPARSED_ARGUMENTS)
1986  message(FATAL_ERROR
1987  "Unparsed arguments for paraview_plugin_add_auto_start: "
1988  "${_paraview_auto_start_UNPARSED_ARGUMENTS}")
1989  endif ()
1990 
1991  if (NOT DEFINED _paraview_auto_start_CLASS_NAME)
1992  message(FATAL_ERROR
1993  "The `CLASS_NAME` argument is required.")
1994  endif ()
1995 
1996  if (NOT DEFINED _paraview_auto_start_INTERFACES)
1997  message(FATAL_ERROR
1998  "The `INTERFACES` argument is required.")
1999  endif ()
2000 
2001  if (NOT DEFINED _paraview_auto_start_SOURCES)
2002  message(FATAL_ERROR
2003  "The `SOURCES` argument is required.")
2004  endif ()
2005 
2006  if (NOT DEFINED _paraview_auto_start_STARTUP)
2007  set(_paraview_auto_start_STARTUP "startup")
2008  endif ()
2009 
2010  if (NOT DEFINED _paraview_auto_start_SHUTDOWN)
2011  set(_paraview_auto_start_SHUTDOWN "shutdown")
2012  endif ()
2013 
2014  configure_file(
2015  "${_ParaViewPlugin_cmake_dir}/pqAutoStartImplementation.h.in"
2016  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_auto_start_CLASS_NAME}Implementation.h"
2017  @ONLY)
2018  configure_file(
2019  "${_ParaViewPlugin_cmake_dir}/pqAutoStartImplementation.cxx.in"
2020  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_auto_start_CLASS_NAME}Implementation.cxx"
2021  @ONLY)
2022 
2023  set("${_paraview_auto_start_INTERFACES}"
2024  "${_paraview_auto_start_CLASS_NAME}Implementation"
2025  PARENT_SCOPE)
2026 
2027  set("${_paraview_auto_start_SOURCES}"
2028  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_auto_start_CLASS_NAME}Implementation.cxx"
2029  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_auto_start_CLASS_NAME}Implementation.h"
2030  PARENT_SCOPE)
2031 endfunction ()
2032 
2033 #[==[.md
2034 ### Location
2035 
2036 The filesystem location of dynamically-loaded plugin.
2037 
2038 ```
2040  CLASS_NAME <name>
2041  [STORE <function>]
2042  INTERFACES <variable>
2043  SOURCES <variable>)
2044 ```
2045 
2046  * `CLASS_NAME`: The name of the location class.
2047  * `STORE`: (Defaults to `StoreLocation`) The name of the method to call on
2048  startup, passing in the plugin location (const char*).
2049  * `INTERFACES`: The name of the generated interface.
2050  * `SOURCES`: The source files generated by the interface.
2051 #]==]
2053  cmake_parse_arguments(_paraview_location
2054  ""
2055  "CLASS_NAME;INTERFACES;SOURCES;STORE"
2056  ""
2057  ${ARGN})
2058 
2059  if (_paraview_location_UNPARSED_ARGUMENTS)
2060  message(FATAL_ERROR
2061  "Unparsed arguments for paraview_plugin_add_location: "
2062  "${_paraview_location_UNPARSED_ARGUMENTS}")
2063  endif ()
2064 
2065  if (NOT DEFINED _paraview_location_CLASS_NAME)
2066  message(FATAL_ERROR
2067  "The `CLASS_NAME` argument is required.")
2068  endif ()
2069 
2070  if (NOT DEFINED _paraview_location_INTERFACES)
2071  message(FATAL_ERROR
2072  "The `INTERFACES` argument is required.")
2073  endif ()
2074 
2075  if (NOT DEFINED _paraview_location_SOURCES)
2076  message(FATAL_ERROR
2077  "The `SOURCES` argument is required.")
2078  endif ()
2079 
2080  if (NOT DEFINED _paraview_location_STORE)
2081  set(_paraview_location_STORE "StoreLocation")
2082  endif ()
2083 
2084  configure_file(
2085  "${_ParaViewPlugin_cmake_dir}/pqPluginLocationImplementation.h.in"
2086  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_location_CLASS_NAME}Implementation.h"
2087  @ONLY)
2088  configure_file(
2089  "${_ParaViewPlugin_cmake_dir}/pqPluginLocationImplementation.cxx.in"
2090  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_location_CLASS_NAME}Implementation.cxx"
2091  @ONLY)
2092 
2093  set("${_paraview_location_INTERFACES}"
2094  "${_paraview_location_CLASS_NAME}Implementation"
2095  PARENT_SCOPE)
2096 
2097  set("${_paraview_location_SOURCES}"
2098  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_location_CLASS_NAME}Implementation.cxx"
2099  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_location_CLASS_NAME}Implementation.h"
2100  PARENT_SCOPE)
2101 endfunction ()
2102 
2103 #[==[.md
2104 ### Tree layout strategy
2105 
2106 TODO: What is a tree layout strategy?
2107 
2108 ```
2110  STRATEGY_TYPE <type>
2111  STRATEGY_LABEL <label>
2112  INTERFACES <variable>
2113  SOURCES <variable>)
2114 ```
2115 
2116  * `STRATEGY_TYPE`: The name of the tree layout strategy class.
2117  * `STRATEGY_LABEL`: The label to use for the strategy.
2118  * `INTERFACES`: The name of the generated interface.
2119  * `SOURCES`: The source files generated by the interface.
2120 #]==]
2122  cmake_parse_arguments(_paraview_tree_layout_strategy
2123  ""
2124  "INTERFACES;SOURCES;STRATEGY_TYPE;STRATEGY_LABEL"
2125  ""
2126  ${ARGN})
2127 
2128  if (_paraview_tree_layout_strategy_UNPARSED_ARGUMENTS)
2129  message(FATAL_ERROR
2130  "Unparsed arguments for paraview_plugin_add_tree_layout_strategy: "
2131  "${_paraview_tree_layout_strategy_UNPARSED_ARGUMENTS}")
2132  endif ()
2133 
2134  if (NOT DEFINED _paraview_tree_layout_strategy_STRATEGY_TYPE)
2135  message(FATAL_ERROR
2136  "The `STRATEGY_TYPE` argument is required.")
2137  endif ()
2138 
2139  if (NOT DEFINED _paraview_tree_layout_strategy_STRATEGY_LABEL)
2140  message(FATAL_ERROR
2141  "The `STRATEGY_LABEL` argument is required.")
2142  endif ()
2143 
2144  if (NOT DEFINED _paraview_tree_layout_strategy_INTERFACES)
2145  message(FATAL_ERROR
2146  "The `INTERFACES` argument is required.")
2147  endif ()
2148 
2149  if (NOT DEFINED _paraview_tree_layout_strategy_SOURCES)
2150  message(FATAL_ERROR
2151  "The `SOURCES` argument is required.")
2152  endif ()
2153 
2154  configure_file(
2155  "${_ParaViewPlugin_cmake_dir}/pqTreeLayoutStrategyImplementation.h.in"
2156  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_tree_layout_strategy_STRATEGY_TYPE}Implementation.h"
2157  @ONLY)
2158  configure_file(
2159  "${_ParaViewPlugin_cmake_dir}/pqTreeLayoutStrategyImplementation.cxx.in"
2160  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_tree_layout_strategy_STRATEGY_TYPE}Implementation.cxx"
2161  @ONLY)
2162 
2163  set("${_paraview_tree_layout_strategy_INTERFACES}"
2164  "${_paraview_tree_layout_strategy_STRATEGY_TYPE}Implementation"
2165  PARENT_SCOPE)
2166 
2167  set("${_paraview_tree_layout_strategy_SOURCES}"
2168  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_tree_layout_strategy_STRATEGY_TYPE}Implementation.cxx"
2169  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_tree_layout_strategy_STRATEGY_TYPE}Implementation.h"
2170  PARENT_SCOPE)
2171 endfunction ()
2172 
2173 #[==[.md
2174 ### Proxy
2175 
2176 TODO: What is a proxy?
2177 
2178 ```
2180  NAME <name>
2181  INTERFACES <variable>
2182  SOURCES <variable>
2183  [PROXY_TYPE <type>
2184  [CLASS_NAME <class>]
2185  XML_GROUP <group>
2186  <XML_NAME|XML_NAME_REGEX> <name>]...)
2187 ```
2188 
2189  * `NAME`: The name of the proxy.
2190  * `INTERFACES`: The name of the generated interface.
2191  * `SOURCES`: The source files generated by the interface.
2192 
2193 At least one `PROXY_TYPE` must be specified. Each proxy type must be given an
2194 `XML_GROUP` and either an `XML_NAME` or `XML_NAME_REGEX`. If `CLASS_NAME` is
2195 not given, the `PROXY_TYPE` name is used instead.
2196 #]==]
2198  cmake_parse_arguments(_paraview_proxy
2199  ""
2200  "INTERFACES;SOURCES;NAME"
2201  ""
2202  ${ARGN})
2203 
2204  if (NOT DEFINED _paraview_proxy_INTERFACES)
2205  message(FATAL_ERROR
2206  "The `INTERFACES` argument is required.")
2207  endif ()
2208 
2209  if (NOT DEFINED _paraview_proxy_SOURCES)
2210  message(FATAL_ERROR
2211  "The `SOURCES` argument is required.")
2212  endif ()
2213 
2214  if (NOT DEFINED _paraview_proxy_NAME)
2215  message(FATAL_ERROR
2216  "The `NAME` argument is required.")
2217  endif ()
2218 
2219  set(_paraview_proxy_parse "")
2220  set(_paraview_proxy_type)
2221  set(_paraview_proxy_types)
2222  foreach (_paraview_proxy_arg IN LISTS _paraview_proxy_UNPARSED_ARGUMENTS)
2223  if (_paraview_proxy_parse STREQUAL "")
2224  set(_paraview_proxy_parse "${_paraview_proxy_arg}")
2225  elseif (_paraview_proxy_parse STREQUAL "PROXY_TYPE")
2226  set(_paraview_proxy_type "${_paraview_proxy_arg}")
2227  list(APPEND _paraview_proxy_types "${_paraview_proxy_type}")
2228  set(_paraview_proxy_parse "")
2229  elseif (_paraview_proxy_parse STREQUAL "CLASS_NAME")
2230  if (NOT _paraview_proxy_type)
2231  message(FATAL_ERROR
2232  "Missing `PROXY_TYPE` for `CLASS_NAME`")
2233  endif ()
2234  if (DEFINED "_paraview_proxy_type_${_paraview_proxy_type}_class_name")
2235  message(FATAL_ERROR
2236  "Duplicate `CLASS_NAME` for `${_paraview_proxy_type}`")
2237  endif ()
2238  set("_paraview_proxy_type_${_paraview_proxy_type}_class_name"
2239  "${_paraview_proxy_arg}")
2240  set(_paraview_proxy_parse "")
2241  elseif (_paraview_proxy_parse STREQUAL "XML_GROUP")
2242  if (NOT _paraview_proxy_type)
2243  message(FATAL_ERROR
2244  "Missing `PROXY_TYPE` for `XML_GROUP`")
2245  endif ()
2246  if (DEFINED "_paraview_proxy_type_${_paraview_proxy_type}_xml_group")
2247  message(FATAL_ERROR
2248  "Duplicate `XML_GROUP` for `${_paraview_proxy_type}`")
2249  endif ()
2250  set("_paraview_proxy_type_${_paraview_proxy_type}_xml_group"
2251  "${_paraview_proxy_arg}")
2252  set(_paraview_proxy_parse "")
2253  elseif (_paraview_proxy_parse STREQUAL "XML_NAME")
2254  if (NOT _paraview_proxy_type)
2255  message(FATAL_ERROR
2256  "Missing `PROXY_TYPE` for `XML_NAME`")
2257  endif ()
2258  if (DEFINED "_paraview_proxy_type_${_paraview_proxy_type}_xml_name" OR
2259  DEFINED "_paraview_proxy_type_${_paraview_proxy_type}_xml_name_regex")
2260  message(FATAL_ERROR
2261  "Duplicate `XML_NAME` or `XML_NAME_REGEX` for `${_paraview_proxy_type}`")
2262  endif ()
2263  set("_paraview_proxy_type_${_paraview_proxy_type}_xml_name"
2264  "${_paraview_proxy_arg}")
2265  set(_paraview_proxy_parse "")
2266  elseif (_paraview_proxy_parse STREQUAL "XML_NAME_REGEX")
2267  if (NOT _paraview_proxy_type)
2268  message(FATAL_ERROR
2269  "Missing `PROXY_TYPE` for `XML_NAME_REGEX`")
2270  endif ()
2271  if (DEFINED "_paraview_proxy_type_${_paraview_proxy_type}_xml_name" OR
2272  DEFINED "_paraview_proxy_type_${_paraview_proxy_type}_xml_name_regex")
2273  message(FATAL_ERROR
2274  "Duplicate `XML_NAME` or `XML_NAME_REGEX` for `${_paraview_proxy_type}`")
2275  endif ()
2276  set("_paraview_proxy_type_${_paraview_proxy_type}_xml_name_regex"
2277  "${_paraview_proxy_arg}")
2278  set(_paraview_proxy_parse "")
2279  else ()
2280  message(FATAL_ERROR
2281  "Unknown argument `${_paraview_proxy_parse}`")
2282  endif ()
2283  endforeach ()
2284 
2285  if (_paraview_proxy_parse)
2286  message(FATAL_ERROR
2287  "Missing argument for `${_paraview_proxy_parse}`")
2288  endif ()
2289 
2290  if (NOT _paraview_proxy_types)
2291  message(FATAL_ERROR
2292  "No `PROXY_TYPE` arguments given")
2293  endif ()
2294 
2295  set(_paraview_proxy_includes)
2296  set(_paraview_proxy_body)
2297  foreach (_paraview_proxy_type IN LISTS _paraview_proxy_types)
2298  if (NOT DEFINED "_paraview_proxy_type_${_paraview_proxy_type}_xml_group")
2299  message(FATAL_ERROR
2300  "Missing `XML_GROUP` for `${_paraview_proxy_type}`")
2301  endif ()
2302  if (NOT DEFINED "_paraview_proxy_type_${_paraview_proxy_type}_xml_name" AND
2303  NOT DEFINED "_paraview_proxy_type_${_paraview_proxy_type}_xml_name_regex")
2304  message(FATAL_ERROR
2305  "Missing `XML_NAME` or `XML_NAME_REGEX` for `${_paraview_proxy_type}`")
2306  endif ()
2307  if (DEFINED "_paraview_proxy_type_${_paraview_proxy_type}_class_name")
2308  set(_paraview_proxy_class
2309  "${_paraview_proxy_type_${_paraview_proxy_type}_class_name}")
2310  else ()
2311  set(_paraview_proxy_class
2312  "${_paraview_proxy_type}")
2313  endif ()
2314 
2315  set(_paraview_proxy_group "${_paraview_proxy_type_${_paraview_proxy_type}_xml_group}")
2316  if (DEFINED "_paraview_proxy_type_${_paraview_proxy_type}_xml_name")
2317  set(_paraview_proxy_name "${_paraview_proxy_type_${_paraview_proxy_type}_xml_name}")
2318  set(_paraview_proxy_name_type "QString")
2319  set(_paraview_proxy_cmp "name == proxy->GetXMLName()")
2320  else ()
2321  set(_paraview_proxy_name "${_paraview_proxy_type_${_paraview_proxy_type}_xml_name_regex}")
2322  set(_paraview_proxy_name_type "QRegularExpression")
2323  set(_paraview_proxy_cmp "QString(proxy->GetXMLName()).contains(name)")
2324  endif ()
2325 
2326  if (NOT DEFINED "_paraview_proxy_included_${_paraview_proxy_class}")
2327  string(APPEND _paraview_proxy_includes
2328  "#include \"${_paraview_proxy_class}.h\"\n")
2329  set("_paraview_proxy_included_${_paraview_proxy_class}" 1)
2330  endif ()
2331  string(APPEND _paraview_proxy_body
2332  " {
2333  static const QString group(\"${_paraview_proxy_group}\");
2334  static const ${_paraview_proxy_name_type} name(\"${_paraview_proxy_name}\");
2335  if (group == proxy->GetXMLGroup() && ${_paraview_proxy_cmp})
2336  {
2337  return new ${_paraview_proxy_class}(regGroup, regName, proxy, server, nullptr);
2338  }
2339  }\n")
2340  endforeach ()
2341 
2342  configure_file(
2343  "${_ParaViewPlugin_cmake_dir}/pqServerManagerModelImplementation.h.in"
2344  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_proxy_NAME}ServerManagerModelImplementation.h"
2345  @ONLY)
2346  configure_file(
2347  "${_ParaViewPlugin_cmake_dir}/pqServerManagerModelImplementation.cxx.in"
2348  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_proxy_NAME}ServerManagerModelImplementation.cxx"
2349  @ONLY)
2350 
2351  set("${_paraview_proxy_INTERFACES}"
2352  "${_paraview_proxy_NAME}ServerManagerModelImplementation"
2353  PARENT_SCOPE)
2354 
2355  set("${_paraview_proxy_SOURCES}"
2356  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_proxy_NAME}ServerManagerModelImplementation.cxx"
2357  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_proxy_NAME}ServerManagerModelImplementation.h"
2358  PARENT_SCOPE)
2359 endfunction ()
2360 
2361 cmake_policy(POP)
description
function paraview_plugin_add_action_group()
.md Action group
function paraview_server_manager_process_files()
.md The second way to process XML files directly.
location
component
content
#define _paraview_add_plugin_with_ui
order
#define _paraview_add_plugin_with_initializers
#define _paraview_add_plugin_with_xml
type
on
function paraview_plugin_add_dock_window()
.md Dock window
version
function paraview_plugin_add_auto_start()
.md Auto start
#define _paraview_add_plugin_built_shared
EXPORT
string
function paraview_plugin_add_property_widget()
.md Plugin interfaces
std::string replace(std::string source, const std::string &search, const std::string &replace, bool all)
name
function paraview_plugin_add_toolbar()
.md Toolbar
function paraview_plugin_add_proxy()
.md Proxy
function
function paraview_plugin_scan()
.md Scanning plugins
function paraview_client_generate_help()
.md Generating help documentation
time
function paraview_plugin_add_location()
.md Location
function paraview_server_manager_process()
.md Building XML files
function paraview_plugin_write_conf()
.md Plugin configuration files
#define VERSION
Definition: jconfigint.h:17
function vtk_module_wrap_client_server()
.md Wrapping a set of VTK modules for ClientServer
function paraview_client_documentation()
.md Documentation from XML files
#define BUILD_SHARED_LIBS
Definition: config.h:45
source
#define PACKAGE
Definition: expat_config.h:67
enabled
top
documentation
value
function _paraview_plugin_debug(domain, format)
.md ParaView Plugin CMake API
function paraview_add_plugin(name)
.md Adding a plugin
#define _paraview_add_plugin_with_python
function paraview_plugin_add_tree_layout_strategy()
.md Tree layout strategy
function paraview_plugin_build()
.md Building plugins