Skip to content

Commit

Permalink
Move floor to Qt 6.2 (#1272)
Browse files Browse the repository at this point in the history
* move floor from Qt 5.15 to 6.2.

* fix some CI failures

* try harder to fix coverage build

* try to fix coverage again

* try agin

* move up msvc tools minimum for Qt6

* clean up clazy warnings with Qt6.

* drop redundnant CI job

* revert translation related unintentionl changes

* simplify find qt packages

* assume Qt6 in textstream

* move CI tidy to noble

* assume Qt6 in textstream.h

* remove obsolete makesetup.bat

* remove Qt5 support from coretool

* strip Qt5 from noble image

* update default qt versions.

* update minimum cmake version to match Qt 6.2.4 QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_USING_QT

* assume QHash result is type size_t

* remove unnecessary qOverloads (in Qt6).
  • Loading branch information
tsteven4 authored May 4, 2024
1 parent 2d6e12d commit 06351ff
Show file tree
Hide file tree
Showing 29 changed files with 81 additions and 303 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codacy-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
fail-fast: false
matrix:
include:
- IMAGE: 'jammy'
CMAKE_PREFIX_PATH: '/usr/lib/x86_64-linux-gnu/cmake/Qt5'
- IMAGE: 'noble'
CMAKE_PREFIX_PATH: '/usr/lib/x86_64-linux-gnu/cmake/Qt6'
SCRIPT: './tools/ci_run_tidy.sh'
container:
image: gpsbabel-docker.jfrog.io/tsteven4/gpsbabel_build_environment_${{ matrix.IMAGE }}
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/fedora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,12 @@ jobs:
fail-fast: false
matrix:
include:
- IMAGE: '35'
CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt5'
- IMAGE: '37'
CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt5'
- IMAGE: '37'
CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt6'
- IMAGE: '38'
CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt5'
- IMAGE: '38'
CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt6'
- IMAGE: '39'
CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt5'
- IMAGE: '39'
CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt6'
- IMAGE: '40'
CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt5'
- IMAGE: '40'
CMAKE_PREFIX_PATH: '/usr/lib64/cmake/Qt6'
container:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fail-fast: false
matrix:
include:
- QT_VERSION: '5.15.2'
- QT_VERSION: '6.2.4'
XCODE_VERSION: '13.4.1'
GENERATOR: 'Ninja'
RELEASE: false
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ jobs:
# focal has Qt 5.12, end of standard support 4/2025, end of life 4/2030.
#- IMAGE: 'focal'
# SCRIPT: './tools/build_and_test_cmake.sh'
- IMAGE: 'jammy'
CMAKE_PREFIX_PATH: '/usr/lib/x86_64-linux-gnu/cmake/Qt5'
SCRIPT: './tools/build_and_test_cmake.sh'
- IMAGE: 'jammy'
CMAKE_PREFIX_PATH: '/usr/lib/x86_64-linux-gnu/cmake/Qt6'
SCRIPT: './tools/build_and_test_cmake.sh'
Expand All @@ -39,7 +36,7 @@ jobs:
SCRIPT: './tools/build_and_test_cmake.sh'
TOOLS: 'clang'
- IMAGE: 'jammy'
CMAKE_PREFIX_PATH: '/usr/lib/x86_64-linux-gnu/cmake/Qt5'
CMAKE_PREFIX_PATH: '/usr/lib/x86_64-linux-gnu/cmake/Qt6'
SCRIPT: './tools/build_extra_tests.sh'
container:
image: gpsbabel-docker.jfrog.io/tsteven4/gpsbabel_build_environment_${{ matrix.IMAGE }}
Expand Down Expand Up @@ -76,7 +73,7 @@ jobs:
- name: install
run: |
sudo apt-get update
sudo apt-get install gcovr lcov libusb-1.0-0-dev qtbase5-dev qtwebengine5-dev libqt5serialport5-dev ninja-build
sudo apt-get install gcovr lcov libusb-1.0-0-dev libgl-dev qt6-base-dev libqt6core5compat6-dev libqt6serialport6-dev qt6-webengine-dev qt6-webengine-dev-tools ninja-build
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
26 changes: 1 addition & 25 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,11 @@ jobs:
fail-fast: false
matrix:
include:
- QT_VERSION: '5.15.2'
ARCH: 'amd64'
HOST_ARCH: 'amd64'
COMPILER: 'msvc2019_64'
METHOD: 'aqt'
GENERATOR: 'Visual Studio 16 2019'
RELEASE: false
os: windows-2019
- QT_VERSION: '5.15.2'
ARCH: 'amd64'
HOST_ARCH: 'amd64'
COMPILER: 'msvc2019_64'
TOOLSET: 'v141,version=14.16.27023'
METHOD: 'aqt'
GENERATOR: 'Visual Studio 16 2019'
RELEASE: false
os: windows-2019
- QT_VERSION: '5.15.2'
ARCH: 'x86'
HOST_ARCH: 'amd64'
COMPILER: 'msvc2019'
METHOD: 'aqt'
GENERATOR: 'Visual Studio 16 2019'
RELEASE: false
os: windows-2019
- QT_VERSION: '6.2.4'
ARCH: 'amd64'
HOST_ARCH: 'amd64'
COMPILER: 'msvc2019_64'
TOOLSET: 'v142,version=14.29.30133'
METHOD: 'aqt'
GENERATOR: 'Visual Studio 16 2019'
RELEASE: false
Expand Down
29 changes: 9 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.11)
cmake_minimum_required(VERSION 3.16)

include(CMakeDependentOption)
include(CheckIncludeFile)
Expand Down Expand Up @@ -26,17 +26,12 @@ set(CMAKE_AUTORCC ON)
add_executable(gpsbabel)

# Find the QtCore library
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
list(APPEND QT_LIBRARIES Qt${QT_VERSION_MAJOR}::Core)
if(${Qt${QT_VERSION_MAJOR}Core_VERSION} VERSION_LESS 5.15)
message(FATAL_ERROR "Qt version ${Qt${QT_VERSION_MAJOR}Core_VERSION} found, but version 5.15 or newer is required.")
find_package(Qt6 REQUIRED COMPONENTS Core Core5Compat)
list(APPEND QT_LIBRARIES Qt6::Core Qt6::Core5Compat)
if(${Qt6Core_VERSION} VERSION_LESS 6.2)
message(FATAL_ERROR "Qt version ${Qt6Core_VERSION} found, but version 6.2 or newer is required.")
else()
message(STATUS "Using Qt${QT_VERSION_MAJOR} version ${Qt${QT_VERSION_MAJOR}Core_VERSION}")
endif()
if(${QT_VERSION_MAJOR} EQUAL "6")
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core5Compat REQUIRED)
list(APPEND QT_LIBRARIES Qt${QT_VERSION_MAJOR}::Core5Compat)
message(STATUS "Using Qt6 version ${Qt6Core_VERSION}")
endif()

option(GPSBABEL_ENABLE_PCH "enable precompiled headers." ON)
Expand Down Expand Up @@ -174,6 +169,7 @@ set(SUPPORT
rgbcolors.cc
route.cc
session.cc
src/core/codecdevice.cc
src/core/logging.cc
src/core/nvector.cc
src/core/textstream.cc
Expand All @@ -187,9 +183,6 @@ set(SUPPORT
waypt.cc
xmlgeneric.cc
)
if(${QT_VERSION_MAJOR} EQUAL "6")
set(SUPPORT ${SUPPORT} src/core/codecdevice.cc)
endif()

# HEADERS
set(HEADERS
Expand Down Expand Up @@ -267,6 +260,7 @@ set(HEADERS
jeeps/gpsusbcommon.h
jeeps/gpsusbint.h
jeeps/gpsutil.h
src/core/codecdevice.h
src/core/datetime.h
src/core/file.h
src/core/logging.h
Expand All @@ -277,9 +271,6 @@ set(HEADERS
src/core/xmlstreamwriter.h
src/core/xmltag.h
)
if(${QT_VERSION_MAJOR} EQUAL "6")
set(HEADERS ${HEADERS} src/core/codecdevice.h)
endif()

string(REPLACE .cc .h FILTER_HEADERS "${FILTERS}")
set(HEADERS ${HEADERS} ${FILTER_HEADERS})
Expand All @@ -292,9 +283,7 @@ endif()

if(WIN32)
target_compile_definitions(gpsbabel PRIVATE __WIN32__)
if(${QT_VERSION_MAJOR} EQUAL "6")
qt_disable_unicode_defines(gpsbabel)
endif()
qt_disable_unicode_defines(gpsbabel)
if(CMAKE_BUILD_TYPE STREQUAL Debug)
target_compile_definitions(gpsbabel PRIVATE _DEBUG)
endif()
Expand Down
3 changes: 1 addition & 2 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,5 @@ On non-macOS unix builds by default we now compile in the gpsbabel generated
translation files, i.e. gpsbabelfe_*.qm, gpsbabel_*.qm, as well as
gmapbase.html. When compiled in these files do not need to be distributed.
These are used by the GUI. Additional translation files from Qt will also be
used if they are found. They may be in a package such as qttranslations5-l10n
or qt5-qttranslations.
used if they are found. They may be in a package such as qt6-translations-l10n.

13 changes: 5 additions & 8 deletions csv_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@
*/

#include <cassert> // for assert
#include <cmath> // for fabs
#include <cstdlib> // for strtod
#include <cstring> // for strlen, strchr, strncmp, strcmp, memmove, strcpy, strcspn, strncpy

#include <QByteArray> // for QByteArray
#include <QChar> // for QChar
#include <QDebug> // for QDebug
#include <QRegularExpression> // for QRegularExpression
#include <QList> // for QList
#include <QString> // for QString, operator+

#include "defs.h"
Expand All @@ -49,12 +48,10 @@ csv_stringclean(const QString& source, const QString& to_nuke)
{
QString r = source;
if (!to_nuke.isEmpty()) {
// avoid problematic regular rexpressions, e.g. xmapwpt generated [:\n:],
// or one can imagine [0-9] when we meant the characters, '0', '-', and '9',
// or one can imagine [^a] when we meant the characters '^' and 'a'.
QRegularExpression regex = QRegularExpression(QStringLiteral("[%1]").arg(QRegularExpression::escape(to_nuke)));
assert(regex.isValid());
r.remove(regex);
auto isNukeable = [&to_nuke](const QChar &ch)->bool {
return to_nuke.contains(ch);
};
r.removeIf(isNukeable);
}
return r;
}
Expand Down
6 changes: 0 additions & 6 deletions defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1022,10 +1022,4 @@ int color_to_bbggrr(const char* cname);
constexpr double unknown_alt = -99999999.0;
constexpr int unknown_color = -1;

#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
using qhash_result_t = uint;
#else
using qhash_result_t = size_t;
#endif

#endif // DEFS_H_INCLUDED_
19 changes: 2 additions & 17 deletions gdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <QString> // for QString
#include <QStringView> // for QStringView
#include <QVector> // for QVector
#include <QtGlobal> // for QT_VERSION, QT_VERSION_CHECK

#include "defs.h" // for arglist_t, Waypoint, route_head, ARGTYPE_BOOL, ARGTYPE_INT, ARG_NOMINMAX, bounds, FF_CAP_RW_ALL, ff_cap, ff_type, ff_type_file
#include "format.h" // for Format
Expand Down Expand Up @@ -74,23 +73,9 @@ class GdbFormat : public Format
public:
WptNamePosnKey(const QString& name, double lt, double ln) : shortname(name), lat(lt), lon(ln) {}

friend qhash_result_t qHash(const WptNamePosnKey &c, qhash_result_t seed = 0) noexcept
friend size_t qHash(const WptNamePosnKey &c, size_t seed = 0) noexcept
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
return qHashMulti(seed, c.shortname.toUpper(), c.lat, c.lon);
#else
/*
* As noted in above refeference
* QtPrivate::QHashCombine is private API, but does not require any special buildsystem magic;
* it’s in <qhashfunctions.h>, a public header.
*/
QtPrivate::QHashCombine hash;

seed = hash(seed, c.shortname.toUpper());
seed = hash(seed, c.lat);
seed = hash(seed, c.lon);
return seed;
#endif
}

QString shortname;
Expand All @@ -104,7 +89,7 @@ class GdbFormat : public Format
public:
WptNameKey(const QString& name) : shortname(name) {} /* converting constructor */

friend qhash_result_t qHash(const WptNameKey &c, qhash_result_t seed = 0) noexcept
friend size_t qHash(const WptNameKey &c, size_t seed = 0) noexcept
{
return qHash(c.shortname.toUpper(), seed);
}
Expand Down
31 changes: 15 additions & 16 deletions gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,18 @@ if(NOT UNIX OR APPLE)
endif()

# Find the QtCore library
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Network SerialPort Widgets Xml REQUIRED)
list(APPEND QT_LIBRARIES Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::SerialPort Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Xml)
if(${Qt${QT_VERSION_MAJOR}Core_VERSION} VERSION_LESS 5.15)
message(FATAL_ERROR "Qt version ${Qt${QT_VERSION_MAJOR}Core_VERSION} found, but version 5.15 or newer is required.")
find_package(Qt6 REQUIRED COMPONENTS Core Gui Network SerialPort Widgets Xml)
list(APPEND QT_LIBRARIES Qt6::Core Qt6::Gui Qt6::Network Qt6::SerialPort Qt6::Widgets Qt6::Xml)
if(${Qt6Core_VERSION} VERSION_LESS 6.2)
message(FATAL_ERROR "Qt version ${Qt6Core_VERSION} found, but version 6.2 or newer is required.")
else()
message(STATUS "Using Qt${QT_VERSION_MAJOR} version ${Qt${QT_VERSION_MAJOR}Core_VERSION}")
message(STATUS "Using Qt6 version ${Qt6Core_VERSION}")
endif()

option(GPSBABEL_MAPPREVIEW "enable map preview." ON)
if (GPSBABEL_MAPPREVIEW)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS WebEngineWidgets WebChannel REQUIRED)
list(APPEND QT_LIBRARIES Qt${QT_VERSION_MAJOR}::WebEngineWidgets Qt${QT_VERSION_MAJOR}::WebChannel)
find_package(Qt6 REQUIRED COMPONENTS WebEngineWidgets WebChannel)
list(APPEND QT_LIBRARIES Qt6::WebEngineWidgets Qt6::WebChannel)
else()
target_compile_definitions(gpsbabelfe PRIVATE DISABLE_MAPPREVIEW)
endif()
Expand Down Expand Up @@ -173,9 +172,9 @@ message(STATUS "Libs are: \"${LnkLibs}\"")
get_target_property(IncDirs gpsbabelfe INCLUDE_DIRECTORIES)
message(STATUS "Include Directores are: \"${IncDirs}\"")

find_package(Qt${QT_VERSION_MAJOR} QUIET COMPONENTS LinguistTools)
if (NOT Qt${QT_VERSION_MAJOR}LinguistTools_FOUND)
message(WARNING "Qt${QT_VERSION_MAJOR}LinguistTools not found, gpsbabelfe translations cannot be updated or released, and application cannot be packaged.")
find_package(Qt6 QUIET COMPONENTS LinguistTools)
if (NOT Qt6LinguistTools_FOUND)
message(WARNING "Qt6LinguistTools not found, gpsbabelfe translations cannot be updated or released, and application cannot be packaged.")
else()
# FIXME: translations updated and released in source directory (and under version control).
list(APPEND TRANSLATIONS gpsbabelfe_de.ts)
Expand All @@ -186,27 +185,27 @@ else()
list(APPEND TRANSLATIONS gpsbabelfe_ru.ts)

add_custom_target(gpsbabelfe_lupdate
COMMAND Qt${QT_VERSION_MAJOR}::lupdate ${SOURCES} ${FORMS} -ts ${TRANSLATIONS}
COMMAND Qt6::lupdate ${SOURCES} ${FORMS} -ts ${TRANSLATIONS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM
USES_TERMINAL)
add_custom_target(gpsbabelfe_lrelease
COMMAND Qt${QT_VERSION_MAJOR}::lrelease ${TRANSLATIONS}
COMMAND Qt6::lrelease ${TRANSLATIONS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS gpsbabelfe_lupdate
VERBATIM
USES_TERMINAL)

if(APPLE)
get_target_property(_qmake_executable Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION)
get_target_property(_qmake_executable Qt6::qmake IMPORTED_LOCATION)
add_custom_target(package_app
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/package_app -a $<TARGET_BUNDLE_DIR:gpsbabelfe> -q ${_qmake_executable} -g $<TARGET_FILE:gpsbabel> -s ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_BUNDLE_DIR:gpsbabelfe>/../GPSBabelFE.dmg ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS gpsbabelfe gpsbabel gpsbabelfe_lrelease coretool_lrelease
VERBATIM
USES_TERMINAL)
elseif(UNIX)
get_target_property(_qmake_executable Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION)
get_target_property(_qmake_executable Qt6::qmake IMPORTED_LOCATION)
add_custom_target(package_app
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/package_app -a $<TARGET_FILE_DIR:gpsbabelfe> -q ${_qmake_executable} -g $<TARGET_FILE:gpsbabel> -s ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS gpsbabelfe gpsbabel gpsbabelfe_lrelease coretool_lrelease
Expand All @@ -220,7 +219,7 @@ else()
endif()

# in 5.12.12 cmake doesn't know about windeployqt, look in directory that has qmake.
get_target_property(_qmake_executable Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION)
get_target_property(_qmake_executable Qt6::qmake IMPORTED_LOCATION)
get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY)
find_program(WINDEPLOYQT NAMES windeployqt PATHS "${_qt_bin_dir}" NO_DEFAULT_PATH)
if (WINDEPLOYQT STREQUAL "WINDEPLOYQT-NOTFOUND")
Expand Down
Loading

0 comments on commit 06351ff

Please sign in to comment.