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