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
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)
169 "The `paraview_client_add(QCH_FILE)` argument is incompatible " 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}")
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" 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")
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")
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")
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")
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)
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")
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")
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 target_sources(
"${_paraview_client_NAME}" 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}")
418 target_include_directories(
"${_paraview_client_NAME}" 420 "${CMAKE_CURRENT_SOURCE_DIR}" 421 "${CMAKE_CURRENT_BINARY_DIR}" 423 "$<TARGET_PROPERTY:VTK::vtksys,INTERFACE_INCLUDE_DIRECTORIES>")
424 target_link_libraries(
"${_paraview_client_NAME}" 426 ParaView::pqApplicationComponents
427 "Qt${PARAVIEW_QT_MAJOR_VERSION}::Widgets" 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")
435 set(_paraview_client_export)
436 if (DEFINED _paraview_client_EXPORT)
437 list(APPEND _paraview_client_export
438 EXPORT "${_paraview_client_EXPORT}")
442 TARGETS
"${_paraview_client_NAME}" 443 ${_paraview_client_export}
445 ${_paraview_client_bundle_args}
446 RUNTIME DESTINATION
"${_paraview_client_RUNTIME_DESTINATION}")
448 if (DEFINED _paraview_client_PLUGINS_TARGETS)
449 target_link_libraries(
"${_paraview_client_NAME}" 451 ${_paraview_client_PLUGINS_TARGETS})
453 set(_paraview_client_binary_destination
454 "${_paraview_client_RUNTIME_DESTINATION}")
455 set(_paraview_client_conf_destination
456 "${_paraview_client_binary_destination}")
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")
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}" 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}" 477 MACOSX_BUNDLE_ICON_FILE
"${_paraview_client_bundle_icon_file}")
479 FILES
"${_paraview_client_BUNDLE_ICON}" 480 DESTINATION
"${_paraview_client_BUNDLE_DESTINATION}/${_paraview_client_APPLICATION_NAME}.app/Contents/Resources" 483 if (DEFINED _paraview_client_BUNDLE_PLIST)
484 set_property(TARGET
"${_paraview_client_NAME}" 486 MACOSX_BUNDLE_INFO_PLIST
"${_paraview_client_BUNDLE_PLIST}")
488 string(TOLOWER
"${_paraview_client_ORGANIZATION}" _paraview_client_organization)
489 set_target_properties(
"${_paraview_client_NAME}" 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}")
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
507 string(REPLACE
"_" "_u" _escape_tmp
"${${variable}}")
508 string(REPLACE
";" "_s" _escape_tmp
"${_escape_tmp}")
515 string(REPLACE
"_s" ";" _escape_tmp
"${${variable}}")
516 string(REPLACE
"_u" "_" _escape_tmp
"${_escape_tmp}")
523 ## Documentation from XML files 525 Documentation can be generated from server manager XML files. The
533 [OUTPUT_DIR <directory>])
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
542 cmake_parse_arguments(_paraview_client_doc
548 if (_paraview_client_doc_UNPARSED_ARGUMENTS)
550 "Unparsed arguments for paraview_client_documentation: " 551 "${_paraview_client_doc_UNPARSED_ARGUMENTS}")
554 if (NOT DEFINED _paraview_client_doc_OUTPUT_DIR)
555 set(_paraview_client_doc_OUTPUT_DIR
"${CMAKE_CURRENT_BINARY_DIR}")
558 if (NOT DEFINED _paraview_client_doc_TARGET)
560 "The `TARGET` argument is required.")
563 if (NOT DEFINED _paraview_client_doc_XMLS)
565 "The `XMLS` argument is required.")
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)
576 if (NOT qt_xmlpatterns_executable)
578 "Cannot find the xmlpatterns executable.")
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}")
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")
592 OUTPUT
"${_paraview_client_doc_xmls_file}" 593 CONTENT
"${_paraview_client_doc_xmls}")
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}" 616 "${_paraview_client_doc_OUTPUT_DIR}/${_paraview_client_doc_TARGET}.xslt" 617 ${_paraview_client_doc_outputs})
620 # Generate proxy documentation. 621 if (_paraview_generate_proxy_documentation_run AND CMAKE_SCRIPT_MODE_FILE)
623 file(READ
"${xmls_file}" xmls)
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")
630 set(_paraview_gpd_xslt
"<xml>\n")
631 file(MAKE_DIRECTORY
"${output_dir}")
632 foreach (_paraview_gpd_xml IN LISTS xmls)
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)
642 "Failed to convert servermanager XML: ${_paraview_gpd_error}")
645 string(APPEND _paraview_gpd_xslt
646 "${_paraview_gpd_output}")
648 string(APPEND _paraview_gpd_xslt
651 file(WRITE
"${output_file}.xslt" 652 "${_paraview_gpd_xslt}")
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)
661 "Failed to generate category index")
664 # Generate HTML files. 666 COMMAND
"${xmlpatterns}" 667 "${_paraview_gpd_to_html}" 669 OUTPUT_VARIABLE _paraview_gpd_output
670 RESULT_VARIABLE _paraview_gpd_result
671 OUTPUT_STRIP_TRAILING_WHITESPACE)
672 if (_paraview_gpd_result)
674 "Failed to generate HTML output")
677 # Escape open/close brackets as HTML entities as they somehow interfere with the foreach loop below. 678 string(REPLACE
"[" "[" _paraview_gpd_output
"${_paraview_gpd_output}")
679 string(REPLACE
"]" "]" _paraview_gpd_output
"${_paraview_gpd_output}")
684 # Convert into a list of HTML documents. 685 string(REPLACE
"</html>\n<html>" "</html>\n;<html>" _paraview_gpd_output
"${_paraview_gpd_output}")
687 foreach (_paraview_gpd_html_doc IN LISTS _paraview_gpd_output)
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)
693 "No filename for an HTML output?")
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")
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)
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")
720 set(_paraview_gpd_query
"not(contains(lower-case($proxy_name),'reader'))")
721 set(_paraview_gpd_group_real
"${_paraview_gpd_group}")
724 set(_paraview_gpd_wiki_xsl
725 "${output_dir}/${_paraview_gpd_group}.xsl")
727 "${_paraview_gpd_to_wiki}" 728 "${_paraview_gpd_wiki_xsl}" 731 COMMAND
"${xmlpatterns}" 732 "${_paraview_gpd_wiki_xsl}" 734 OUTPUT_VARIABLE _paraview_gpd_output
735 RESULT_VARIABLE _paraview_gpd_result)
736 if (_paraview_gpd_result)
738 "Failed to generate Wiki output for ${_paraview_gpd_group}")
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}")
748 ## Generating help documentation 759 [OUTPUT_DIR <directory>]
760 [SOURCE_DIR <directory>]
761 [PATTERNS <pattern>...]
762 [DEPENDS <depend>...]
764 [NAMESPACE <namespace>]
767 [TABLE_OF_CONTENTS <toc>]
768 [TABLE_OF_CONTENTS_FILE <tocfile>]
770 [RESOURCE_FILE <qrcfile>]
771 [RESOURCE_PREFIX <prefix>]
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
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
787 * `NAMESPACE`: (Defaults to `<NAME>.org`) The
namespace for the generated
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. 798 function (paraview_client_generate_help) 799 cmake_parse_arguments(_paraview_client_help 801 "NAME;TARGET;OUTPUT_DIR;SOURCE_DIR;NAMESPACE;FOLDER;TABLE_OF_CONTENTS;TABLE_OF_CONTENTS_FILE;RESOURCE_FILE;RESOURCE_PREFIX;OUTPUT_PATH" 805 if (_paraview_client_help_UNPARSED_ARGUMENTS) 807 "Unparsed arguments for paraview_client_generate_help: " 808 "${_paraview_client_help_UNPARSED_ARGUMENTS}") 811 if (NOT DEFINED _paraview_client_help_NAME) 813 "The `NAME` argument is required.") 816 if (NOT DEFINED _paraview_client_help_OUTPUT_PATH) 818 "The `OUTPUT_PATH` argument is required.") 821 if (NOT DEFINED _paraview_client_help_TARGET) 822 set(_paraview_client_help_TARGET 823 "${_paraview_client_help_NAME}") 826 if (NOT DEFINED _paraview_client_help_OUTPUT_DIR) 827 set(_paraview_client_help_OUTPUT_DIR 828 "${CMAKE_CURRENT_BINARY_DIR}/paraview_help") 831 if (NOT DEFINED _paraview_client_help_NAMESPACE) 832 set(_paraview_client_help_NAMESPACE 833 "${_paraview_client_help_NAME}.org") 836 if (NOT DEFINED _paraview_client_help_FOLDER) 837 set(_paraview_client_help_FOLDER 838 "${_paraview_client_help_NAME}") 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}") 848 set(_paraview_client_help_toc) 850 string(REPLACE "\n" " " _paraview_client_help_toc "${_paraview_client_help_toc}") 852 if (NOT DEFINED _paraview_client_help_PATTERNS) 853 set(_paraview_client_help_PATTERNS 857 include("${_ParaViewClient_cmake_dir}/paraview-find-package-helpers.cmake" OPTIONAL) 858 set(_paraview_client_help_components 860 if (PARAVIEW_QT_MAJOR_VERSION GREATER "5") 861 list(APPEND _paraview_client_help_components 864 find_package("Qt${PARAVIEW_QT_MAJOR_VERSION}" QUIET REQUIRED COMPONENTS ${_paraview_client_help_components}) 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}") 874 file(GLOB _paraview_client_help_copied_sources 875 ${_paraview_client_help_PATTERNS}) 878 file(MAKE_DIRECTORY "${_paraview_client_help_OUTPUT_DIR}") 880 set(_paraview_client_help_patterns "${_paraview_client_help_PATTERNS}") 881 _paraview_client_escape_cmake_list(_paraview_client_help_patterns) 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") 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}" 904 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} 905 "$<TARGET_FILE:Qt${PARAVIEW_QT_MAJOR_VERSION}::qhelpgenerator>" 906 "${_paraview_client_help_qhp}" 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}" 913 "${_paraview_client_help_output}") 915 if (DEFINED _paraview_client_help_RESOURCE_FILE) 916 if (NOT DEFINED _paraview_client_help_RESOURCE_PREFIX) 918 "The `RESOURCE_PREFIX` argument is required if `RESOURCE_FILE` is given.") 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}" 927 OBJECT_DEPENDS "${_paraview_client_help_output}") 930 set("${_paraview_client_help_OUTPUT_PATH}" 931 "${_paraview_client_help_output}" 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) 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}") 945 list(APPEND _paraview_help_patterns 946 "${output_dir}/${_paraview_help_pattern}") 950 file(GLOB _paraview_help_files 951 RELATIVE "${output_dir}" 952 ${_paraview_help_patterns}) 955 if (NOT _paraview_help_files) 957 "No matching files given without a table of contents") 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$") 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}") 972 set(_paraview_help_title "${CMAKE_MATCH_1}") 974 string(APPEND _paraview_help_subsections 975 " <section title=\"${_paraview_help_title}\" ref=\"${_paraview_help_file}\" />\n") 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}") 984 "<toc>\n <section title=\"${name}\" ref=\"${_paraview_help_index}\">\n${_paraview_help_subsections} </section>\n</toc>") 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") 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> 1001 <!-- TODO: how to handle keywords? --> 1004 ${_paraview_help_file_entries} 1007 </QtHelpProject>\n") 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 1022 paraview_client_qt_resource( 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`. 1034 function (paraview_client_qt_resource) 1035 cmake_parse_arguments(_paraview_client_resource 1037 "OUTPUT;PREFIX;ALIAS;FILE" 1041 if (_paraview_client_resource_UNPARSED_ARGUMENTS) 1043 "Unparsed arguments for paraview_client_qt_resource: " 1044 "${_paraview_client_resource_UNPARSED_ARGUMENTS}") 1047 if (NOT DEFINED _paraview_client_resource_OUTPUT) 1049 "The `OUTPUT` argument is required.") 1052 if (NOT DEFINED _paraview_client_resource_PREFIX) 1054 "The `PREFIX` argument is required.") 1057 if (NOT DEFINED _paraview_client_resource_FILE) 1059 "The `FILE` argument is required.") 1062 if (NOT DEFINED _paraview_client_resource_ALIAS) 1063 get_filename_component(_paraview_client_resource_ALIAS 1064 "${_paraview_client_resource_FILE}" 1068 get_filename_component(_paraview_client_resource_file_path 1069 "${_paraview_client_resource_FILE}" 1071 get_filename_component(_paraview_client_resource_file_path 1072 "${_paraview_client_resource_file_path}" 1076 "${_paraview_client_resource_file_path}" 1077 _paraview_client_resource_file_path) 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" 1084 <qresource prefix=\"/${_paraview_client_resource_PREFIX}\"> 1085 <file alias=\"${_paraview_client_resource_ALIAS}\">${_paraview_client_resource_file_path}</file> 1089 "${_paraview_client_resource_OUTPUT}.tmp" 1090 "${_paraview_client_resource_OUTPUT}" 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
1110 cmake_parse_arguments(_paraview_client_resources
1116 if (_paraview_client_resources_UNPARSED_ARGUMENTS)
1118 "Unparsed arguments for paraview_client_qt_resources: " 1119 "${_paraview_client_resources_UNPARSED_ARGUMENTS}")
1122 if (NOT DEFINED _paraview_client_resources_OUTPUT)
1124 "The `OUTPUT` argument is required.")
1127 if (NOT DEFINED _paraview_client_resources_PREFIX)
1129 "The `PREFIX` argument is required.")
1132 if (NOT DEFINED _paraview_client_resources_FILES)
1134 "The `FILES` argument is required.")
1137 set(_paraview_client_resources_contents)
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}" 1145 get_filename_component(_paraview_client_resources_file_path
1146 "${_paraview_client_resources_file}" 1148 get_filename_component(_paraview_client_resources_file_path
1149 "${_paraview_client_resources_file_path}" 1153 "${_paraview_client_resources_file_path}" 1154 _paraview_client_resources_file_path)
1156 string(APPEND _paraview_client_resources_contents
1157 " <file alias=\"${_paraview_client_resources_alias}\">${_paraview_client_resources_file_path}</file>\n")
1159 string(APPEND _paraview_client_resources_contents
1160 " </qresource>\n</RCC>\n")
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}") 1167 "${_paraview_client_resources_OUTPUT}.tmp" 1168 "${_paraview_client_resources_OUTPUT}" function paraview_create_translation()
Generate a Qt translation source file from the given source files.
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...
function paraview_client_documentation()
.md Documentation from XML files
function paraview_client_qt_resource()
.md Qt resources
function paraview_client_generate_help()
.md Generating help documentation
function paraview_client_add()
.md Building a client
#define BUILD_SHARED_LIBS
function paraview_plugin_write_conf()
.md Plugin configuration files
function paraview_client_qt_resources()
.md Many files
function _paraview_client_escape_cmake_list(variable)
.md INTERNAL Quoting