diff options
author | Sankhesh Jhaveri <sankhesh.jhaveri@kitware.com> | 2020-12-28 19:38:13 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-01-05 16:03:31 (GMT) |
commit | 2e4cbaa521ee36b05422469e6569cd85943d79fd (patch) | |
tree | e57f1500acf6bfa28b331b42bad68196ba7a78dc /Source/QtDialog | |
parent | b3ee09290bcc6f660aeafbe3490a6016867ef2ae (diff) | |
download | CMake-2e4cbaa521ee36b05422469e6569cd85943d79fd.zip CMake-2e4cbaa521ee36b05422469e6569cd85943d79fd.tar.gz CMake-2e4cbaa521ee36b05422469e6569cd85943d79fd.tar.bz2 |
cmake-gui: Add a Qt version control variable
Diffstat (limited to 'Source/QtDialog')
-rw-r--r-- | Source/QtDialog/CMakeLists.txt | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index ce55f51..1d3c66e 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -8,15 +8,27 @@ set (QT_COMPONENTS Widgets Gui ) -# Look for Qt6 first -find_package(Qt6Widgets QUIET) -set(INSTALLED_QT_VERSION 6) -if(NOT Qt6Widgets_FOUND) - find_package(Qt5Widgets QUIET) - if(NOT Qt5Widgets_FOUND) - message(FATAL_ERROR "Could not find a valid Qt installation.") + +set(CMake_QT_MAJOR_VERSION "A" CACHE + STRING "Expected Qt major version. Valid values are A (auto-select), 5, 6.") +set(SUPPORTED_QT_VERSIONS "A" 5 6) +set_property(CACHE CMake_QT_MAJOR_VERSION PROPERTY STRINGS ${SUPPORTED_QT_VERSIONS}) +if(NOT CMake_QT_MAJOR_VERSION VERSION_EQUAL "A") + if(NOT CMake_QT_MAJOR_VERSION IN_LIST SUPPORTED_QT_VERSIONS) + message(FATAL_ERROR "Supported Qt versions are \"${SUPPORTED_QT_VERSIONS}\"." + " But CMake_QT_MAJOR_VERSION is set to ${CMake_QT_MAJOR_VERSION}.") + endif() + set(INSTALLED_QT_VERSION ${CMake_QT_MAJOR_VERSION}) +else() + find_package(Qt6Widgets QUIET) + set(INSTALLED_QT_VERSION 6) + if(NOT Qt6Widgets_FOUND) + find_package(Qt5Widgets QUIET) + if(NOT Qt5Widgets_FOUND) + message(FATAL_ERROR "Could not find a valid Qt installation.") + endif() + set(INSTALLED_QT_VERSION 5) endif() - set(INSTALLED_QT_VERSION 5) endif() find_package(Qt${INSTALLED_QT_VERSION} |