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