1 set(_ParaViewClient_cmake_dir
"${CMAKE_CURRENT_LIST_DIR}")
2 set(_ParaViewClient_script_file
"${CMAKE_CURRENT_LIST_FILE}")
14 [APPLICATION_XMLS <xml>...]
17 [MAIN_WINDOW_CLASS <class>]
18 [MAIN_WINDOW_INCLUDE <include>]
20 [PLUGINS_TARGETS <target>...]
21 [REQUIRED_PLUGINS <plugin>...]
22 [OPTIONAL_PLUGINS <plugin>...]
24 [APPLICATION_NAME <name>]
25 [ORGANIZATION <organization>]
28 [DEFAULT_STYLE <style>]
30 [APPLICATION_ICON <icon>]
32 [BUNDLE_PLIST <plist>]
33 [SPLASH_IMAGE <image>]
35 [NAMESPACE <namespace>]
37 [FORCE_UNIX_LAYOUT <ON|OFF>]
38 [BUNDLE_DESTINATION <directory>]
39 [RUNTIME_DESTINATION <directory>]
40 [LIBRARY_DESTINATION <directory>]
42 [TRANSLATE_XML <ON|OFF>]
43 [TRANSLATIONS_DIRECTORY <directory>]
44 [TRANSLATION_TARGET <target>])
47 * `
NAME`: (Required) The name of the application. This is used as the target
49 * `VERSION`: (Required) The
version of the application.
50 * `SOURCES`: (Required) Source files
for the application.
51 * `APPLICATION_XMLS`: Server manager XML files.
53 * `MAIN_WINDOW_CLASS`: (Defaults to `QMainWindow`) The
name of the main
55 * `MAIN_WINDOW_INCLUDE`: (Defaults to `QMainWindow` or
56 `<MAIN_WINDOW_CLASS>.h`
if it is specified) The include file
for the main
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
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
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.,
78 * `BUNDLE_DESTINATION`: (Defaults to `Applications`) Where to place the
80 * `RUNTIME_DESTINATION`: (Defaults to `${CMAKE_INSTALL_BINDIR}`) Where to
82 * `LIBRARY_DESTINATION`: (Defaults to `${CMAKE_INSTALL_LIBDIR}`) Where
83 libraries are placed. Sets up `RPATH` on ELF platforms (e.g., Linux and the
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
93 cmake_parse_arguments(_paraview_client
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"
99 if (_paraview_client_UNPARSED_ARGUMENTS)
101 "Unparsed arguments for paraview_client_add: "
102 "${_paraview_client_UNPARSED_ARGUMENTS}")
105 # TODO: Installation.
107 if (DEFINED _paraview_client_PLUGINS_TARGET)
108 if (DEFINED _paraview_client_PLUGINS_TARGETS)
110 "The `paraview_client_add(PLUGINS_TARGET)` argument is incompatible "
111 "with `PLUGINS_TARGETS`.")
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}")
121 if (NOT DEFINED _paraview_client_NAME)
123 "The `
NAME` argument is required.")
126 if (NOT DEFINED _paraview_client_VERSION)
128 "The `VERSION` argument is required.")
131 if (NOT DEFINED _paraview_client_SOURCES)
133 "The `SOURCES` argument is required.")
136 if (NOT DEFINED _paraview_client_APPLICATION_NAME)
137 set(_paraview_client_APPLICATION_NAME
138 "${_paraview_client_NAME}
")
141 if (NOT DEFINED _paraview_client_ORGANIZATION)
142 set(_paraview_client_ORGANIZATION
146 if (NOT DEFINED _paraview_client_FORCE_UNIX_LAYOUT)
147 set(_paraview_client_FORCE_UNIX_LAYOUT
151 if (NOT DEFINED _paraview_client_BUNDLE_DESTINATION)
152 set(_paraview_client_BUNDLE_DESTINATION
156 if (NOT DEFINED _paraview_client_RUNTIME_DESTINATION)
157 set(_paraview_client_RUNTIME_DESTINATION
158 "${CMAKE_INSTALL_BINDIR}
")
161 if (NOT DEFINED _paraview_client_LIBRARY_DESTINATION)
162 set(_paraview_client_LIBRARY_DESTINATION
163 "${CMAKE_INSTALL_LIBDIR}
")
166 if (DEFINED _paraview_client_QCH_FILE)
167 if (DEFINED _paraview_client_QCH_FILES)
174 "favor of `QCH_FILES`.
")
175 set(_paraview_client_QCH_FILES
176 "${_paraview_client_QCH_FILE}
")
180 if (NOT DEFINED _paraview_client_MAIN_WINDOW_CLASS)
181 if (DEFINED _paraview_client_MAIN_WINDOW_INCLUDE)
183 "The `MAIN_WINDOW_INCLUDE` argument cannot be specified without
"
184 "`MAIN_WINDOW_CLASS`.
")
187 set(_paraview_client_MAIN_WINDOW_CLASS
189 set(_paraview_client_MAIN_WINDOW_INCLUDE
193 if (NOT DEFINED _paraview_client_MAIN_WINDOW_INCLUDE)
194 set(_paraview_client_MAIN_WINDOW_INCLUDE
195 "${_paraview_client_MAIN_WINDOW_CLASS}.h
")
198 set(_paraview_client_extra_sources)
199 set(_paraview_client_bundle_args)
201 set(_paraview_client_executable_flags)
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
"
209 IDI_ICON1 ICON \
"${_paraview_client_APPLICATION_ICON}\"\n")
211 "${_paraview_client_appicon_file}.tmp"
212 "${_paraview_client_appicon_file}"
215 list(APPEND _paraview_client_extra_sources
216 "${_paraview_client_appicon_file}")
219 list(APPEND _paraview_client_executable_flags
224 list(APPEND _paraview_client_bundle_args
225 BUNDLE DESTINATION
"${_paraview_client_BUNDLE_DESTINATION}")
226 list(APPEND _paraview_client_executable_flags
230 set(_paraview_client_resource_files "")
231 set(_paraview_client_resource_init "")
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}
")
241 set(_paraview_client_splash_resource_file
242 "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_client_splash_base_name}.qrc
")
244 paraview_client_qt_resource(
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}
")
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
")
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
")
263 paraview_client_qt_resources(
264 OUTPUT "${_paraview_client_application_resource_file}
"
265 PREFIX "/${_paraview_client_NAME}/Configuration
"
266 FILES "${_paraview_client_APPLICATION_XMLS}
")
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
")
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
")
281 paraview_client_qt_resources(
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}
"
288 OBJECT_DEPENDS "${_paraview_client_QCH_FILES}
")
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
")
297 include("${_ParaViewClient_cmake_dir}/paraview-find-package-helpers.cmake
" OPTIONAL)
298 find_package("Qt${PARAVIEW_QT_MAJOR_VERSION}
" REQUIRED QUIET COMPONENTS Core Widgets)
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.
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)
310 set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}
"
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}
"
315 "Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MINOR
" "${Qt${PARAVIEW_QT_MAJOR_VERSION}Core_VERSION_MAJOR}
")
317 set(_paraview_client_built_shared 0)
318 if (BUILD_SHARED_LIBS)
319 set(_paraview_client_built_shared 1)
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")
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
")
341 "${_ParaViewClient_cmake_dir}/paraview_client_main.cxx.in
"
342 "${CMAKE_CURRENT_BINARY_DIR}/${_paraview_client_NAME}_main.cxx
"
345 "${_ParaViewClient_cmake_dir}/paraview_client_initializer.cxx.in
"
346 "${CMAKE_CURRENT_BINARY_DIR}/pq${_paraview_client_NAME}Initializer.cxx
"
349 "${_ParaViewClient_cmake_dir}/paraview_client_initializer.h.in
"
350 "${CMAKE_CURRENT_BINARY_DIR}/pq${_paraview_client_NAME}Initializer.h
"
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}
")
362 list(APPEND CMAKE_INSTALL_RPATH
363 "${_paraview_client_origin_rpath}
")
366 if (_paraview_client_resource_files)
367 source_group("resources
"
369 ${_paraview_client_resource_files})
372 ## Translation Management
373 if (NOT DEFINED _paraview_client_TRANSLATIONS_DIRECTORY)
374 set(_paraview_client_TRANSLATIONS_DIRECTORY
375 "${CMAKE_CURRENT_BINARY_DIR}/Translations
")
377 if (NOT DEFINED _paraview_client_TRANSLATE_XML)
378 set(_paraview_client_TRANSLATE_XML "OFF
")
380 if (_paraview_client_TRANSLATE_XML)
381 if (NOT DEFINED _paraview_client_TRANSLATION_TARGET)
382 message(FATAL_ERROR "The `TRANSLATION_TARGET` argument is required.
")
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
")
389 paraview_generate_translation_header(
390 TARGET "${_paraview_client_TRANSLATION_TARGET}Header
"
391 INPUT_FILES ${_paraview_client_APPLICATION_XMLS}
392 RESULT_FILE "${xml_header}
")
393 paraview_create_translation(
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
")
399 paraview_create_translation(
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
")
408 add_executable("${_paraview_client_NAME}
" ${_paraview_client_executable_flags}
409 ${_paraview_client_SOURCES}
410 ${_paraview_client_resource_files}
411 ${_paraview_client_source_files}
412 ${_paraview_client_extra_sources})
413 if (DEFINED _paraview_client_NAMESPACE)
414 add_executable("${_paraview_client_NAMESPACE}::${_paraview_client_NAME}
" ALIAS "${_paraview_client_NAME}
")
416 target_include_directories("${_paraview_client_NAME}
"
418 "${CMAKE_CURRENT_SOURCE_DIR}
"
419 "${CMAKE_CURRENT_BINARY_DIR}
"
420 # https://gitlab.kitware.com/cmake/cmake/-/issues/18049
421 "$<TARGET_PROPERTY:VTK::vtksys,INTERFACE_INCLUDE_DIRECTORIES>
")
422 target_link_libraries("${_paraview_client_NAME}
"
424 ParaView::pqApplicationComponents
425 "Qt${PARAVIEW_QT_MAJOR_VERSION}::Widgets
"
427 if (PARAVIEW_USE_QTWEBENGINE)
428 find_package("Qt${PARAVIEW_QT_MAJOR_VERSION}
" REQUIRED QUIET COMPONENTS WebEngineWidgets)
429 target_link_libraries("${_paraview_client_NAME}
"
430 PRIVATE "Qt${PARAVIEW_QT_MAJOR_VERSION}::WebEngineWidgets
")
433 set(_paraview_client_export)
434 if (DEFINED _paraview_client_EXPORT)
435 list(APPEND _paraview_client_export
436 EXPORT "${_paraview_client_EXPORT}
")
440 TARGETS "${_paraview_client_NAME}
"
441 ${_paraview_client_export}
443 ${_paraview_client_bundle_args}
444 RUNTIME DESTINATION "${_paraview_client_RUNTIME_DESTINATION}
")
446 if (DEFINED _paraview_client_PLUGINS_TARGETS)
447 target_link_libraries("${_paraview_client_NAME}
"
449 ${_paraview_client_PLUGINS_TARGETS})
451 set(_paraview_client_binary_destination
452 "${_paraview_client_RUNTIME_DESTINATION}
")
453 set(_paraview_client_conf_destination
454 "${_paraview_client_binary_destination}
")
456 string(APPEND _paraview_client_binary_destination
457 "/${_paraview_client_NAME}.app/Contents/Resources
")
458 set(_paraview_client_conf_destination
459 "${_paraview_client_BUNDLE_DESTINATION}/${_paraview_client_NAME}.app/Contents/Resources
")
462 paraview_plugin_write_conf(
463 NAME "${_paraview_client_NAME}
"
464 PLUGINS_TARGETS ${_paraview_client_PLUGINS_TARGETS}
465 BUILD_DESTINATION "${_paraview_client_binary_destination}
"
466 INSTALL_DESTINATION "${_paraview_client_conf_destination}
"
471 if (DEFINED _paraview_client_BUNDLE_ICON)
472 get_filename_component(_paraview_client_bundle_icon_file "${_paraview_client_BUNDLE_ICON}
" NAME)
473 set_property(TARGET "${_paraview_client_NAME}
"
475 MACOSX_BUNDLE_ICON_FILE "${_paraview_client_bundle_icon_file}
")
477 FILES "${_paraview_client_BUNDLE_ICON}
"
478 DESTINATION "${_paraview_client_BUNDLE_DESTINATION}/${_paraview_client_APPLICATION_NAME}.app/Contents/Resources
"
481 if (DEFINED _paraview_client_BUNDLE_PLIST)
482 set_property(TARGET "${_paraview_client_NAME}
"
484 MACOSX_BUNDLE_INFO_PLIST "${_paraview_client_BUNDLE_PLIST}
")
486 string(TOLOWER "${_paraview_client_ORGANIZATION}
" _paraview_client_organization)
487 set_target_properties("${_paraview_client_NAME}
"
489 MACOSX_BUNDLE_BUNDLE_NAME "${_paraview_client_APPLICATION_NAME}
"
490 MACOSX_BUNDLE_GUI_IDENTIFIER "org.${_paraview_client_organization}.${_paraview_client_APPLICATION_NAME}
"
491 MACOSX_BUNDLE_SHORT_VERSION_STRING "${_paraview_client_VERSION}
")
498 Passing CMake lists down to the help generation and proxy documentation steps
499 requires escaping the `;` in them. These functions escape and unescape the
500 variable passed in. The new value is placed in the same variable in the calling
504 function (_paraview_client_escape_cmake_list variable)
505 string(REPLACE "_
" "_u
" _escape_tmp "${${variable}}
")
506 string(REPLACE ";
" "_s
" _escape_tmp "${_escape_tmp}
")
512 function (_paraview_client_unescape_cmake_list variable)
513 string(REPLACE "_s
" ";
" _escape_tmp "${${variable}}
")
514 string(REPLACE "_u
" "_
" _escape_tmp "${_escape_tmp}
")
521 ## Documentation from XML files
523 Documentation can be generated from server manager XML files. The
524 `paraview_client_documentation` generates Qt help, HTML, and Wiki documentation
528 paraview_client_documentation(
531 [OUTPUT_DIR <directory>])
534 * `TARGET`: (Required) The name of the target to generate.
535 * `XMLS`: (Required) The list of XML files to process.
536 * `OUTPUT_DIR`: (Defaults to `${CMAKE_CURRENT_BINARY_DIR}`) Where to place
537 generated documentation.
539 function (paraview_client_documentation)
540 cmake_parse_arguments(_paraview_client_doc
546 if (_paraview_client_doc_UNPARSED_ARGUMENTS)
549 "${_paraview_client_doc_UNPARSED_ARGUMENTS}
")
552 if (NOT DEFINED _paraview_client_doc_OUTPUT_DIR)
553 set(_paraview_client_doc_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}
")
556 if (NOT DEFINED _paraview_client_doc_TARGET)
558 "The `TARGET` argument is required.
")
561 if (NOT DEFINED _paraview_client_doc_XMLS)
563 "The `XMLS` argument is required.
")
566 include("${_ParaViewClient_cmake_dir}/paraview-find-package-helpers.cmake
" OPTIONAL)
567 find_program(qt_xmlpatterns_executable
568 NAMES xmlpatterns-qt5 xmlpatterns
569 HINTS "${Qt5_DIR}/../../../bin
"
570 "${Qt5_DIR}/../../../libexec/qt5/bin
"
571 DOC "Path to xmlpatterns
")
572 mark_as_advanced(qt_xmlpatterns_executable)
574 if (NOT qt_xmlpatterns_executable)
576 "Cannot find the xmlpatterns executable.
")
579 set(_paraview_client_doc_xmls)
580 foreach (_paraview_client_doc_xml IN LISTS _paraview_client_doc_XMLS)
581 get_filename_component(_paraview_client_doc_xml "${_paraview_client_doc_xml}
" ABSOLUTE)
582 list(APPEND _paraview_client_doc_xmls
583 "${_paraview_client_doc_xml}
")
586 # Save xmls to a temporary file.
587 set (_paraview_client_doc_xmls_file
588 "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_paraview_client_doc_TARGET}-xmls.txt
")
590 OUTPUT "${_paraview_client_doc_xmls_file}
"
591 CONTENT "${_paraview_client_doc_xmls}
")
594 OUTPUT "${_paraview_client_doc_OUTPUT_DIR}/${_paraview_client_doc_TARGET}.xslt
"
595 ${_paraview_client_doc_outputs}
596 COMMAND "${CMAKE_COMMAND}
"
597 "-Dxmlpatterns=${qt_xmlpatterns_executable}
"
598 "-Doutput_dir=${_paraview_client_doc_OUTPUT_DIR}
"
599 "-Doutput_file=${_paraview_client_doc_OUTPUT_DIR}/${_paraview_client_doc_TARGET}.xslt
"
600 "-Dxmls_file=${_paraview_client_doc_xmls_file}
"
601 -D_paraview_generate_proxy_documentation_run=ON
602 -P "${_ParaViewClient_script_file}
"
603 DEPENDS ${_paraview_client_doc_xmls}
604 "${_paraview_client_doc_xmls_file}
"
605 "${_ParaViewClient_script_file}
"
606 "${_ParaViewClient_cmake_dir}/paraview_servermanager_convert_xml.xsl
"
607 "${_ParaViewClient_cmake_dir}/paraview_servermanager_convert_categoryindex.xsl
"
608 "${_ParaViewClient_cmake_dir}/paraview_servermanager_convert_html.xsl
"
609 "${_ParaViewClient_cmake_dir}/paraview_servermanager_convert_wiki.xsl.in
"
610 WORKING_DIRECTORY "${_paraview_client_doc_OUTPUT_DIR}
"
611 COMMENT "Generating
documentation for ${_paraview_client_doc_TARGET}
")
612 add_custom_target("${_paraview_client_doc_TARGET}
"
614 "${_paraview_client_doc_OUTPUT_DIR}/${_paraview_client_doc_TARGET}.xslt
"
615 ${_paraview_client_doc_outputs})
618 # Generate proxy documentation.
619 if (_paraview_generate_proxy_documentation_run AND CMAKE_SCRIPT_MODE_FILE)
621 file(READ "${xmls_file}
" xmls)
623 set(_paraview_gpd_to_xml "${CMAKE_CURRENT_LIST_DIR}/paraview_servermanager_convert_xml.xsl
")
624 set(_paraview_gpd_to_catindex "${CMAKE_CURRENT_LIST_DIR}/paraview_servermanager_convert_categoryindex.xsl
")
625 set(_paraview_gpd_to_html "${CMAKE_CURRENT_LIST_DIR}/paraview_servermanager_convert_html.xsl
")
626 set(_paraview_gpd_to_wiki "${CMAKE_CURRENT_LIST_DIR}/paraview_servermanager_convert_wiki.xsl.in
")
628 set(_paraview_gpd_xslt "<xml>\n
")
629 file(MAKE_DIRECTORY "${output_dir}
")
630 foreach (_paraview_gpd_xml IN LISTS xmls)
632 COMMAND "${xmlpatterns}
"
633 "${_paraview_gpd_to_xml}
"
634 "${_paraview_gpd_xml}
"
635 OUTPUT_VARIABLE _paraview_gpd_output
636 ERROR_VARIABLE _paraview_gpd_error
637 RESULT_VARIABLE _paraview_gpd_result)
638 if (_paraview_gpd_result)
640 "Failed to
convert servermanager XML: ${_paraview_gpd_error}
")
643 string(APPEND _paraview_gpd_xslt
644 "${_paraview_gpd_output}
")
646 string(APPEND _paraview_gpd_xslt
649 file(WRITE "${output_file}.xslt
"
650 "${_paraview_gpd_xslt}
")
652 COMMAND "${xmlpatterns}
"
653 -output "${output_file}
"
654 "${_paraview_gpd_to_catindex}
"
655 "${output_file}.xslt
"
656 RESULT_VARIABLE _paraview_gpd_result)
657 if (_paraview_gpd_result)
659 "Failed to generate category
index")
662 # Generate HTML files.
664 COMMAND "${xmlpatterns}
"
665 "${_paraview_gpd_to_html}
"
667 OUTPUT_VARIABLE _paraview_gpd_output
668 RESULT_VARIABLE _paraview_gpd_result
669 OUTPUT_STRIP_TRAILING_WHITESPACE)
670 if (_paraview_gpd_result)
672 "Failed to generate HTML output
")
675 # Escape open/close brackets as HTML entities as they somehow interfere with the foreach loop below.
676 string(REPLACE "[
" "[
" _paraview_gpd_output "${_paraview_gpd_output}
")
677 string(REPLACE "]
" "]
" _paraview_gpd_output "${_paraview_gpd_output}
")
680 _paraview_client_escape_cmake_list(_paraview_gpd_output)
682 # Convert into a list of HTML documents.
683 string(REPLACE "</html>\n<html>
" "</html>\n;<html>
" _paraview_gpd_output "${_paraview_gpd_output}
")
685 foreach (_paraview_gpd_html_doc IN LISTS _paraview_gpd_output)
686 _paraview_client_unescape_cmake_list(_paraview_gpd_html_doc)
687 string(REGEX MATCH "<
meta name=\
"filename\" contents=\"([^\"]*)\"" _
"${_paraview_gpd_html_doc}")
688 set(_paraview_gpd_filename
"${CMAKE_MATCH_1}")
689 if (NOT _paraview_gpd_filename)
691 "No filename for an HTML output?")
694 # Replace reStructured Text markup.
695 string(REGEX REPLACE
"\\*\\*([^*]+)\\*\\*" "<b>\\1</b>" _paraview_gpd_html_doc
"${_paraview_gpd_html_doc}")
696 string(REGEX REPLACE
"\\*([^*]+)\\*" "<em>\\1</em>" _paraview_gpd_html_doc
"${_paraview_gpd_html_doc}")
697 string(REGEX REPLACE
"\n\n- " "\n<ul><li>" _paraview_gpd_html_doc
"${_paraview_gpd_html_doc}")
698 string(REGEX REPLACE
"\n-" "\n<li>" _paraview_gpd_html_doc
"${_paraview_gpd_html_doc}")
699 string(REGEX REPLACE
"<li>(.*)\n\n([^-])" "<li>\\1</ul>\n\\2" _paraview_gpd_html_doc
"${_paraview_gpd_html_doc}")
700 string(REGEX REPLACE
"\n\n" "\n<p>\n" _paraview_gpd_html_doc
"${_paraview_gpd_html_doc}")
701 file(WRITE
"${output_dir}/${_paraview_gpd_filename}"
702 "${_paraview_gpd_html_doc}\n")
705 # Generate Wiki files.
706 string(REGEX MATCHALL
"proxy_group=\"[^\"]*\"" _paraview_gpd_groups
"${_paraview_gpd_xslt}")
707 string(REGEX REPLACE
"proxy_group=\"([^\"]*)\"" "\\1" _paraview_gpd_groups
"${_paraview_gpd_groups}")
708 list(APPEND _paraview_gpd_groups readers)
709 if (_paraview_gpd_groups)
710 list(REMOVE_DUPLICATES _paraview_gpd_groups)
713 foreach (_paraview_gpd_group IN LISTS _paraview_gpd_groups)
714 if (_paraview_gpd_group STREQUAL "readers")
715 set(_paraview_gpd_query "contains(lower-case($proxy_name),'reader')")
716 set(_paraview_gpd_group_real "sources")
718 set(_paraview_gpd_query "not(contains(lower-case($proxy_name),'reader'))")
719 set(_paraview_gpd_group_real "${_paraview_gpd_group}
")
722 set(_paraview_gpd_wiki_xsl
723 "${output_dir}/${_paraview_gpd_group}.xsl
")
725 "${_paraview_gpd_to_wiki}
"
726 "${_paraview_gpd_wiki_xsl}
"
729 COMMAND "${xmlpatterns}
"
730 "${_paraview_gpd_wiki_xsl}
"
732 OUTPUT_VARIABLE _paraview_gpd_output
733 RESULT_VARIABLE _paraview_gpd_result)
734 if (_paraview_gpd_result)
736 "Failed to generate Wiki output
for ${_paraview_gpd_group}
")
738 string(REGEX REPLACE " +
" " " _paraview_gpd_output "${_paraview_gpd_output}
")
739 string(REPLACE "\n
" "\n
" _paraview_gpd_output "${_paraview_gpd_output}
")
740 file(WRITE "${output_dir}/${_paraview_gpd_group}.wiki
"
741 "${_paraview_gpd_output}
")
746 ## Generating help documentation
751 paraview_client_generate_help(
757 [OUTPUT_DIR <directory>]
758 [SOURCE_DIR <directory>]
759 [PATTERNS <pattern>...]
760 [DEPENDS <depend>...]
762 [NAMESPACE <namespace>]
765 [TABLE_OF_CONTENTS <toc>]
766 [TABLE_OF_CONTENTS_FILE <tocfile>]
768 [RESOURCE_FILE <qrcfile>]
769 [RESOURCE_PREFIX <prefix>]
772 * `NAME`: (Required) The basename of the generated `.qch` file.
773 * `TARGET`: (Defaults to `<NAME>`) The name of the generated target.
774 * `OUTPUT_PATH`: (Required) This variable is set to the output path of the
775 generated `.qch` file.
776 * `OUTPUT_DIR`: (Defaults to `${CMAKE_CURRENT_BINARY_DIR}`) Where to place
778 * `SOURCE_DIR`: Where to copy input files from.
779 * `PATTERNS`: (Defaults to `*.*`) If `SOURCE_DIR` is specified, files
780 matching these globs will be copied to `OUTPUT_DIR`.
781 * `DEPENDS`: A list of dependencies which are required before the help can be
782 generated. Note that file paths which are generated via
783 `add_custom_command` must be in the same directory as the
784 `paraview_client_generate_help` on non-Ninja generators.
785 * `NAMESPACE`: (Defaults to `<NAME>.org`) The namespace for the generated
787 * `FOLDER`: (Defaults to `<NAME>`) The folder for the generated help.
788 * `TABLE_OF_CONTENTS` and `TABLE_OF_CONTENTS_FILE`: At most one may be
789 provided. This is used as the `<toc>` element in the generated help. If not
790 provided at all, a table of contents will be generated.
791 * `RESOURCE_FILE`: If provided, a Qt resource file providing the contents of
792 the generated help will be generated at this path. It will be available as
793 `<RESOURCE_PREFIX>/<NAME>`.
794 * `RESOURCE_PREFIX`: The prefix to use for the generated help's Qt resource.
796 function (paraview_client_generate_help)
797 cmake_parse_arguments(_paraview_client_help
799 "NAME;TARGET;OUTPUT_DIR;SOURCE_DIR;NAMESPACE;FOLDER;TABLE_OF_CONTENTS;TABLE_OF_CONTENTS_FILE;RESOURCE_FILE;RESOURCE_PREFIX;OUTPUT_PATH
"
803 if (_paraview_client_help_UNPARSED_ARGUMENTS)
806 "${_paraview_client_help_UNPARSED_ARGUMENTS}
")
809 if (NOT DEFINED _paraview_client_help_NAME)
811 "The `
NAME` argument is required.
")
814 if (NOT DEFINED _paraview_client_help_OUTPUT_PATH)
816 "The `OUTPUT_PATH` argument is required.
")
819 if (NOT DEFINED _paraview_client_help_TARGET)
820 set(_paraview_client_help_TARGET
821 "${_paraview_client_help_NAME}
")
824 if (NOT DEFINED _paraview_client_help_OUTPUT_DIR)
825 set(_paraview_client_help_OUTPUT_DIR
826 "${CMAKE_CURRENT_BINARY_DIR}/paraview_help
")
829 if (NOT DEFINED _paraview_client_help_NAMESPACE)
830 set(_paraview_client_help_NAMESPACE
831 "${_paraview_client_help_NAME}.org
")
834 if (NOT DEFINED _paraview_client_help_FOLDER)
835 set(_paraview_client_help_FOLDER
836 "${_paraview_client_help_NAME}
")
839 if (DEFINED _paraview_client_help_TABLE_OF_CONTENTS_FILE)
840 file(READ "${_paraview_client_help_TABLE_OF_CONTENTS_FILE}
"
841 _paraview_client_help_toc)
842 elseif (DEFINED _paraview_client_help_TABLE_OF_CONTENTS)
843 set(_paraview_client_help_toc
844 "${_paraview_client_help_TABLE_OF_CONTENTS}
")
846 set(_paraview_client_help_toc)
848 string(REPLACE "\n
" " " _paraview_client_help_toc "${_paraview_client_help_toc}
")
850 if (NOT DEFINED _paraview_client_help_PATTERNS)
851 set(_paraview_client_help_PATTERNS
855 include("${_ParaViewClient_cmake_dir}/paraview-find-package-helpers.cmake
" OPTIONAL)
856 set(_paraview_client_help_components
858 if (PARAVIEW_QT_MAJOR_VERSION GREATER "5
")
859 list(APPEND _paraview_client_help_components
862 find_package("Qt${PARAVIEW_QT_MAJOR_VERSION}
" QUIET REQUIRED COMPONENTS ${_paraview_client_help_components})
864 set(_paraview_client_help_copy_sources)
865 set(_paraview_client_help_copied_sources)
866 if (DEFINED _paraview_client_help_SOURCE_DIR)
867 list(APPEND _paraview_client_help_copy_sources
868 COMMAND "${CMAKE_COMMAND}
" -E copy_directory
869 "${_paraview_client_help_SOURCE_DIR}
"
870 "${_paraview_client_help_OUTPUT_DIR}
")
872 file(GLOB _paraview_client_help_copied_sources
873 ${_paraview_client_help_PATTERNS})
876 file(MAKE_DIRECTORY "${_paraview_client_help_OUTPUT_DIR}
")
878 set(_paraview_client_help_patterns "${_paraview_client_help_PATTERNS}
")
879 _paraview_client_escape_cmake_list(_paraview_client_help_patterns)
881 set(_paraview_client_help_qhp
882 "${_paraview_client_help_OUTPUT_DIR}/${_paraview_client_help_NAME}.qhp
")
883 set(_paraview_client_help_output
884 "${_paraview_client_help_OUTPUT_DIR}/${_paraview_client_help_NAME}.qch
")
886 OUTPUT "${_paraview_client_help_output}
"
887 DEPENDS "${_ParaViewClient_script_file}
"
888 ${_paraview_client_help_copied_sources}
889 ${_paraview_client_help_DEPENDS}
890 ${_paraview_client_help_copy_sources}
891 COMMAND "${CMAKE_COMMAND}
"
892 "-Doutput_dir=${_paraview_client_help_OUTPUT_DIR}
"
893 "-Doutput_file=${_paraview_client_help_qhp}
"
894 "-Dnamespace=${_paraview_client_help_NAMESPACE}
"
895 "-Dfolder=${_paraview_client_help_FOLDER}
"
896 "-Dname=${_paraview_client_help_NAME}
"
897 "-Dtoc=${_paraview_client_help_toc}
"
898 "-Dpatterns=${_paraview_client_help_patterns}
"
899 -D_paraview_generate_help_run=ON
900 -P "${_ParaViewClient_script_file}
"
902 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR}
903 "$<TARGET_FILE:Qt${PARAVIEW_QT_MAJOR_VERSION}::qhelpgenerator>
"
904 "${_paraview_client_help_qhp}
"
906 -o "${_paraview_client_help_output}
"
907 COMMENT "Compiling Qt help
for ${_paraview_client_help_NAME}
"
908 WORKING_DIRECTORY "${_paraview_client_help_OUTPUT_DIR}
")
909 add_custom_target("${_paraview_client_help_TARGET}
"
911 "${_paraview_client_help_output}
")
913 if (DEFINED _paraview_client_help_RESOURCE_FILE)
914 if (NOT DEFINED _paraview_client_help_RESOURCE_PREFIX)
916 "The `RESOURCE_PREFIX` argument is required
if `RESOURCE_FILE` is given.
")
919 paraview_client_qt_resource(
920 OUTPUT "${_paraview_client_help_RESOURCE_FILE}
"
921 PREFIX "${_paraview_client_help_RESOURCE_PREFIX}
"
922 FILE "${_paraview_client_help_output}
")
923 set_property(SOURCE "${_paraview_client_help_RESOURCE_FILE}
"
925 OBJECT_DEPENDS "${_paraview_client_help_output}
")
928 set("${_paraview_client_help_OUTPUT_PATH}
"
929 "${_paraview_client_help_output}
"
933 # Handle the generation of the help file.
934 if (_paraview_generate_help_run AND CMAKE_SCRIPT_MODE_FILE)
935 _paraview_client_unescape_cmake_list(patterns)
937 set(_paraview_help_patterns)
938 foreach (_paraview_help_pattern IN LISTS patterns)
939 if (IS_ABSOLUTE "${_paraview_help_pattern}
")
940 list(APPEND _paraview_help_patterns
941 "${_paraview_help_pattern}
")
943 list(APPEND _paraview_help_patterns
944 "${output_dir}/${_paraview_help_pattern}
")
948 file(GLOB _paraview_help_files
949 RELATIVE "${output_dir}
"
950 ${_paraview_help_patterns})
953 if (NOT _paraview_help_files)
955 "No matching files given without a table of contents
")
957 set(_paraview_help_subsections "")
958 list(GET _paraview_help_files 0
959 _paraview_help_index)
960 set(_paraview_help_subsections "")
961 foreach (_paraview_help_file IN LISTS _paraview_help_files)
962 if (NOT _paraview_help_file MATCHES "\\.html$
")
965 get_filename_component(_paraview_help_name "${_paraview_help_file}
" NAME_WE)
966 set(_paraview_help_title "${_paraview_help_name}
")
967 file(READ "${_paraview_help_file}
" _paraview_help_contents)
968 string(REGEX MATCH "<
title>([^<]*)</title>
" _ "${_paraview_help_contents}
")
970 set(_paraview_help_title "${CMAKE_MATCH_1}
")
972 string(APPEND _paraview_help_subsections
973 " <section
title=\
"${_paraview_help_title}\" ref=\"${_paraview_help_file}\" />\n")
975 string(TOLOWER
"${_paraview_help_name}" _paraview_help_name_lower)
976 if (_paraview_help_name_lower STREQUAL
"index")
977 set(_paraview_help_index
978 "${_paraview_help_file}")
982 "<toc>\n <section title=\"${
name}\
" ref=\"${_paraview_help_index}\">\n${_paraview_help_subsections} </section>\n</toc>")
985 set(_paraview_help_file_entries "")
986 foreach (_paraview_help_file IN LISTS _paraview_help_files)
987 string(APPEND _paraview_help_file_entries
988 " <file>${_paraview_help_file}</file>\n
")
991 file(WRITE "${output_file}
"
992 "<?xml
version=\
"1.0\" encoding=\"UTF-8\"?>
993 <QtHelpProject version=\"1.0\">
994 <namespace>${namespace}</namespace>
995 <virtualFolder>${folder}</virtualFolder>
999 <!-- TODO: how to handle keywords? -->
1002 ${_paraview_help_file_entries}
1005 </QtHelpProject>\n")
1011 Compiling Qt resources into a client can be a little tedious. To help with
1012 this, some functions are provided to make it easier to embed
content into the
1027 Outputs a Qt resource to the file given to the `OUTPUT` argument. Its resource
1028 name is `<PREFIX>/<ALIAS>`. The contents are copied from the contents of the
1029 file specified by the `FILE` argument. If not given the
name of the file is
1030 used as the `ALIAS`.
1033 cmake_parse_arguments(_paraview_client_resource
1035 "OUTPUT;PREFIX;ALIAS;FILE"
1039 if (_paraview_client_resource_UNPARSED_ARGUMENTS)
1041 "Unparsed arguments for paraview_client_qt_resource: "
1042 "${_paraview_client_resource_UNPARSED_ARGUMENTS}")
1045 if (NOT DEFINED _paraview_client_resource_OUTPUT)
1047 "The `OUTPUT` argument is required.")
1050 if (NOT DEFINED _paraview_client_resource_PREFIX)
1052 "The `PREFIX` argument is required.")
1055 if (NOT DEFINED _paraview_client_resource_FILE)
1057 "The `FILE` argument is required.")
1060 if (NOT DEFINED _paraview_client_resource_ALIAS)
1061 get_filename_component(_paraview_client_resource_ALIAS
1062 "${_paraview_client_resource_FILE}
"
1066 get_filename_component(_paraview_client_resource_file_path
1067 "${_paraview_client_resource_FILE}
"
1069 get_filename_component(_paraview_client_resource_file_path
1070 "${_paraview_client_resource_file_path}
"
1074 "${_paraview_client_resource_file_path}
"
1075 _paraview_client_resource_file_path)
1078 # We cannot use file(GENERATE) because automoc doesn't like when generated
1079 # sources are in the source list.
1080 file(WRITE "${_paraview_client_resource_OUTPUT}.tmp
"
1082 <qresource prefix=\
"/${_paraview_client_resource_PREFIX}\">
1083 <file alias=\"${_paraview_client_resource_ALIAS}\">${_paraview_client_resource_file_path}</file>
1087 "${_paraview_client_resource_OUTPUT}.tmp"
1088 "${_paraview_client_resource_OUTPUT}"
1102 Outputs a Qt resource to the file given to the `OUTPUT` argument. Its resource
1103 name is `<PREFIX>/<filename>`
for each of the files in the given list. If
1104 aliases other than the filenames are required, the
1108 cmake_parse_arguments(_paraview_client_resources
1114 if (_paraview_client_resources_UNPARSED_ARGUMENTS)
1116 "Unparsed arguments for paraview_client_qt_resources: "
1117 "${_paraview_client_resources_UNPARSED_ARGUMENTS}")
1120 if (NOT DEFINED _paraview_client_resources_OUTPUT)
1122 "The `OUTPUT` argument is required.")
1125 if (NOT DEFINED _paraview_client_resources_PREFIX)
1127 "The `PREFIX` argument is required.")
1130 if (NOT DEFINED _paraview_client_resources_FILES)
1132 "The `FILES` argument is required.")
1135 set(_paraview_client_resources_contents)
1137 string(APPEND _paraview_client_resources_contents
1138 "<RCC>\n <qresource prefix=\"${_paraview_client_resources_PREFIX}\
">\n")
1139 foreach (_paraview_client_resources_file IN LISTS _paraview_client_resources_FILES)
1140 get_filename_component(_paraview_client_resources_alias
1141 "${_paraview_client_resources_file}"
1143 get_filename_component(_paraview_client_resources_file_path
1144 "${_paraview_client_resources_file}"
1146 get_filename_component(_paraview_client_resources_file_path
1147 "${_paraview_client_resources_file_path}"
1151 "${_paraview_client_resources_file_path}"
1152 _paraview_client_resources_file_path)
1154 string(APPEND _paraview_client_resources_contents
1155 " <file alias=\"${_paraview_client_resources_alias}\
">${_paraview_client_resources_file_path}</file>\n")
1157 string(APPEND _paraview_client_resources_contents
1158 " </qresource>\n</RCC>\n")
1160 # We cannot use file(GENERATE) because automoc doesn't like when generated
1161 # sources are in the source list.
1162 file(WRITE
"${_paraview_client_resources_OUTPUT}.tmp"
1163 "${_paraview_client_resources_contents}")
1165 "${_paraview_client_resources_OUTPUT}.tmp"
1166 "${_paraview_client_resources_OUTPUT}"