Cmake build: Try to figure out at configure time which qt version to use

Selecting -DLYX_USE_QT=AUTO (which is the default now) will try
to figure out which QT-version to use.

The qt4 version will be used if it is installed and the installed qt5-version is <= 5.6
Otherwise use qt5 if it is installed.
This commit is contained in:
Kornel Benko 2017-05-02 14:12:41 +02:00
parent c4c989b9c8
commit ba0492faee

View File

@ -133,7 +133,7 @@ LYX_OPTION(ENABLE_URLTESTS "Enable for URL tests" OFF ALL)
LYX_OPTION(ENABLE_EXPORT_TESTS "Enable for export tests" OFF ALL) LYX_OPTION(ENABLE_EXPORT_TESTS "Enable for export tests" OFF ALL)
LYX_OPTION(ENABLE_KEYTESTS "Enable for keytests" OFF ALL) LYX_OPTION(ENABLE_KEYTESTS "Enable for keytests" OFF ALL)
LYX_OPTION(ASAN "Use address sanitizer" OFF ALL) LYX_OPTION(ASAN "Use address sanitizer" OFF ALL)
LYX_COMBO(USE_QT "Use Qt version as frontend" QT4 QT5) LYX_COMBO(USE_QT "Use Qt version as frontend" AUTO QT4 QT5)
#LYX_OPTION(3RDPARTY_BUILD "Build 3rdparty libs" OFF ALL) #LYX_OPTION(3RDPARTY_BUILD "Build 3rdparty libs" OFF ALL)
LYX_OPTION(EXTERNAL_Z "OFF := Build 3rdparty lib zlib" ON ALL) LYX_OPTION(EXTERNAL_Z "OFF := Build 3rdparty lib zlib" ON ALL)
LYX_OPTION(EXTERNAL_ICONV "OFF := Build 3rdparty lib iconvlib" ON ALL) LYX_OPTION(EXTERNAL_ICONV "OFF := Build 3rdparty lib iconvlib" ON ALL)
@ -614,6 +614,23 @@ if(LYX_XMINGW)
list(APPEND CMAKE_FIND_ROOT_PATH ${GNUWIN32_DIR}) list(APPEND CMAKE_FIND_ROOT_PATH ${GNUWIN32_DIR})
endif() endif()
set(min_qt5_version "5.6")
if(LYX_USE_QT MATCHES "AUTO")
# try qt5 first
find_package(Qt5Core 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})
find_package(Qt4 "4.5.0" QUIET)
if(QT4_FOUND)
set(LYX_USE_QT "QT4" CACHE STRING "Valid qt version" FORCE)
endif()
endif()
else()
set(LYX_USE_QT "QT4" CACHE STRING "Valid qt version" FORCE)
endif()
endif()
if(LYX_USE_QT MATCHES "QT5") if(LYX_USE_QT MATCHES "QT5")
# set QPA_XCB if QT uses X11 # set QPA_XCB if QT uses X11
find_package(Qt5Core REQUIRED) find_package(Qt5Core REQUIRED)
@ -625,10 +642,10 @@ if(LYX_USE_QT MATCHES "QT5")
find_package(Qt5X11Extras QUIET) find_package(Qt5X11Extras QUIET)
find_package(Qt5WinExtras QUIET) find_package(Qt5WinExtras QUIET)
set(QTVERSION ${Qt5Core_VERSION}) set(QTVERSION ${Qt5Core_VERSION})
if (QTVERSION VERSION_LESS "5.4") if (QTVERSION VERSION_LESS ${min_qt5_version})
message(STATUS "QTVERSION = \"${QTVERSION}\"") message(STATUS "QTVERSION = \"${QTVERSION}\"")
message(STATUS "This version is not recommended, try either option -DLYX_USE_QT=QT4 or") message(STATUS "This version is not recommended, try either option -DLYX_USE_QT=QT4 or")
message(STATUS "install QT-Version >= \"5.4\"") message(STATUS "install QT-Version >= \"${min_qt5_version}\"")
# see thread in lyx-devel list # see thread in lyx-devel list
# From: Jean-Pierre Chrétien <jeanpierre.chretien@free.fr> # From: Jean-Pierre Chrétien <jeanpierre.chretien@free.fr>
# Date 11.03.2017 # Date 11.03.2017