paraviewQt.cmake
Go to the documentation of this file.
1 # PARAVIEW_QT_VERSION is used to choose between Qt5 and Qt6.
2 # If it is set to Auto(default), PARAVIEW finds and uses the
3 # version installed on the system. If both versions are
4 # found, Qt6 is preferred.
5 
6 # Note that this is a duplication of vtkQt.cmake from VTK
7 
8 set(paraview_supported_qt_versions "Auto" 5 6)
9 
10 # The following `if` check can be removed once CMake 3.21 is required and
11 # the policy CMP0126 is set to NEW for ParaView and other superbuilds.
12 if (NOT DEFINED PARAVIEW_QT_VERSION)
13  set(PARAVIEW_QT_VERSION "Auto" CACHE
14  STRING "Expected Qt major version. Valid values are Auto, 5, 6.")
15  set_property(CACHE PARAVIEW_QT_VERSION PROPERTY STRINGS "${paraview_supported_qt_versions}")
16 endif ()
17 
18 if (NOT PARAVIEW_QT_VERSION IN_LIST paraview_supported_qt_versions)
19  string(REPLACE ";" "\", \"" paraview_supported_qt_versions_string "${paraview_supported_qt_versions}")
20  message(FATAL_ERROR
21  "Supported Qt versions are \"${paraview_supported_qt_versions_string}\". "
22  "But `PARAVIEW_QT_VERSION` is set to \"${PARAVIEW_QT_VERSION}\".")
23 endif ()
24 
25 if (PARAVIEW_QT_VERSION STREQUAL "Auto")
26  find_package(Qt6 QUIET COMPONENTS Core)
27  set(_paraview_qt_version 6)
28  if (NOT Qt6_FOUND)
29  find_package(Qt5 QUIET COMPONENTS Core)
30  if (NOT Qt5_FOUND)
31  message(FATAL_ERROR
32  "Could not find a valid Qt installation.")
33  endif ()
34  set(_paraview_qt_version 5)
35  endif ()
36 else ()
37  set(_paraview_qt_version "${PARAVIEW_QT_VERSION}")
38 endif ()
39 
40 set(PARAVIEW_QT_MAJOR_VERSION "${_paraview_qt_version}")