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