Less hacky

This commit is contained in:
Nyall Dawson 2021-03-22 12:44:38 +10:00
parent 22bd3a2e2b
commit 56ca66dd6f

View File

@ -431,48 +431,96 @@ if(WITH_CORE)
endif()
#############################################################
# search for Qt5
set(QT_MIN_VERSION 6.0.0)
# search for Qt
set (WITH_QT6 TRUE CACHE BOOL "Enable (broken, experimental) Qt6 support")
if (WITH_QT6)
set(QT_MIN_VERSION 6.0.0)
else()
set(QT_MIN_VERSION 5.12.0)
endif()
# Use Qt5SerialPort optionally for GPS
set (WITH_QT5SERIALPORT TRUE CACHE BOOL "Determines whether Qt5SerialPort should be tried for GPS positioning")
if (WITH_QT5SERIALPORT)
find_package(Qt6 COMPONENTS SerialPort REQUIRED)
if (WITH_QT6)
find_package(Qt6 COMPONENTS SerialPort REQUIRED)
else()
find_package(Qt5 COMPONENTS SerialPort REQUIRED)
endif()
# following variable is used in qgsconfig.h
set (HAVE_QT5SERIALPORT TRUE)
endif()
find_package(Qt6 COMPONENTS Core Gui Widgets Network Xml Svg Concurrent Test UiTools Sql REQUIRED)
if (WITH_QT6)
find_package(Qt6 COMPONENTS Core Gui Widgets Network Xml Svg Concurrent Test UiTools Sql REQUIRED)
else()
find_package(Qt5 COMPONENTS Core Gui Widgets Network Xml Svg Concurrent Test UiTools Sql REQUIRED)
endif()
if (NOT IOS)
find_package(Qt6 COMPONENTS PrintSupport REQUIRED)
if (WITH_QT6)
find_package(Qt6 COMPONENTS PrintSupport REQUIRED)
else()
find_package(Qt5 COMPONENTS PrintSupport REQUIRED)
endif()
else()
add_definitions(-DQT_NO_PRINTER)
endif()
find_package(Qt6 COMPONENTS Positioning)
if (WITH_QTWEBKIT)
if (WITH_QT6)
find_package(Qt6 COMPONENTS Positioning)
else()
find_package(Qt5 COMPONENTS Positioning)
endif()
if (WITH_QTWEBKIT AND NOT WITH_QT6)
find_package(Qt5WebKit REQUIRED)
find_package(Qt5WebKitWidgets REQUIRED)
endif()
if (WITH_3D)
find_package(Qt6 COMPONENTS 3DCore 3DRender 3DInput 3DLogic 3DExtras REQUIRED)
if (WITH_QT6)
find_package(Qt6 COMPONENTS 3DCore 3DRender 3DInput 3DLogic 3DExtras REQUIRED)
else()
find_package(Qt5 COMPONENTS 3DCore 3DRender 3DInput 3DLogic 3DExtras REQUIRED)
endif()
set(HAVE_3D TRUE) # used in qgsconfig.h
endif()
if (APPLE)
find_package(Qt6 COMPONENTS MacExtras REQUIRED)
if (WITH_QT6)
find_package(Qt6 COMPONENTS MacExtras REQUIRED)
else()
find_package(Qt6 COMPONENTS MacExtras REQUIRED)
endif()
endif()
# get the Qt plugins directory
get_target_property(QMAKE_EXECUTABLE Qt6::qmake LOCATION)
if (WITH_QT6)
get_target_property(QMAKE_EXECUTABLE Qt6::qmake LOCATION)
else()
get_target_property(QMAKE_EXECUTABLE Qt5::qmake LOCATION)
endif()
EXEC_PROGRAM(${QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_PLUGINS" RETURN_VALUE return_code OUTPUT_VARIABLE DEFAULT_QT_PLUGINS_DIR )
set (QT_PLUGINS_DIR ${DEFAULT_QT_PLUGINS_DIR} CACHE STRING "Path to installation directory for Qt Plugins. Defaults to Qt native plugin directory")
message(STATUS "Found Qt version: ${Qt6Core_VERSION_STRING}")
if (WITH_QT6)
message(STATUS "Found Qt version: ${Qt6Core_VERSION_STRING}")
else()
message(STATUS "Found Qt version: ${Qt5Core_VERSION_STRING}")
endif()
if (WITH_QUICK)
find_package(Qt6 COMPONENTS Qml Quick REQUIRED)
if(${CMAKE_SYSTEM_NAME} MATCHES "Android")
if (WITH_QT6)
find_package(Qt6 COMPONENTS Qml Quick REQUIRED)
if(${CMAKE_SYSTEM_NAME} MATCHES "Android")
find_package(Qt6 COMPONENTS AndroidExtras)
else()
find_package(QtQmlTools)
endif()
else()
find_package(QtQmlTools)
find_package(Qt5 COMPONENTS Qml Quick REQUIRED)
if(${CMAKE_SYSTEM_NAME} MATCHES "Android")
find_package(Qt5 COMPONENTS AndroidExtras)
else()
find_package(QtQmlTools)
endif()
endif()
# following variable is used in qgsconfig.h
@ -493,14 +541,18 @@ if(WITH_CORE)
endif()
# Password helper
find_package(QtKeychain REQUIRED)
# Master password hash and authentication encryption
find_package(QCA REQUIRED)
# Check for runtime dependency of qca-ossl plugin
# REQUIRED if unit tests are to be run from build directory
if(NOT MSVC)
include(QCAMacros)
FIND_QCAOSSL_PLUGIN_CPP(ENABLE_TESTS)
if (WITH_QT6)
# nope, not yet!
else()
find_package(QtKeychain REQUIRED)
# Master password hash and authentication encryption
find_package(QCA REQUIRED)
# Check for runtime dependency of qca-ossl plugin
# REQUIRED if unit tests are to be run from build directory
if(NOT MSVC)
include(QCAMacros)
FIND_QCAOSSL_PLUGIN_CPP(ENABLE_TESTS)
endif()
endif()
if (APPLE)