ParaViewClient.cmake
Go to the documentation of this file.
1 set(_ParaViewClient_cmake_dir "${CMAKE_CURRENT_LIST_DIR}")
2 set(_ParaViewClient_script_file "${CMAKE_CURRENT_LIST_FILE}")
3 
4 #[==[.md
5 ## Building a client
6 
7 TODO: Document
8 
9 ```
11  NAME <name>
12  VERSION <version>
13  SOURCES <source>...
14  [APPLICATION_XMLS <xml>...]
15  [QCH_FILES <file>...]
16 
17  [MAIN_WINDOW_CLASS <class>]
18  [MAIN_WINDOW_INCLUDE <include>]
19 
20  [PLUGINS_TARGETS <target>...]
21  [REQUIRED_PLUGINS <plugin>...]
22  [OPTIONAL_PLUGINS <plugin>...]
23 
24  [APPLICATION_NAME <name>]
25  [ORGANIZATION <organization>]
26  [TITLE <title>]
27 
28  [DEFAULT_STYLE <style>]
29 
30  [APPLICATION_ICON <icon>]
31  [BUNDLE_ICON <icon>]
32  [BUNDLE_PLIST <plist>]
33  [SPLASH_IMAGE <image>]
34 
35  [NAMESPACE <namespace>]
36  [EXPORT <export>]
37  [FORCE_UNIX_LAYOUT <ON|OFF>]
38  [BUNDLE_DESTINATION <directory>]
39  [RUNTIME_DESTINATION <directory>]
40  [LIBRARY_DESTINATION <directory>]
41 
42  [TRANSLATE_XML <ON|OFF>]
43  [TRANSLATIONS_DIRECTORY <directory>]
44  [TRANSLATION_TARGET <target>])
45 ```
46 
47  * `NAME`: (Required) The name of the application. This is used as the target
48  name as well.
49  * `VERSION`: (Required) The version of the application.
50  * `SOURCES`: (Required) Source files for the application.
51  * `APPLICATION_XMLS`: Server manager XML files.
52  * `QCH_FILES`: Any `.qch` files containing documentation.
53  * `MAIN_WINDOW_CLASS`: (Defaults to `QMainWindow`) The name of the main
54  window class.
55  * `MAIN_WINDOW_INCLUDE`: (Defaults to `QMainWindow` or
56  `<MAIN_WINDOW_CLASS>.h` if it is specified) The include file for the main
57  window.
58  * `PLUGINS_TARGETS`: The targets for plugins. The associated functions
59  will be called upon startup.
60  * `REQUIRED_PLUGINS`: Plugins to load upon startup.
61  * `OPTIONAL_PLUGINS`: Plugins to load upon startup if available.
62  * `APPLICATION_NAME`: (Defaults to `<NAME>`) The displayed name of the
63  application.
64  * `ORGANIZATION`: (Defaults to `Anonymous`) The organization for the
65  application. This is used for the macOS GUI identifier.
66  * `TITLE`: The window title for the application.
67  * `DEFAULT_STYLE`: The default Qt style for the application.
68  * `APPLICATION_ICON`: The path to the icon for the Windows application.
69  * `BUNDLE_ICON`: The path to the icon for the macOS bundle.
70  * `BUNDLE_PLIST`: The path to the `Info.plist.in` template.
71  * `SPLASH_IMAGE`: The image to display upon startup.
72  * `NAMESPACE`: If provided, an alias target `<NAMESPACE>::<NAME>` will be
73  created.
74  * `EXPORT`: If provided, the target will be exported.
75  * `FORCE_UNIX_LAYOUT`: (Defaults to `OFF`) Forces a Unix-style layout even on
76  platforms for which they are not the norm for GUI applications (e.g.,
77  macOS).
78  * `BUNDLE_DESTINATION`: (Defaults to `Applications`) Where to place the
79  bundle executable.
80  * `RUNTIME_DESTINATION`: (Defaults to `${CMAKE_INSTALL_BINDIR}`) Where to
81  place the binary.
82  * `LIBRARY_DESTINATION`: (Defaults to `${CMAKE_INSTALL_LIBDIR}`) Where
83  libraries are placed. Sets up `RPATH` on ELF platforms (e.g., Linux and the
84  BSD family).
85  * `TRANSLATE_XML`: (Defaults to `OFF`) Produce a translations source file
86  from APPLICATION_XMLS files.
87  * `TRANSLATIONS_DIRECTORY`: (Defaults to `${CMAKE_CURRENT_BINARY_DIR}/Translations`)
88  The path of the directory where translation source files are stored.
89  * `TRANSLATION_TARGET` : The name of the target on which to add the ts file as
90  dependency.
91 #]==]
93  cmake_parse_arguments(_paraview_client
94  ""
95  "NAME;APPLICATION_NAME;ORGANIZATION;TITLE;SPLASH_IMAGE;BUNDLE_DESTINATION;BUNDLE_ICON;BUNDLE_PLIST;APPLICATION_ICON;MAIN_WINDOW_CLASS;MAIN_WINDOW_INCLUDE;VERSION;FORCE_UNIX_LAYOUT;PLUGINS_TARGET;DEFAULT_STYLE;RUNTIME_DESTINATION;LIBRARY_DESTINATION;NAMESPACE;EXPORT;TRANSLATION_TARGET;TRANSLATE_XML;TRANSLATIONS_DIRECTORY"
96  "REQUIRED_PLUGINS;OPTIONAL_PLUGINS;APPLICATION_XMLS;SOURCES;QCH_FILES;QCH_FILE;PLUGINS_TARGETS"
97  ${ARGN})
98 
99  if (_paraview_client_UNPARSED_ARGUMENTS)
100  message(FATAL_ERROR
101  "Unparsed arguments for paraview_client_add: "
102  "${_paraview_client_UNPARSED_ARGUMENTS}")
103  endif ()
104 
105  # TODO: Installation.
106 
107  if (DEFINED _paraview_client_PLUGINS_TARGET)
108  if (DEFINED _paraview_client_PLUGINS_TARGETS)
109  message(FATAL_ERROR
110  "The `paraview_client_add(PLUGINS_TARGET)` argument is incompatible "
111  "with `PLUGINS_TARGETS`.")
112  else ()
113  message(DEPRECATION
114  "The `paraview_client_add(PLUGINS_TARGET)` argument is deprecated in "
115  "favor of `PLUGINS_TARGETS`.")
116  set(_paraview_client_PLUGINS_TARGETS
117  "${_paraview_client_PLUGINS_TARGET}")
118  endif ()
119  endif ()
120 
121  if (NOT DEFINED _paraview_client_NAME)
122  message(FATAL_ERROR
123  "The `NAME` argument is required.")
124  endif ()
125 
126  if (NOT DEFINED _paraview_client_VERSION)
127  message(FATAL_ERROR
128  "The `VERSION` argument is required.")
129  endif ()
130 
131  if (NOT DEFINED _paraview_client_SOURCES)
132  message(FATAL_ERROR
133  "The `SOURCES` argument is required.")
134  endif ()
135 
136  if (NOT DEFINED _paraview_client_APPLICATION_NAME)
137  set(_paraview_client_APPLICATION_NAME
138  "${_paraview_client_NAME}")
139  endif ()
140 
141  if (NOT DEFINED _paraview_client_ORGANIZATION)
142  set(_paraview_client_ORGANIZATION
143  "Anonymous")
144  endif ()
145 
146  if (NOT DEFINED _paraview_client_FORCE_UNIX_LAYOUT)
147  set(_paraview_client_FORCE_UNIX_LAYOUT
148  OFF)
149  endif ()
150 
151  if (NOT DEFINED _paraview_client_BUNDLE_DESTINATION)
152  set(_paraview_client_BUNDLE_DESTINATION
153  "Applications")
154  endif ()
155 
156  if (NOT DEFINED _paraview_client_RUNTIME_DESTINATION)
157  set(_paraview_client_RUNTIME_DESTINATION
158  "${CMAKE_INSTALL_BINDIR}")
159  endif ()
160 
161  if (NOT DEFINED _paraview_client_LIBRARY_DESTINATION)
162  set(_paraview_client_LIBRARY_DESTINATION
163  "${CMAKE_INSTALL_LIBDIR}")
164  endif ()
165 
166  if (DEFINED _paraview_client_QCH_FILE)
167  if (DEFINED _paraview_client_QCH_FILES)
168  message(FATAL_ERROR
169  "The `paraview_client_add(QCH_FILE)` argument is incompatible "
170  "with `QCH_FILES`.")
171  else ()
172  message(DEPRECATION
173  "The `paraview_client_add(QCH_FILE)` argument is deprecated in "
174  "favor of `QCH_FILES`.")
175  set(_paraview_client_QCH_FILES
176  "${_paraview_client_QCH_FILE}")
177  endif ()
178  endif ()
179 
180  if (NOT DEFINED _paraview_client_MAIN_WINDOW_CLASS)
181  if (DEFINED _paraview_client_MAIN_WINDOW_INCLUDE)
182  message(FATAL_ERROR
183  "The `MAIN_WINDOW_INCLUDE` argument cannot be specified without "
184  "`MAIN_WINDOW_CLASS`.")
185  endif ()
186 
187  set(_paraview_client_MAIN_WINDOW_CLASS
188  "QMainWindow")
189  set(_paraview_client_MAIN_WINDOW_INCLUDE
190  "QMainWindow")
191  endif ()
192 
193  if (NOT DEFINED _paraview_client_MAIN_WINDOW_INCLUDE)
194  set(_paraview_client_MAIN_WINDOW_INCLUDE
195  "${_paraview_client_MAIN_WINDOW_CLASS}.h")
196  endif ()
197 
198  set(_paraview_client_extra_sources)
199  set(_paraview_client_bundle_args)
200 
201  set(_paraview_client_executable_flags)
202  if (WIN32)
203  if (DEFINED _paraview_client_APPLICATION_ICON)
204  set(_paraview_client_appicon_file
205  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_client_NAME}_appicon.rc")
206  file(WRITE "${_paraview_client_appicon_file}.tmp"
207  "// Icon with the lowest ID value placed first to ensure that the application
208 // icon remains consistent on all systems.
209 IDI_ICON1 ICON \"${_paraview_client_APPLICATION_ICON}\"\n")
210  configure_file(
211  "${_paraview_client_appicon_file}.tmp"
212  "${_paraview_client_appicon_file}"
213  COPYONLY)
214 
215  list(APPEND _paraview_client_extra_sources
216  "${_paraview_client_appicon_file}")
217  endif ()
218 
219  list(APPEND _paraview_client_executable_flags
220  WIN32)
221  elseif (APPLE)
222  # TODO: nib files
223 
224  list(APPEND _paraview_client_bundle_args
225  BUNDLE DESTINATION "${_paraview_client_BUNDLE_DESTINATION}")
226  list(APPEND _paraview_client_executable_flags
227  MACOSX_BUNDLE)
228  endif ()
229 
230  set(_paraview_client_resource_files "")
231  set(_paraview_client_resource_init "")
232 
233  if (DEFINED _paraview_client_SPLASH_IMAGE)
234  set(_paraview_client_splash_base_name
235  "${_paraview_client_NAME}_splash")
236  set(_paraview_client_splash_image_name
237  "${_paraview_client_splash_base_name}.img")
238  set(_paraview_client_splash_resource
239  ":/${_paraview_client_NAME}/${_paraview_client_splash_base_name}")
240 
241  set(_paraview_client_splash_resource_file
242  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_client_splash_base_name}.qrc")
243 
245  OUTPUT "${_paraview_client_splash_resource_file}"
246  PREFIX "/${_paraview_client_NAME}"
247  ALIAS "${_paraview_client_splash_base_name}"
248  FILE "${_paraview_client_SPLASH_IMAGE}")
249 
250  list(APPEND _paraview_client_resource_files
251  "${_paraview_client_splash_resource_file}")
252  string(APPEND _paraview_client_resource_init
253  " Q_INIT_RESOURCE(${_paraview_client_splash_base_name});\n")
254  set(CMAKE_AUTORCC 1)
255  endif ()
256 
257  if (DEFINED _paraview_client_APPLICATION_XMLS)
258  set(_paraview_client_application_base_name
259  "${_paraview_client_NAME}_configuration")
260  set(_paraview_client_application_resource_file
261  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_client_application_base_name}.qrc")
262 
264  OUTPUT "${_paraview_client_application_resource_file}"
265  PREFIX "/${_paraview_client_NAME}/Configuration"
266  FILES "${_paraview_client_APPLICATION_XMLS}")
267 
268  list(APPEND _paraview_client_resource_files
269  "${_paraview_client_application_resource_file}")
270  string(APPEND _paraview_client_resource_init
271  " Q_INIT_RESOURCE(${_paraview_client_application_base_name});\n")
272  set(CMAKE_AUTORCC 1)
273  endif ()
274 
275  if (DEFINED _paraview_client_QCH_FILES)
276  set(_paraview_client_documentation_base_name
277  "${_paraview_client_NAME}_documentation")
278  set(_paraview_client_documentation_resource_file
279  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_client_documentation_base_name}.qrc")
280 
282  OUTPUT "${_paraview_client_documentation_resource_file}"
283  # This prefix is part of the API.
284  PREFIX "/${_paraview_client_NAME}/Documentation"
285  FILES ${_paraview_client_QCH_FILES})
286  set_property(SOURCE "${_paraview_client_documentation_resource_file}"
287  PROPERTY
288  OBJECT_DEPENDS "${_paraview_client_QCH_FILES}")
289 
290  list(APPEND _paraview_client_resource_files
291  "${_paraview_client_documentation_resource_file}")
292  string(APPEND _paraview_client_resource_init
293  " Q_INIT_RESOURCE(${_paraview_client_documentation_base_name});\n")
294  set(CMAKE_AUTORCC 1)
295  endif ()
296 
297  include("${_ParaViewClient_cmake_dir}/paraview-find-package-helpers.cmake" OPTIONAL)
298  find_package("Qt${PARAVIEW_QT_MAJOR_VERSION}" REQUIRED QUIET COMPONENTS Core Widgets)
299 
300  # CMake 3.13 started using Qt5's version variables to detect what version
301  # of Qt's tools to run for autorcc. However, they are looked up using the
302  # target's directory scope, but these are here in a local scope and unset
303  # when AutoGen gets around to asking about the variables at generate time.
304 
305  # Fix for 3.13.0–3.13.3. Does not work if `paraview_client_add` is called
306  # from another function.
307  set("Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MAJOR" "${Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MAJOR}" PARENT_SCOPE)
308  set("Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MINOR" "${Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MINOR}" PARENT_SCOPE)
309  # Fix for 3.13.4+.
310  set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
311  PROPERTY
312  "Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MAJOR" "${Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MAJOR}")
313  set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
314  PROPERTY
315  "Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MINOR" "${Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MAJOR}")
316 
317  set(_paraview_client_built_shared 0)
318  if (BUILD_SHARED_LIBS)
319  set(_paraview_client_built_shared 1)
320  endif ()
321 
322  set(_paraview_client_have_plugins 0)
323  set(_paraview_client_plugins_includes)
324  set(_paraview_client_plugins_calls)
325  if (_paraview_client_PLUGINS_TARGETS)
326  set(_paraview_client_have_plugins 1)
327  foreach (_paraview_client_plugin_target IN LISTS _paraview_client_PLUGINS_TARGETS)
328  string(REPLACE "::" "_" _paraview_client_plugin_target_safe "${_paraview_client_plugin_target}")
329  string(APPEND _paraview_client_plugins_includes
330  "#include \"${_paraview_client_plugin_target_safe}.h\"\n")
331  string(APPEND _paraview_client_plugins_calls
332  " ${_paraview_client_plugin_target_safe}_initialize();\n")
333  endforeach ()
334  endif ()
335 
336  set(_paraview_client_source_files
337  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_client_NAME}_main.cxx"
338  "${CMAKE_CURRENT_BINARY_DIR}/pq${_paraview_client_NAME}Initializer.cxx"
339  "${CMAKE_CURRENT_BINARY_DIR}/pq${_paraview_client_NAME}Initializer.h")
340  configure_file(
341  "${_ParaViewClient_cmake_dir}/paraview_client_main.cxx.in"
342  "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_client_NAME}_main.cxx"
343  @ONLY)
344  configure_file(
345  "${_ParaViewClient_cmake_dir}/paraview_client_initializer.cxx.in"
346  "${CMAKE_CURRENT_BINARY_DIR}/pq${_paraview_client_NAME}Initializer.cxx"
347  @ONLY)
348  configure_file(
349  "${_ParaViewClient_cmake_dir}/paraview_client_initializer.h.in"
350  "${CMAKE_CURRENT_BINARY_DIR}/pq${_paraview_client_NAME}Initializer.h"
351  @ONLY)
352 
353  # Set up rpaths
354  set(CMAKE_BUILD_RPATH_USE_ORIGIN 1)
355  if (UNIX AND NOT APPLE)
356  file(RELATIVE_PATH _paraview_client_relpath
357  "/prefix/${_paraview_client_RUNTIME_DESTINATION}"
358  "/prefix/${_paraview_client_LIBRARY_DESTINATION}")
359  set(_paraview_client_origin_rpath
360  "$ORIGIN/${_paraview_client_relpath}")
361 
362  list(APPEND CMAKE_INSTALL_RPATH
363  "${_paraview_client_origin_rpath}")
364  endif ()
365 
366  if (_paraview_client_resource_files)
367  source_group("resources"
368  FILES
369  ${_paraview_client_resource_files})
370  endif ()
371 
372  ## Translation Management
373  if (NOT DEFINED _paraview_client_TRANSLATIONS_DIRECTORY)
374  set(_paraview_client_TRANSLATIONS_DIRECTORY
375  "${CMAKE_CURRENT_BINARY_DIR}/Translations")
376  endif ()
377  if (NOT DEFINED _paraview_client_TRANSLATE_XML)
378  set(_paraview_client_TRANSLATE_XML "OFF")
379  endif ()
380  if (_paraview_client_TRANSLATE_XML)
381  if (NOT DEFINED _paraview_client_TRANSLATION_TARGET)
382  message(FATAL_ERROR "The `TRANSLATION_TARGET` argument is required.")
383  endif ()
384  endif ()
385  if (DEFINED _paraview_client_TRANSLATION_TARGET)
386  find_package("Qt${PARAVIEW_QT_MAJOR_VERSION}" QUIET COMPONENTS LinguistTools REQUIRED)
387  if (_paraview_client_TRANSLATE_XML)
388  set(xml_header "${CMAKE_CURRENT_BINARY_DIR}/translationSources${_paraview_client_NAME}ClientXMLs.h")
390  TARGET "${_paraview_client_TRANSLATION_TARGET}Header"
391  INPUT_FILES ${_paraview_client_APPLICATION_XMLS}
392  RESULT_FILE "${xml_header}")
394  TARGET "${_paraview_client_TRANSLATION_TARGET}XMLs"
395  FILES "${xml_header}"
396  OUTPUT_TS "${_paraview_client_TRANSLATIONS_DIRECTORY}/Clients_${_paraview_client_APPLICATION_NAME}-XMLs.ts")
397  add_dependencies("${_paraview_client_TRANSLATION_TARGET}XMLs" "${_paraview_client_TRANSLATION_TARGET}Header")
398  endif ()
400  TARGET "${_paraview_client_TRANSLATION_TARGET}"
401  FILES ${_paraview_client_SOURCES}
402  OUTPUT_TS "${_paraview_client_TRANSLATIONS_DIRECTORY}/Clients_${_paraview_client_APPLICATION_NAME}.ts")
403  if (_paraview_client_TRANSLATE_XML)
404  add_dependencies("${_paraview_client_TRANSLATION_TARGET}" "${_paraview_client_TRANSLATION_TARGET}XMLs")
405  endif()
406  endif ()
407 
408  add_executable("${_paraview_client_NAME}" ${_paraview_client_executable_flags})
409  target_sources("${_paraview_client_NAME}"
410  PRIVATE
411  ${_paraview_client_SOURCES}
412  ${_paraview_client_resource_files}
413  ${_paraview_client_source_files}
414  ${_paraview_client_extra_sources})
415  if (DEFINED _paraview_client_NAMESPACE)
416  add_executable("${_paraview_client_NAMESPACE}::${_paraview_client_NAME}" ALIAS "${_paraview_client_NAME}")
417  endif ()
418  target_include_directories("${_paraview_client_NAME}"
419  PRIVATE
420  "${CMAKE_CURRENT_SOURCE_DIR}"
421  "${CMAKE_CURRENT_BINARY_DIR}"
422  # https://gitlab.kitware.com/cmake/cmake/-/issues/18049
423  "$<TARGET_PROPERTY:VTK::vtksys,INTERFACE_INCLUDE_DIRECTORIES>")
424  target_link_libraries("${_paraview_client_NAME}"
425  PRIVATE
426  ParaView::pqApplicationComponents
427  "Qt${PARAVIEW_QT_MAJOR_VERSION}::Widgets"
428  VTK::vtksys)
430  find_package("Qt${PARAVIEW_QT_MAJOR_VERSION}" REQUIRED QUIET COMPONENTS WebEngineWidgets)
431  target_link_libraries("${_paraview_client_NAME}"
432  PRIVATE "Qt${PARAVIEW_QT_MAJOR_VERSION}::WebEngineWidgets")
433  endif ()
434 
435  set(_paraview_client_export)
436  if (DEFINED _paraview_client_EXPORT)
437  list(APPEND _paraview_client_export
438  EXPORT "${_paraview_client_EXPORT}")
439  endif ()
440 
441  install(
442  TARGETS "${_paraview_client_NAME}"
443  ${_paraview_client_export}
444  COMPONENT "runtime"
445  ${_paraview_client_bundle_args}
446  RUNTIME DESTINATION "${_paraview_client_RUNTIME_DESTINATION}")
447 
448  if (DEFINED _paraview_client_PLUGINS_TARGETS)
449  target_link_libraries("${_paraview_client_NAME}"
450  PRIVATE
451  ${_paraview_client_PLUGINS_TARGETS})
452 
453  set(_paraview_client_binary_destination
454  "${_paraview_client_RUNTIME_DESTINATION}")
455  set(_paraview_client_conf_destination
456  "${_paraview_client_binary_destination}")
457  if (APPLE)
458  string(APPEND _paraview_client_binary_destination
459  "/${_paraview_client_NAME}.app/Contents/Resources")
460  set(_paraview_client_conf_destination
461  "${_paraview_client_BUNDLE_DESTINATION}/${_paraview_client_NAME}.app/Contents/Resources")
462  endif ()
463 
465  NAME "${_paraview_client_NAME}"
466  PLUGINS_TARGETS ${_paraview_client_PLUGINS_TARGETS}
467  BUILD_DESTINATION "${_paraview_client_binary_destination}"
468  INSTALL_DESTINATION "${_paraview_client_conf_destination}"
469  COMPONENT "runtime")
470  endif ()
471 
472  if (APPLE)
473  if (DEFINED _paraview_client_BUNDLE_ICON)
474  get_filename_component(_paraview_client_bundle_icon_file "${_paraview_client_BUNDLE_ICON}" NAME)
475  set_property(TARGET "${_paraview_client_NAME}"
476  PROPERTY
477  MACOSX_BUNDLE_ICON_FILE "${_paraview_client_bundle_icon_file}")
478  install(
479  FILES "${_paraview_client_BUNDLE_ICON}"
480  DESTINATION "${_paraview_client_BUNDLE_DESTINATION}/${_paraview_client_APPLICATION_NAME}.app/Contents/Resources"
481  COMPONENT "runtime")
482  endif ()
483  if (DEFINED _paraview_client_BUNDLE_PLIST)
484  set_property(TARGET "${_paraview_client_NAME}"
485  PROPERTY
486  MACOSX_BUNDLE_INFO_PLIST "${_paraview_client_BUNDLE_PLIST}")
487  endif ()
488  string(TOLOWER "${_paraview_client_ORGANIZATION}" _paraview_client_organization)
489  set_target_properties("${_paraview_client_NAME}"
490  PROPERTIES
491  MACOSX_BUNDLE_BUNDLE_NAME "${_paraview_client_APPLICATION_NAME}"
492  MACOSX_BUNDLE_GUI_IDENTIFIER "org.${_paraview_client_organization}.${_paraview_client_APPLICATION_NAME}"
493  MACOSX_BUNDLE_SHORT_VERSION_STRING "${_paraview_client_VERSION}")
494  endif ()
495 endfunction ()
496 
497 #[==[.md INTERNAL
498 ## Quoting
499 
500 Passing CMake lists down to the help generation and proxy documentation steps
501 requires escaping the `;` in them. These functions escape and unescape the
502 variable passed in. The new value is placed in the same variable in the calling
503 scope.
504 #]==]
505 
507  string(REPLACE "_" "_u" _escape_tmp "${${variable}}")
508  string(REPLACE ";" "_s" _escape_tmp "${_escape_tmp}")
509  set("${variable}"
510  "${_escape_tmp}"
511  PARENT_SCOPE)
512 endfunction ()
513 
515  string(REPLACE "_s" ";" _escape_tmp "${${variable}}")
516  string(REPLACE "_u" "_" _escape_tmp "${_escape_tmp}")
517  set("${variable}"
518  "${_escape_tmp}"
519  PARENT_SCOPE)
520 endfunction ()
521 
522 #[==[.md
523 ## Documentation from XML files
524 
525 Documentation can be generated from server manager XML files. The
526 `paraview_client_documentation` generates Qt help, HTML, and Wiki documentation
527 from them.
528 
529 ```
531  TARGET <target>
532  XMLS <xml>...
533  [OUTPUT_DIR <directory>])
534 ```
535 
536  * `TARGET`: (Required) The name of the target to generate.
537  * `XMLS`: (Required) The list of XML files to process.
538  * `OUTPUT_DIR`: (Defaults to `${CMAKE_CURRENT_BINARY_DIR}`) Where to place
539  generated documentation.
540 #]==]
542  cmake_parse_arguments(_paraview_client_doc
543  ""
544  "TARGET;OUTPUT_DIR"
545  "XMLS"
546  ${ARGN})
547 
548  if (_paraview_client_doc_UNPARSED_ARGUMENTS)
549  message(FATAL_ERROR
550  "Unparsed arguments for paraview_client_documentation: "
551  "${_paraview_client_doc_UNPARSED_ARGUMENTS}")
552  endif ()
553 
554  if (NOT DEFINED _paraview_client_doc_OUTPUT_DIR)
555  set(_paraview_client_doc_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
556  endif ()
557 
558  if (NOT DEFINED _paraview_client_doc_TARGET)
559  message(FATAL_ERROR
560  "The `TARGET` argument is required.")
561  endif ()
562 
563  if (NOT DEFINED _paraview_client_doc_XMLS)
564  message(FATAL_ERROR
565  "The `XMLS` argument is required.")
566  endif ()
567 
568  include("${_ParaViewClient_cmake_dir}/paraview-find-package-helpers.cmake" OPTIONAL)
569  find_program(qt_xmlpatterns_executable
570  NAMES xmlpatterns-qt5 xmlpatterns
571  HINTS "${Qt5_DIR}/../../../bin"
572  "${Qt5_DIR}/../../../libexec/qt5/bin"
573  DOC "Path to xmlpatterns")
574  mark_as_advanced(qt_xmlpatterns_executable)
575 
576  if (NOT qt_xmlpatterns_executable)
577  message(FATAL_ERROR
578  "Cannot find the xmlpatterns executable.")
579  endif ()
580 
581  set(_paraview_client_doc_xmls)
582  foreach (_paraview_client_doc_xml IN LISTS _paraview_client_doc_XMLS)
583  get_filename_component(_paraview_client_doc_xml "${_paraview_client_doc_xml}" ABSOLUTE)
584  list(APPEND _paraview_client_doc_xmls
585  "${_paraview_client_doc_xml}")
586  endforeach ()
587 
588  # Save xmls to a temporary file.
589  set (_paraview_client_doc_xmls_file
590  "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_paraview_client_doc_TARGET}-xmls.txt")
591  file(GENERATE
592  OUTPUT "${_paraview_client_doc_xmls_file}"
593  CONTENT "${_paraview_client_doc_xmls}")
594 
595  add_custom_command(
596  OUTPUT "${_paraview_client_doc_OUTPUT_DIR}/${_paraview_client_doc_TARGET}.xslt"
597  ${_paraview_client_doc_outputs}
598  COMMAND "${CMAKE_COMMAND}"
599  "-Dxmlpatterns=${qt_xmlpatterns_executable}"
600  "-Doutput_dir=${_paraview_client_doc_OUTPUT_DIR}"
601  "-Doutput_file=${_paraview_client_doc_OUTPUT_DIR}/${_paraview_client_doc_TARGET}.xslt"
602  "-Dxmls_file=${_paraview_client_doc_xmls_file}"
603  -D_paraview_generate_proxy_documentation_run=ON
604  -P "${_ParaViewClient_script_file}"
605  DEPENDS ${_paraview_client_doc_xmls}
606  "${_paraview_client_doc_xmls_file}"
607  "${_ParaViewClient_script_file}"
608  "${_ParaViewClient_cmake_dir}/paraview_servermanager_convert_xml.xsl"
609  "${_ParaViewClient_cmake_dir}/paraview_servermanager_convert_categoryindex.xsl"
610  "${_ParaViewClient_cmake_dir}/paraview_servermanager_convert_html.xsl"
611  "${_ParaViewClient_cmake_dir}/paraview_servermanager_convert_wiki.xsl.in"
612  WORKING_DIRECTORY "${_paraview_client_doc_OUTPUT_DIR}"
613  COMMENT "Generating documentation for ${_paraview_client_doc_TARGET}")
614  add_custom_target("${_paraview_client_doc_TARGET}"
615  DEPENDS
616  "${_paraview_client_doc_OUTPUT_DIR}/${_paraview_client_doc_TARGET}.xslt"
617  ${_paraview_client_doc_outputs})
618 endfunction ()
619 
620 # Generate proxy documentation.
621 if (_paraview_generate_proxy_documentation_run AND CMAKE_SCRIPT_MODE_FILE)
622 
623  file(READ "${xmls_file}" xmls)
624 
625  set(_paraview_gpd_to_xml "${CMAKE_CURRENT_LIST_DIR}/paraview_servermanager_convert_xml.xsl")
626  set(_paraview_gpd_to_catindex "${CMAKE_CURRENT_LIST_DIR}/paraview_servermanager_convert_categoryindex.xsl")
627  set(_paraview_gpd_to_html "${CMAKE_CURRENT_LIST_DIR}/paraview_servermanager_convert_html.xsl")
628  set(_paraview_gpd_to_wiki "${CMAKE_CURRENT_LIST_DIR}/paraview_servermanager_convert_wiki.xsl.in")
629 
630  set(_paraview_gpd_xslt "<xml>\n")
631  file(MAKE_DIRECTORY "${output_dir}")
632  foreach (_paraview_gpd_xml IN LISTS xmls)
633  execute_process(
634  COMMAND "${xmlpatterns}"
635  "${_paraview_gpd_to_xml}"
636  "${_paraview_gpd_xml}"
637  OUTPUT_VARIABLE _paraview_gpd_output
638  ERROR_VARIABLE _paraview_gpd_error
639  RESULT_VARIABLE _paraview_gpd_result)
640  if (_paraview_gpd_result)
641  message(FATAL_ERROR
642  "Failed to convert servermanager XML: ${_paraview_gpd_error}")
643  endif ()
644 
645  string(APPEND _paraview_gpd_xslt
646  "${_paraview_gpd_output}")
647  endforeach ()
648  string(APPEND _paraview_gpd_xslt
649  "</xml>\n")
650 
651  file(WRITE "${output_file}.xslt"
652  "${_paraview_gpd_xslt}")
653  execute_process(
654  COMMAND "${xmlpatterns}"
655  -output "${output_file}"
656  "${_paraview_gpd_to_catindex}"
657  "${output_file}.xslt"
658  RESULT_VARIABLE _paraview_gpd_result)
659  if (_paraview_gpd_result)
660  message(FATAL_ERROR
661  "Failed to generate category index")
662  endif ()
663 
664  # Generate HTML files.
665  execute_process(
666  COMMAND "${xmlpatterns}"
667  "${_paraview_gpd_to_html}"
668  "${output_file}"
669  OUTPUT_VARIABLE _paraview_gpd_output
670  RESULT_VARIABLE _paraview_gpd_result
671  OUTPUT_STRIP_TRAILING_WHITESPACE)
672  if (_paraview_gpd_result)
673  message(FATAL_ERROR
674  "Failed to generate HTML output")
675  endif ()
676 
677  # Escape open/close brackets as HTML entities as they somehow interfere with the foreach loop below.
678  string(REPLACE "[" "&#91;" _paraview_gpd_output "${_paraview_gpd_output}")
679  string(REPLACE "]" "&#93;" _paraview_gpd_output "${_paraview_gpd_output}")
680 
681  # Escape semicolons.
682  _paraview_client_escape_cmake_list(_paraview_gpd_output)
683 
684  # Convert into a list of HTML documents.
685  string(REPLACE "</html>\n<html>" "</html>\n;<html>" _paraview_gpd_output "${_paraview_gpd_output}")
686 
687  foreach (_paraview_gpd_html_doc IN LISTS _paraview_gpd_output)
688  _paraview_client_unescape_cmake_list(_paraview_gpd_html_doc)
689  string(REGEX MATCH "<meta name=\"filename\" contents=\"([^\"]*)\"" _ "${_paraview_gpd_html_doc}")
690  set(_paraview_gpd_filename "${CMAKE_MATCH_1}")
691  if (NOT _paraview_gpd_filename)
692  message(FATAL_ERROR
693  "No filename for an HTML output?")
694  endif ()
695 
696  # Replace reStructured Text markup.
697  string(REGEX REPLACE "\\*\\*([^*]+)\\*\\*" "<b>\\1</b>" _paraview_gpd_html_doc "${_paraview_gpd_html_doc}")
698  string(REGEX REPLACE "\\*([^*]+)\\*" "<em>\\1</em>" _paraview_gpd_html_doc "${_paraview_gpd_html_doc}")
699  string(REGEX REPLACE "\n\n- " "\n<ul><li>" _paraview_gpd_html_doc "${_paraview_gpd_html_doc}")
700  string(REGEX REPLACE "\n-" "\n<li>" _paraview_gpd_html_doc "${_paraview_gpd_html_doc}")
701  string(REGEX REPLACE "<li>(.*)\n\n([^-])" "<li>\\1</ul>\n\\2" _paraview_gpd_html_doc "${_paraview_gpd_html_doc}")
702  string(REGEX REPLACE "\n\n" "\n<p>\n" _paraview_gpd_html_doc "${_paraview_gpd_html_doc}")
703  file(WRITE "${output_dir}/${_paraview_gpd_filename}"
704  "${_paraview_gpd_html_doc}\n")
705  endforeach ()
706 
707  # Generate Wiki files.
708  string(REGEX MATCHALL "proxy_group=\"[^\"]*\"" _paraview_gpd_groups "${_paraview_gpd_xslt}")
709  string(REGEX REPLACE "proxy_group=\"([^\"]*)\"" "\\1" _paraview_gpd_groups "${_paraview_gpd_groups}")
710  list(APPEND _paraview_gpd_groups readers)
711  if (_paraview_gpd_groups)
712  list(REMOVE_DUPLICATES _paraview_gpd_groups)
713  endif ()
714 
715  foreach (_paraview_gpd_group IN LISTS _paraview_gpd_groups)
716  if (_paraview_gpd_group STREQUAL "readers")
717  set(_paraview_gpd_query "contains(lower-case($proxy_name),'reader')")
718  set(_paraview_gpd_group_real "sources")
719  else ()
720  set(_paraview_gpd_query "not(contains(lower-case($proxy_name),'reader'))")
721  set(_paraview_gpd_group_real "${_paraview_gpd_group}")
722  endif ()
723 
724  set(_paraview_gpd_wiki_xsl
725  "${output_dir}/${_paraview_gpd_group}.xsl")
726  configure_file(
727  "${_paraview_gpd_to_wiki}"
728  "${_paraview_gpd_wiki_xsl}"
729  @ONLY)
730  execute_process(
731  COMMAND "${xmlpatterns}"
732  "${_paraview_gpd_wiki_xsl}"
733  "${output_file}"
734  OUTPUT_VARIABLE _paraview_gpd_output
735  RESULT_VARIABLE _paraview_gpd_result)
736  if (_paraview_gpd_result)
737  message(FATAL_ERROR
738  "Failed to generate Wiki output for ${_paraview_gpd_group}")
739  endif ()
740  string(REGEX REPLACE " +" " " _paraview_gpd_output "${_paraview_gpd_output}")
741  string(REPLACE "\n " "\n" _paraview_gpd_output "${_paraview_gpd_output}")
742  file(WRITE "${output_dir}/${_paraview_gpd_group}.wiki"
743  "${_paraview_gpd_output}")
744  endforeach ()
745 endif ()
746 
747 #[==[.md
748 ## Generating help documentation
749 
750 TODO: Document
751 
752 ```
754  NAME <name>
755  [TARGET <target>]
756 
757  OUTPUT_PATH <var>
758 
759  [OUTPUT_DIR <directory>]
760  [SOURCE_DIR <directory>]
761  [PATTERNS <pattern>...]
762  [DEPENDS <depend>...]
763 
764  [NAMESPACE <namespace>]
765  [FOLDER <folder>]
766 
767  [TABLE_OF_CONTENTS <toc>]
768  [TABLE_OF_CONTENTS_FILE <tocfile>]
769 
770  [RESOURCE_FILE <qrcfile>]
771  [RESOURCE_PREFIX <prefix>]
772 ```
773 
774  * `NAME`: (Required) The basename of the generated `.qch` file.
775  * `TARGET`: (Defaults to `<NAME>`) The name of the generated target.
776  * `OUTPUT_PATH`: (Required) This variable is set to the output path of the
777  generated `.qch` file.
778  * `OUTPUT_DIR`: (Defaults to `${CMAKE_CURRENT_BINARY_DIR}`) Where to place
779  generated files.
780  * `SOURCE_DIR`: Where to copy input files from.
781  * `PATTERNS`: (Defaults to `*.*`) If `SOURCE_DIR` is specified, files
782  matching these globs will be copied to `OUTPUT_DIR`.
783  * `DEPENDS`: A list of dependencies which are required before the help can be
784  generated. Note that file paths which are generated via
785  `add_custom_command` must be in the same directory as the
786  `paraview_client_generate_help` on non-Ninja generators.
787  * `NAMESPACE`: (Defaults to `<NAME>.org`) The namespace for the generated
788  help.
789  * `FOLDER`: (Defaults to `<NAME>`) The folder for the generated help.
790  * `TABLE_OF_CONTENTS` and `TABLE_OF_CONTENTS_FILE`: At most one may be
791  provided. This is used as the `<toc>` element in the generated help. If not
792  provided at all, a table of contents will be generated.
793  * `RESOURCE_FILE`: If provided, a Qt resource file providing the contents of
794  the generated help will be generated at this path. It will be available as
795  `<RESOURCE_PREFIX>/<NAME>`.
796  * `RESOURCE_PREFIX`: The prefix to use for the generated help's Qt resource.
797 #]==]
798 function (paraview_client_generate_help)
799  cmake_parse_arguments(_paraview_client_help
800  ""
801  "NAME;TARGET;OUTPUT_DIR;SOURCE_DIR;NAMESPACE;FOLDER;TABLE_OF_CONTENTS;TABLE_OF_CONTENTS_FILE;RESOURCE_FILE;RESOURCE_PREFIX;OUTPUT_PATH"
802  "PATTERNS;DEPENDS"
803  ${ARGN})
804 
805  if (_paraview_client_help_UNPARSED_ARGUMENTS)
806  message(FATAL_ERROR
807  "Unparsed arguments for paraview_client_generate_help: "
808  "${_paraview_client_help_UNPARSED_ARGUMENTS}")
809  endif ()
810 
811  if (NOT DEFINED _paraview_client_help_NAME)
812  message(FATAL_ERROR
813  "The `NAME` argument is required.")
814  endif ()
815 
816  if (NOT DEFINED _paraview_client_help_OUTPUT_PATH)
817  message(FATAL_ERROR
818  "The `OUTPUT_PATH` argument is required.")
819  endif ()
820 
821  if (NOT DEFINED _paraview_client_help_TARGET)
822  set(_paraview_client_help_TARGET
823  "${_paraview_client_help_NAME}")
824  endif ()
825 
826  if (NOT DEFINED _paraview_client_help_OUTPUT_DIR)
827  set(_paraview_client_help_OUTPUT_DIR
828  "${CMAKE_CURRENT_BINARY_DIR}/paraview_help")
829  endif ()
830 
831  if (NOT DEFINED _paraview_client_help_NAMESPACE)
832  set(_paraview_client_help_NAMESPACE
833  "${_paraview_client_help_NAME}.org")
834  endif ()
835 
836  if (NOT DEFINED _paraview_client_help_FOLDER)
837  set(_paraview_client_help_FOLDER
838  "${_paraview_client_help_NAME}")
839  endif ()
840 
841  if (DEFINED _paraview_client_help_TABLE_OF_CONTENTS_FILE)
842  file(READ "${_paraview_client_help_TABLE_OF_CONTENTS_FILE}"
843  _paraview_client_help_toc)
844  elseif (DEFINED _paraview_client_help_TABLE_OF_CONTENTS)
845  set(_paraview_client_help_toc
846  "${_paraview_client_help_TABLE_OF_CONTENTS}")
847  else ()
848  set(_paraview_client_help_toc)
849  endif ()
850  string(REPLACE "\n" " " _paraview_client_help_toc "${_paraview_client_help_toc}")
851 
852  if (NOT DEFINED _paraview_client_help_PATTERNS)
853  set(_paraview_client_help_PATTERNS
854  "*.*")
855  endif ()
856 
857  include("${_ParaViewClient_cmake_dir}/paraview-find-package-helpers.cmake" OPTIONAL)
858  set(_paraview_client_help_components
859  Help)
860  if (PARAVIEW_QT_MAJOR_VERSION GREATER "5")
861  list(APPEND _paraview_client_help_components
862  Tools)
863  endif ()
864  find_package("Qt${PARAVIEW_QT_MAJOR_VERSION}" QUIET REQUIRED COMPONENTS ${_paraview_client_help_components})
865 
866  set(_paraview_client_help_copy_sources)
867  set(_paraview_client_help_copied_sources)
868  if (DEFINED _paraview_client_help_SOURCE_DIR)
869  list(APPEND _paraview_client_help_copy_sources
870  COMMAND "${CMAKE_COMMAND}" -E copy_directory
871  "${_paraview_client_help_SOURCE_DIR}"
872  "${_paraview_client_help_OUTPUT_DIR}")
873 
874  file(GLOB _paraview_client_help_copied_sources
875  ${_paraview_client_help_PATTERNS})
876  endif ()
877 
878  file(MAKE_DIRECTORY "${_paraview_client_help_OUTPUT_DIR}")
879 
880  set(_paraview_client_help_patterns "${_paraview_client_help_PATTERNS}")
881  _paraview_client_escape_cmake_list(_paraview_client_help_patterns)
882 
883  set(_paraview_client_help_qhp
884  "${_paraview_client_help_OUTPUT_DIR}/${_paraview_client_help_NAME}.qhp")
885  set(_paraview_client_help_output
886  "${_paraview_client_help_OUTPUT_DIR}/${_paraview_client_help_NAME}.qch")
887  add_custom_command(
888  OUTPUT "${_paraview_client_help_output}"
889  DEPENDS "${_ParaViewClient_script_file}"
890  ${_paraview_client_help_copied_sources}
891  ${_paraview_client_help_DEPENDS}
892  ${_paraview_client_help_copy_sources}
893  COMMAND "${CMAKE_COMMAND}"
894  "-Doutput_dir=${_paraview_client_help_OUTPUT_DIR}"
895  "-Doutput_file=${_paraview_client_help_qhp}"
896  "-Dnamespace=${_paraview_client_help_NAMESPACE}"
897  "-Dfolder=${_paraview_client_help_FOLDER}"
898  "-Dname=${_paraview_client_help_NAME}"
899  "-Dtoc=${_paraview_client_help_toc}"
900  "-Dpatterns=${_paraview_client_help_patterns}"
901  -D_paraview_generate_help_run=ON
902  -P "${_ParaViewClient_script_file}"
903  VERBATIM
904  COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR}
905  "$<TARGET_FILE:Qt${PARAVIEW_QT_MAJOR_VERSION}::qhelpgenerator>"
906  "${_paraview_client_help_qhp}"
907  -s
908  -o "${_paraview_client_help_output}"
909  COMMENT "Compiling Qt help for ${_paraview_client_help_NAME}"
910  WORKING_DIRECTORY "${_paraview_client_help_OUTPUT_DIR}")
911  add_custom_target("${_paraview_client_help_TARGET}"
912  DEPENDS
913  "${_paraview_client_help_output}")
914 
915  if (DEFINED _paraview_client_help_RESOURCE_FILE)
916  if (NOT DEFINED _paraview_client_help_RESOURCE_PREFIX)
917  message(FATAL_ERROR
918  "The `RESOURCE_PREFIX` argument is required if `RESOURCE_FILE` is given.")
919  endif ()
920 
921  paraview_client_qt_resource(
922  OUTPUT "${_paraview_client_help_RESOURCE_FILE}"
923  PREFIX "${_paraview_client_help_RESOURCE_PREFIX}"
924  FILE "${_paraview_client_help_output}")
925  set_property(SOURCE "${_paraview_client_help_RESOURCE_FILE}"
926  PROPERTY
927  OBJECT_DEPENDS "${_paraview_client_help_output}")
928  endif ()
929 
930  set("${_paraview_client_help_OUTPUT_PATH}"
931  "${_paraview_client_help_output}"
932  PARENT_SCOPE)
933 endfunction ()
934 
935 # Handle the generation of the help file.
936 if (_paraview_generate_help_run AND CMAKE_SCRIPT_MODE_FILE)
937  _paraview_client_unescape_cmake_list(patterns)
938 
939  set(_paraview_help_patterns)
940  foreach (_paraview_help_pattern IN LISTS patterns)
941  if (IS_ABSOLUTE "${_paraview_help_pattern}")
942  list(APPEND _paraview_help_patterns
943  "${_paraview_help_pattern}")
944  else ()
945  list(APPEND _paraview_help_patterns
946  "${output_dir}/${_paraview_help_pattern}")
947  endif ()
948  endforeach ()
949 
950  file(GLOB _paraview_help_files
951  RELATIVE "${output_dir}"
952  ${_paraview_help_patterns})
953 
954  if (NOT toc)
955  if (NOT _paraview_help_files)
956  message(FATAL_ERROR
957  "No matching files given without a table of contents")
958  endif ()
959  set(_paraview_help_subsections "")
960  list(GET _paraview_help_files 0
961  _paraview_help_index)
962  set(_paraview_help_subsections "")
963  foreach (_paraview_help_file IN LISTS _paraview_help_files)
964  if (NOT _paraview_help_file MATCHES "\\.html$")
965  continue ()
966  endif ()
967  get_filename_component(_paraview_help_name "${_paraview_help_file}" NAME_WE)
968  set(_paraview_help_title "${_paraview_help_name}")
969  file(READ "${_paraview_help_file}" _paraview_help_contents)
970  string(REGEX MATCH "<title>([^<]*)</title>" _ "${_paraview_help_contents}")
971  if (CMAKE_MATCH_1)
972  set(_paraview_help_title "${CMAKE_MATCH_1}")
973  endif ()
974  string(APPEND _paraview_help_subsections
975  " <section title=\"${_paraview_help_title}\" ref=\"${_paraview_help_file}\" />\n")
976 
977  string(TOLOWER "${_paraview_help_name}" _paraview_help_name_lower)
978  if (_paraview_help_name_lower STREQUAL "index")
979  set(_paraview_help_index
980  "${_paraview_help_file}")
981  endif ()
982  endforeach ()
983  set(toc
984  "<toc>\n <section title=\"${name}\" ref=\"${_paraview_help_index}\">\n${_paraview_help_subsections} </section>\n</toc>")
985  endif ()
986 
987  set(_paraview_help_file_entries "")
988  foreach (_paraview_help_file IN LISTS _paraview_help_files)
989  string(APPEND _paraview_help_file_entries
990  " <file>${_paraview_help_file}</file>\n")
991  endforeach ()
992 
993  file(WRITE "${output_file}"
994  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
995 <QtHelpProject version=\"1.0\">
996  <namespace>${namespace}</namespace>
997  <virtualFolder>${folder}</virtualFolder>
998  <filterSection>
999  ${toc}
1000  <keywords>
1001  <!-- TODO: how to handle keywords? -->
1002  </keywords>
1003  <files>
1004 ${_paraview_help_file_entries}
1005  </files>
1006  </filterSection>
1007 </QtHelpProject>\n")
1008 endif ()
1009 
1010 #[==[.md
1011 ## Qt resources
1012 
1013 Compiling Qt resources into a client can be a little tedious. To help with
1014 this, some functions are provided to make it easier to embed content into the
1015 client.
1016 #]==]
1017 
1018 #[==[.md
1019 ### Single file
1020 
1021 ```
1022 paraview_client_qt_resource(
1023  OUTPUT <file>
1024  PREFIX <prefix>
1025  FILE <file>
1026  [ALIAS <alias>])
1027 ```
1028 
1029 Outputs a Qt resource to the file given to the `OUTPUT` argument. Its resource
1030 name is `<PREFIX>/<ALIAS>`. The contents are copied from the contents of the
1031 file specified by the `FILE` argument. If not given the name of the file is
1032 used as the `ALIAS`.
1033 #]==]
1034 function (paraview_client_qt_resource)
1035  cmake_parse_arguments(_paraview_client_resource
1036  ""
1037  "OUTPUT;PREFIX;ALIAS;FILE"
1038  ""
1039  ${ARGN})
1040 
1041  if (_paraview_client_resource_UNPARSED_ARGUMENTS)
1042  message(FATAL_ERROR
1043  "Unparsed arguments for paraview_client_qt_resource: "
1044  "${_paraview_client_resource_UNPARSED_ARGUMENTS}")
1045  endif ()
1046 
1047  if (NOT DEFINED _paraview_client_resource_OUTPUT)
1048  message(FATAL_ERROR
1049  "The `OUTPUT` argument is required.")
1050  endif ()
1051 
1052  if (NOT DEFINED _paraview_client_resource_PREFIX)
1053  message(FATAL_ERROR
1054  "The `PREFIX` argument is required.")
1055  endif ()
1056 
1057  if (NOT DEFINED _paraview_client_resource_FILE)
1058  message(FATAL_ERROR
1059  "The `FILE` argument is required.")
1060  endif ()
1061 
1062  if (NOT DEFINED _paraview_client_resource_ALIAS)
1063  get_filename_component(_paraview_client_resource_ALIAS
1064  "${_paraview_client_resource_FILE}"
1065  NAME)
1066  endif ()
1067 
1068  get_filename_component(_paraview_client_resource_file_path
1069  "${_paraview_client_resource_FILE}"
1070  ABSOLUTE)
1071  get_filename_component(_paraview_client_resource_file_path
1072  "${_paraview_client_resource_file_path}"
1073  REALPATH)
1074  if (WIN32)
1075  file(TO_NATIVE_PATH
1076  "${_paraview_client_resource_file_path}"
1077  _paraview_client_resource_file_path)
1078  endif ()
1079 
1080  # We cannot use file(GENERATE) because automoc doesn't like when generated
1081  # sources are in the source list.
1082  file(WRITE "${_paraview_client_resource_OUTPUT}.tmp"
1083  "<RCC>
1084  <qresource prefix=\"/${_paraview_client_resource_PREFIX}\">
1085  <file alias=\"${_paraview_client_resource_ALIAS}\">${_paraview_client_resource_file_path}</file>
1086  </qresource>
1087 </RCC>\n")
1088  configure_file(
1089  "${_paraview_client_resource_OUTPUT}.tmp"
1090  "${_paraview_client_resource_OUTPUT}"
1091  COPYONLY)
1092 endfunction ()
1093 
1094 #[==[.md
1095 ### Many files
1096 
1097 ```
1099  OUTPUT <file>
1100  PREFIX <prefix>
1101  FILES <file>...)
1102 ```
1103 
1104 Outputs a Qt resource to the file given to the `OUTPUT` argument. Its resource
1105 name is `<PREFIX>/<filename>` for each of the files in the given list. If
1106 aliases other than the filenames are required, the
1107 `paraview_client_qt_resource` function should be used instead.
1108 #]==]
1110  cmake_parse_arguments(_paraview_client_resources
1111  ""
1112  "OUTPUT;PREFIX"
1113  "FILES"
1114  ${ARGN})
1115 
1116  if (_paraview_client_resources_UNPARSED_ARGUMENTS)
1117  message(FATAL_ERROR
1118  "Unparsed arguments for paraview_client_qt_resources: "
1119  "${_paraview_client_resources_UNPARSED_ARGUMENTS}")
1120  endif ()
1121 
1122  if (NOT DEFINED _paraview_client_resources_OUTPUT)
1123  message(FATAL_ERROR
1124  "The `OUTPUT` argument is required.")
1125  endif ()
1126 
1127  if (NOT DEFINED _paraview_client_resources_PREFIX)
1128  message(FATAL_ERROR
1129  "The `PREFIX` argument is required.")
1130  endif ()
1131 
1132  if (NOT DEFINED _paraview_client_resources_FILES)
1133  message(FATAL_ERROR
1134  "The `FILES` argument is required.")
1135  endif ()
1136 
1137  set(_paraview_client_resources_contents)
1138 
1139  string(APPEND _paraview_client_resources_contents
1140  "<RCC>\n <qresource prefix=\"${_paraview_client_resources_PREFIX}\">\n")
1141  foreach (_paraview_client_resources_file IN LISTS _paraview_client_resources_FILES)
1142  get_filename_component(_paraview_client_resources_alias
1143  "${_paraview_client_resources_file}"
1144  NAME)
1145  get_filename_component(_paraview_client_resources_file_path
1146  "${_paraview_client_resources_file}"
1147  ABSOLUTE)
1148  get_filename_component(_paraview_client_resources_file_path
1149  "${_paraview_client_resources_file_path}"
1150  REALPATH)
1151  if (WIN32)
1152  file(TO_NATIVE_PATH
1153  "${_paraview_client_resources_file_path}"
1154  _paraview_client_resources_file_path)
1155  endif ()
1156  string(APPEND _paraview_client_resources_contents
1157  " <file alias=\"${_paraview_client_resources_alias}\">${_paraview_client_resources_file_path}</file>\n")
1158  endforeach ()
1159  string(APPEND _paraview_client_resources_contents
1160  " </qresource>\n</RCC>\n")
1161 
1162  # We cannot use file(GENERATE) because automoc doesn't like when generated
1163  # sources are in the source list.
1164  file(WRITE "${_paraview_client_resources_OUTPUT}.tmp"
1165  "${_paraview_client_resources_contents}")
1166  configure_file(
1167  "${_paraview_client_resources_OUTPUT}.tmp"
1168  "${_paraview_client_resources_OUTPUT}"
1169  COPYONLY)
1170 endfunction ()
function paraview_create_translation()
Generate a Qt translation source file from the given source files.
style
function _paraview_client_unescape_cmake_list(variable)
boost::graph_traits< vtkGraph *>::vertex_descriptor target(boost::graph_traits< vtkGraph *>::edge_descriptor e, vtkGraph *)
function paraview_generate_translation_header()
Generate a C++ header with input XML labels and UI strings that can be parsed by Qt Linguist tools...
on
version
function paraview_client_documentation()
.md Documentation from XML files
EXPORT
function paraview_client_qt_resource()
.md Qt resources
function paraview_client_generate_help()
.md Generating help documentation
string
name
#define PARAVIEW_USE_QTWEBENGINE
function
function paraview_client_add()
.md Building a client
#define VERSION
Definition: jconfigint.h:17
#define BUILD_SHARED_LIBS
Definition: config.h:45
function paraview_plugin_write_conf()
.md Plugin configuration files
documentation
value
function paraview_client_qt_resources()
.md Many files
function _paraview_client_escape_cmake_list(variable)
.md INTERNAL Quoting