diff --git a/CMakeLists.txt b/CMakeLists.txt index f473ee4bc5..dcbdee812a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -662,23 +662,31 @@ endif() set(min_qt5_version "5.6") if(LYX_USE_QT MATCHES "AUTO") - # try qt6 first - find_package(Qt6Core CONFIG QUIET) - if (Qt6Core_FOUND) - set(LYX_USE_QT "QT6" CACHE STRING "Valid qt version" FORCE) - message(STATUS "Qt6Core_VERSION = ${Qt6Core_VERSION}") - else() - find_package(Qt5Core CONFIG QUIET) - if(Qt5Core_FOUND) - set(LYX_USE_QT "QT5" CACHE STRING "Valid qt version" FORCE) - message(STATUS "Qt5Core_VERSION = ${Qt5Core_VERSION}") - if(Qt5Core_VERSION VERSION_LESS ${min_qt5_version}) - message(FATAL_ERROR "No appropriate QT-version found") - endif() + # try qt5 first + find_package(Qt5Core CONFIG QUIET) + if(Qt5Core_FOUND) + message(STATUS "Qt5Core_VERSION = ${Qt5Core_VERSION}") + if(Qt5Core_VERSION VERSION_LESS ${min_qt5_version}) + message(STATUS "No appropriate QT-version found") + set(Qt5Core_FOUND OFF) else() - message(FATAL_ERROR "No appropriate QT-version found") + set(LYX_USE_QT "QT5" CACHE STRING "Valid qt version" FORCE) + set(Qt6Core_FOUND OFF) endif() endif() + if (NOT Qt5Core_FOUND) + foreach(_mod Core Gui Widgets Concurrent Svg) + find_package(Qt6${_mod} CONFIG QUIET) + if (NOT Qt6${_mod}_FOUND) + message(FATAL_ERROR "Not found Qt6${_mod}, aborting use of QT6") + set(Qt6Core_FOUND OFF) + break() + else() + message(STATUS "Found Qt6${_mod}") + endif() + endforeach() + set(LYX_USE_QT "QT6" CACHE STRING "Valid qt version" FORCE) + endif() endif() # When shared libs are supported enable this option