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