Skip to content

Commit

Permalink
Drop Qt5 support
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Apr 5, 2024
1 parent 587604c commit 1c543f3
Show file tree
Hide file tree
Showing 31 changed files with 122 additions and 2,522 deletions.
34 changes: 5 additions & 29 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ set(APP_VERSION "0" CACHE STRING "Application Version (Example: v1.0.0)")
set(APP_VERSION_STR "local - dev" CACHE STRING "Application Version Name (Example: 1.0.0 - Homerun)")
set(APP_PACKAGE_NAME "qfield" CACHE STRING "Package name suffix. E.g. qfield --> ch.opengis.qfield")

set(BUILD_WITH_QT6 ON CACHE BOOL "Build with Qt6")

string(REGEX REPLACE "v" "" CLEAN_APP_VERSION "${APP_VERSION}")

set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
Expand Down Expand Up @@ -100,13 +98,7 @@ else()
set(WITH_SENTRY 0)
endif()

if(BUILD_WITH_QT6)
set(QT_PKG Qt6)
set(QT_MIN_VERSION 6.5.0)
else()
set(QT_PKG Qt5)
set(QT_MIN_VERSION 5.14.0)
endif()
set(QT_MIN_VERSION 6.5.0)

if (ANDROID)
if(VCPKG_TARGET_TRIPLET STREQUAL "arm-android" OR VCPKG_TARGET_TRIPLET STREQUAL "arm-neon-android")
Expand All @@ -123,24 +115,12 @@ if (ANDROID)
list(APPEND CMAKE_FIND_ROOT_PATH /)

set(ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_BINARY_DIR}/android-template)

if(NOT BUILD_WITH_QT6)
find_package(Qt5 COMPONENTS AndroidExtras REQUIRED)

include(FetchContent)
FetchContent_Declare(android_openssl
GIT_REPOSITORY https://github.com/KDAB/android_openssl.git
GIT_TAG aa3c67c59160715216e89ae2c48291d6021601fa
)
FetchContent_MakeAvailable(android_openssl)
include(${FETCHCONTENT_BASE_DIR}/android_openssl-src/CMakeLists.txt)
endif()
endif()

find_package(${QT_PKG} COMPONENTS Concurrent Core Qml Gui Xml Positioning Widgets Network Quick Svg Sql Sensors WebView Multimedia REQUIRED)
find_package(Qt6 COMPONENTS Concurrent Core Qml Gui Xml Positioning Widgets Network Quick Svg Sql Sensors WebView Multimedia REQUIRED)

if(NOT CMAKE_SYSTEM_NAME STREQUAL "iOS")
find_package(${QT_PKG} COMPONENTS PrintSupport REQUIRED)
find_package(Qt6 COMPONENTS PrintSupport REQUIRED)
endif()

find_package(QGIS COMPONENTS Core Analysis REQUIRED)
Expand Down Expand Up @@ -188,11 +168,7 @@ endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(SHARE_DIR "${CMAKE_BINARY_DIR}/output/bin/qfield.app/Contents/share")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
if (BUILD_WITH_QT6)
set(SHARE_DIR "${ANDROID_PACKAGE_SOURCE_DIR}/assets")
else()
set(SHARE_DIR "${CMAKE_BINARY_DIR}/android-build/assets/share")
endif()
set(SHARE_DIR "${ANDROID_PACKAGE_SOURCE_DIR}/assets")
else()
set(SHARE_DIR "${CMAKE_BINARY_DIR}/output/share")
endif()
Expand All @@ -210,7 +186,7 @@ if(WITH_SENTRY)
endif()

if (ENABLE_TESTS)
find_package(${QT_PKG} COMPONENTS Test QuickTest)
find_package(Qt6 COMPONENTS Test QuickTest)
enable_testing()
add_subdirectory(test)
endif()
Expand Down
21 changes: 6 additions & 15 deletions cmake/FindQca.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,12 @@ The macro sets the following variables:

#]=======================================================================]

if(BUILD_WITH_QT6)
set(Qca_INCLUDE_SUFFIXES
QtCrypto
qt6/QtCrypto
Qca-qt6/QtCrypto
qt6/Qca-qt6/QtCrypto)
set(Qca_NAMES ${Qca_NAMES} qca-qt6 qca)
else()
set(Qca_INCLUDE_SUFFIXES
QtCrypto
qt5/QtCrypto
Qca-qt5/QtCrypto
qt5/Qca-qt5/QtCrypto)
set(Qca_NAMES ${Qca_NAMES} qca-qt5 qca)
endif()
set(Qca_INCLUDE_SUFFIXES
QtCrypto
qt6/QtCrypto
Qca-qt6/QtCrypto
qt6/Qca-qt6/QtCrypto)
set(Qca_NAMES ${Qca_NAMES} qca-qt6 qca)
find_path(Qca_INCLUDE_DIR qca.h
PATHS
${Qca_ROOT}/include/
Expand Down
2 changes: 1 addition & 1 deletion cmake/Package.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if(WIN32)
list(APPEND CPACK_GENERATOR "NSIS")
endif()

get_target_property(qmake_executable ${QT_PKG}::qmake IMPORTED_LOCATION)
get_target_property(qmake_executable Qt::qmake IMPORTED_LOCATION)

set(CPACK_OUTPUT_CONFIG_FILE "${CMAKE_BINARY_DIR}/BundleConfig.cmake")

Expand Down
45 changes: 15 additions & 30 deletions cmake/qgis-cmake-wrapper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -136,42 +136,27 @@ if(TRUE) # Should possibly have a "static only" check

pkg_check_modules(freexl REQUIRED IMPORTED_TARGET freexl)
target_link_libraries(QGIS::Core INTERFACE PkgConfig::freexl)
if(BUILD_WITH_QT6)
_qgis_core_add_dependency(Qt6Keychain::Qt6Keychain Qt6Keychain)
else()
_qgis_core_add_dependency(Qt5Keychain::Qt5Keychain Qt5Keychain)
endif()
_qgis_core_add_dependency(Qt6Keychain::Qt6Keychain Qt6Keychain)

find_package(${QT_PKG} COMPONENTS Core Gui Network Xml Svg Concurrent Sql Positioning)
find_package(Qt6 COMPONENTS Core Gui Network Xml Svg Concurrent Sql Positioning Core5Compat)
target_link_libraries(QGIS::Core INTERFACE
${QT_PKG}::Gui
${QT_PKG}::Core
${QT_PKG}::Network
${QT_PKG}::Xml
${QT_PKG}::Svg
${QT_PKG}::Concurrent
${QT_PKG}::Sql
${QT_PKG}::Positioning
Qt::Gui
Qt::Core
Qt::Network
Qt::Xml
Qt::Svg
Qt::Concurrent
Qt::Sql
Qt::Positioning
Qt::Core5Compat
)
if(BUILD_WITH_QT6)
find_package(${QT_PKG} COMPONENTS Core5Compat)
target_link_libraries(QGIS::Core INTERFACE
${QT_PKG}::Core5Compat
)
endif()
if(NOT CMAKE_SYSTEM_NAME STREQUAL "iOS")
find_package(${QT_PKG} COMPONENTS SerialPort)
find_package(Qt6 COMPONENTS SerialPort)
target_link_libraries(QGIS::Core INTERFACE
${QT_PKG}::SerialPort
Qt::SerialPort
)
endif()
if(APPLE)
if(NOT BUILD_WITH_QT6)
find_package(${QT_PKG} COMPONENTS MacExtras)
target_link_libraries(QGIS::Core INTERFACE
${QT_PKG}::MacExtras
)
endif()
pkg_check_modules(libtasn1 REQUIRED IMPORTED_TARGET libtasn1)
target_link_libraries(QGIS::Core INTERFACE PkgConfig::libtasn1)

Expand All @@ -183,9 +168,9 @@ if(TRUE) # Should possibly have a "static only" check
# _find_and_link_library(lcms2 QGIS::Core)

# QtKeychain
find_package(${QT_PKG} COMPONENTS DBus REQUIRED)
find_package(Qt6 COMPONENTS DBus REQUIRED)
target_link_libraries(QGIS::Core INTERFACE
${QT_PKG}::DBus
Qt::DBus
)
endif()
target_link_libraries(QGIS::Analysis INTERFACE QGIS::Core)
Expand Down
5 changes: 1 addition & 4 deletions doc/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ sudo apt install libqt5sensors5-dev libqt5webview5-dev libqt5multimedia5-plugins

### Configure
```sh
# Building for Qt6 is the standard, but currently no
# distributions ship Qt 6.5.0
# To be updated
cmake -S QField -B build -D BUILD_WITH_QT6=OFF
cmake -S QField -B build
```

If you use a locally built QGIS installed to a different
Expand Down
78 changes: 32 additions & 46 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
find_package(${QT_PKG}QuickCompiler QUIET)
find_package(Qt6QuickCompiler QUIET)

if(MSVC)
configure_file("${CMAKE_SOURCE_DIR}/platform/windows/appicon.rc.in"
Expand All @@ -14,16 +14,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
endif()

# lrelease .ts files
find_package(${QT_PKG} COMPONENTS LinguistTools)
find_package(Qt6 COMPONENTS LinguistTools)

file(GLOB TS_FILES ${CMAKE_SOURCE_DIR}/i18n/*.ts)
set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION
"${CMAKE_BINARY_DIR}")
if(BUILD_WITH_QT6)
qt_add_translation(QM_FILES ${TS_FILES})
else()
qt5_add_translation(QM_FILES ${TS_FILES})
endif()
qt_add_translation(QM_FILES ${TS_FILES})

# include manually copied .qm files
file(GLOB QM_FILES_MANUAL ${CMAKE_SOURCE_DIR}/i18n/*.qm)
Expand All @@ -42,12 +38,10 @@ file(APPEND ${TRANSLATIONS_QRC} "\n </qresource>\n</RCC>")
configure_file(${CMAKE_SOURCE_DIR}/images/logo.qrc.in
${CMAKE_BINARY_DIR}/images/logo.qrc @ONLY)

if(BUILD_WITH_QT6)
find_package(
Qt6
COMPONENTS Core5Compat
REQUIRED)
endif()
find_package(
Qt6
COMPONENTS Core5Compat
REQUIRED)

function(create_executable)
cmake_parse_arguments(exe "" "TARGET" "EXTRA_ARGS" "" ${ARGN})
Expand All @@ -62,19 +56,15 @@ function(create_executable)
${TRANSLATIONS_QRC})

if(ANDROID)
if(BUILD_WITH_QT6)
qt_add_executable(${exe_TARGET} ${QFIELD_SOURCES})
set_property(TARGET ${exe_TARGET} PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
${ANDROID_PACKAGE_SOURCE_DIR})
set_property(TARGET ${exe_TARGET} PROPERTY QT_QML_IMPORT_PATH
$ENV{Qt6_DIR}/qml)
set_property(TARGET ${exe_TARGET} PROPERTY QT_QML_ROOT_PATH
${CMAKE_SOURCE_DIR}/src/qml)

set(PROJECT_NAME ${exe_TARGET})
else()
add_library(${exe_TARGET} SHARED ${QFIELD_SOURCES})
endif()
qt_add_executable(${exe_TARGET} ${QFIELD_SOURCES})
set_property(TARGET ${exe_TARGET} PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
${ANDROID_PACKAGE_SOURCE_DIR})
set_property(TARGET ${exe_TARGET} PROPERTY QT_QML_IMPORT_PATH
$ENV{Qt6_DIR}/qml)
set_property(TARGET ${exe_TARGET} PROPERTY QT_QML_ROOT_PATH
${CMAKE_SOURCE_DIR}/src/qml)

set(PROJECT_NAME ${exe_TARGET})
else()
add_executable(${exe_TARGET} ${exe_EXTRA_ARGS} ${QFIELD_SOURCES})
endif()
Expand All @@ -89,12 +79,12 @@ function(create_executable)
target_link_libraries(${exe_TARGET} PRIVATE qfield_sentry)
endif()

get_target_property(QT_TARGET_TYPE ${QT_PKG}::Core TYPE)
get_target_property(QT_TARGET_TYPE Qt::Core TYPE)
# This should be in src/qml/CMakeLists.txt but that's not possible with Qt5.
# Retry with Qt6 Same is in tests/CMakeLists.txt
# https://bugreports.qt.io/browse/QTBUG-80847
if(${QT_TARGET_TYPE} STREQUAL "STATIC_LIBRARY")
find_package(${QT_PKG} COMPONENTS QmlImportScanner)
find_package(Qt6 COMPONENTS QmlImportScanner)

get_target_property(qfield_qmlfiles qfield_qml QML_FILES)
file(COPY ${qfield_qmlfiles}
Expand All @@ -113,24 +103,20 @@ function(create_executable)
qt_import_qml_plugins(${exe_TARGET} PATH_TO_SCAN
"${CMAKE_CURRENT_BINARY_DIR}/qmldrop/app")
endif()
if(BUILD_WITH_QT6)
target_link_libraries(${exe_TARGET} PUBLIC Qt6::Core5Compat)
qt_import_plugins(${exe_TARGET} INCLUDE ${QT_PKG}::QSvgPlugin)
qt_import_plugins(${exe_TARGET} INCLUDE ${QT_PKG}::Core5Compat)

if(IOS)
target_link_libraries(
${exe_TARGET}
PUBLIC ${QT_PKG}::QDarwinCameraPermissionPlugin
${QT_PKG}::QDarwinMicrophonePermissionPlugin
${QT_PKG}::QDarwinLocationPermissionPlugin)
qt_import_plugins(
${exe_TARGET} INCLUDE ${QT_PKG}::QDarwinCameraPermissionPlugin
${QT_PKG}::QDarwinMicrophonePermissionPlugin
${QT_PKG}::QDarwinLocationPermissionPlugin)
endif()
else()
qt5_import_plugins(${exe_TARGET} INCLUDE ${QT_PKG}::QSvgPlugin)
target_link_libraries(${exe_TARGET} PUBLIC Qt::Core5Compat)
qt_import_plugins(${exe_TARGET} INCLUDE Qt::QSvgPlugin)
qt_import_plugins(${exe_TARGET} INCLUDE Qt::Core5Compat)

if(IOS)
target_link_libraries(
${exe_TARGET}
PUBLIC Qt6::QDarwinCameraPermissionPlugin
Qt6::QDarwinMicrophonePermissionPlugin
Qt6::QDarwinLocationPermissionPlugin)
qt_import_plugins(
${exe_TARGET} INCLUDE Qt6::QDarwinCameraPermissionPlugin
Qt6::QDarwinMicrophonePermissionPlugin
Qt6::QDarwinLocationPermissionPlugin)
endif()

if(WITH_VCPKG) # this triggers the initialisation of static qca ossl plugin.
Expand Down
5 changes: 0 additions & 5 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@ int main( int argc, char **argv )
#endif

Q_INIT_RESOURCE( qml );
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
Q_INIT_RESOURCE( qmlqt6 );
#else
Q_INIT_RESOURCE( qmlqt5 );
#endif

QtWebView::initialize();

Expand Down
Loading

0 comments on commit 1c543f3

Please sign in to comment.