Skip to content

Commit f15c21a

Browse files
committed
Update to Qt6
- New baseline minimum platform is Ubuntu 22.04 - Qt6 requires at least 6.2 - some deprecations may be flagged on later versions (e.g. 6.8) - CMake requires at least 3.22 - Include build-tests.yml github action to validate builds on mulitple platforms - QtTest is no longer optional since it easily comes along for the ride with Qt - Replaced QStringRef in model::SubstitutionField with simple ParserState class - Removed deprecations up to Qt 6.2
1 parent f683896 commit f15c21a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+481
-229
lines changed

.github/workflows/build-tests.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# This workflow performs test builds across a diversity of supported platforms
2+
#
3+
# - ubuntu-latest - gcc
4+
# - ubuntu-latest - clang
5+
# - ubuntu-24.04 - gcc (For backwards compatablity)
6+
# - windows-latest - cl
7+
#
8+
# TODO:
9+
# - macos
10+
# - install optional dependencies for windows-latest test build
11+
12+
13+
name: Multi-Platform Build Tests
14+
15+
on:
16+
push:
17+
pull_request:
18+
branches: [ master ]
19+
20+
jobs:
21+
build:
22+
runs-on: ${{ matrix.os }}
23+
24+
strategy:
25+
fail-fast: false
26+
27+
matrix:
28+
os: [ubuntu-latest, ubuntu-22.04, windows-latest]
29+
build_type: [Release]
30+
c_compiler: [gcc, clang, cl]
31+
include:
32+
- os: ubuntu-latest
33+
c_compiler: gcc
34+
cpp_compiler: g++
35+
- os: ubuntu-latest
36+
c_compiler: clang
37+
cpp_compiler: clang++
38+
- os: ubuntu-22.04
39+
c_compiler: gcc
40+
cpp_compiler: g++
41+
- os: windows-latest
42+
c_compiler: cl
43+
cpp_compiler: cl
44+
exclude:
45+
- os: ubuntu-latest
46+
c_compiler: cl
47+
- os: ubuntu-22.04
48+
c_compiler: clang
49+
- os: ubuntu-22.04
50+
c_compiler: cl
51+
- os: windows-latest
52+
c_compiler: gcc
53+
- os: windows-latest
54+
c_compiler: clang
55+
56+
steps:
57+
- name: Checkout
58+
uses: actions/checkout@v4
59+
with:
60+
# Checkout full-depth to facilitate auto versioning
61+
fetch-depth: 0
62+
63+
- name: Install optional dependencies (Ubuntu)
64+
shell: bash
65+
if: startsWith( matrix.os, 'ubuntu-' )
66+
run: |
67+
# install packages
68+
sudo apt-get update
69+
sudo apt-get -y install xvfb
70+
sudo apt-get -y install pkgconf libqrencode-dev
71+
sudo apt-get -y install barcode
72+
# install zint-2.6.5 from source
73+
# - 2.6.5 is last version that works with glabels-qt
74+
# - currently must be done before qt installed, because of errors
75+
# trying to build qzint
76+
wget https://downloads.sourceforge.net/project/zint/zint/2.6.5/zint-2.6.5.tar.gz && tar xzf zint-2.6.5.tar.gz && ( cd zint-2.6.5 && mkdir build && cd build && cmake .. && make && sudo make install )
77+
78+
- name: Install Qt
79+
uses: jurplel/install-qt-action@v4
80+
with:
81+
version: '6.2.*'
82+
install-deps: 'true'
83+
archives: 'qtbase qtsvg qttools icu'
84+
85+
- name: Set reusable strings
86+
id: strings
87+
shell: bash
88+
run: |
89+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
90+
91+
- name: Configure CMake
92+
run: >
93+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
94+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
95+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
96+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
97+
-S ${{ github.workspace }}
98+
99+
- name: Build
100+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
101+
102+
- name: Test (Ubuntu)
103+
if: startsWith( matrix.os, 'ubuntu-' )
104+
working-directory: ${{ steps.strings.outputs.build-output-dir }}
105+
run: xvfb-run ctest --build-config ${{ matrix.build_type }}
106+
107+
- name: Test (Windows)
108+
if: startsWith( matrix.os, 'windows-' )
109+
working-directory: ${{ steps.strings.outputs.build-output-dir }}
110+
run: ctest --build-config ${{ matrix.build_type }}

CMakeLists.txt

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required (VERSION 3.9)
1+
cmake_minimum_required (VERSION 3.22)
22

33
###############################################################################
44
# gLabels Label Designer Project
@@ -111,12 +111,7 @@ if (MINGW)
111111
set (CMAKE_PREFIX_PATH ${MINGW_BASE_DIR} )
112112
endif ()
113113

114-
find_package (Qt5Core 5.15 REQUIRED)
115-
find_package (Qt5Widgets 5.15 REQUIRED)
116-
find_package (Qt5PrintSupport 5.15 REQUIRED)
117-
find_package (Qt5Xml 5.15 REQUIRED)
118-
find_package (Qt5Svg 5.15 REQUIRED)
119-
find_package (Qt5LinguistTools)
114+
find_package (Qt6 6.2 REQUIRED COMPONENTS Core Gui Widgets PrintSupport Xml Svg LinguistTools Test)
120115

121116
if (WIN32)
122117
# Locate Qt directories
@@ -131,8 +126,6 @@ find_package (ZLIB 1.2 QUIET)
131126
find_package (GnuBarcode 0.98 QUIET)
132127
find_package (LibQrencode 3.4 QUIET)
133128
find_package (LibZint 2.6 EXACT QUIET)
134-
# Unit testing support
135-
find_package (Qt5Test 5.6 QUIET)
136129

137130

138131
#=======================================
@@ -143,7 +136,7 @@ if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
143136
# Uncomment to compile everything with aggressively pedantic options
144137
# (not recommended -- only for testing -- also not portable)
145138
#
146-
#add_compile_options("-Wall" "-Werror" "-Wpedantic")
139+
#add_compile_options("-Wall" "-Wextra" "-Wpedantic" "-Wno-unused-parameter" "-Werror")
147140

148141
# Uncomment to always compile with debug symbols
149142
add_compile_options("-g")
@@ -153,7 +146,7 @@ endif ()
153146
#=======================================
154147
# Unit Testing
155148
#=======================================
156-
if (Qt5Test_FOUND)
149+
if (Qt6Test_FOUND)
157150
enable_testing ()
158151
endif ()
159152

@@ -177,11 +170,13 @@ add_subdirectory (data)
177170
message (STATUS "")
178171
message (STATUS "Project name ............ " ${CMAKE_PROJECT_NAME})
179172
message (STATUS "Project version ......... " ${LONG_VERSION_STRING})
173+
message (STATUS "Host system ............. " ${CMAKE_HOST_SYSTEM} " " ${CMAKE_HOST_SYSTEM_PROCESSOR})
174+
message (STATUS "Target system ........... " ${CMAKE_SYSTEM} " " ${CMAKE_SYSTEM_PROCESSOR})
180175
message (STATUS "Installation prefix ..... " ${CMAKE_INSTALL_PREFIX})
181176
message (STATUS "Source code location .... " ${glabels_SOURCE_DIR})
182177
message (STATUS "CMake version ........... " ${CMAKE_VERSION})
183178
message (STATUS "C++ Compiler ............ " ${CMAKE_CXX_COMPILER_ID} " " ${CMAKE_CXX_COMPILER} " " ${CMAKE_CXX_COMPILER_VERSION})
184-
message (STATUS "Qt version .............. " ${Qt5Core_VERSION})
179+
message (STATUS "Qt version .............. " ${Qt6Core_VERSION})
185180

186181
if (ZLIB_FOUND)
187182
message (STATUS "zlib (optional).......... " ${ZLIB_VERSION_STRING})
@@ -207,12 +202,6 @@ else (LIBZINT_FOUND)
207202
message (STATUS "libzint (optional)....... No.")
208203
endif (LIBZINT_FOUND)
209204

210-
if (Qt5Test_FOUND)
211-
message (STATUS "QtTest (optional)........ " ${Qt5Test_VERSION})
212-
else (Qt5Test_FOUND)
213-
message (STATUS "QtTest (optional)........ No.")
214-
endif (Qt5Test_FOUND)
215-
216205
if (MSVC)
217206
message (STATUS "MSVC Qt location ........ " ${QT_BASE_DIR})
218207
endif (MSVC)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
![Cover Image](docs/images/cover-image.png)
44

5-
[![Travis Build Status](https://travis-ci.org/j-evins/glabels-qt.svg?branch=master)](https://travis-ci.org/j-evins/glabels-qt)
6-
[![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/github/j-evins/glabels-qt?branch=master&svg=true)](https://ci.appveyor.com/project/j-evins/glabels-qt)
5+
[![Multi-Platform Build Tests](https://github.com/j-evins/glabels-qt/actions/workflows/build-tests.yml/badge.svg?branch=master&event=push)](https://github.com/j-evins/glabels-qt/actions/workflows/build-tests.yml)
76

87
*******************************************************************************
98

@@ -89,3 +88,4 @@ restrictive licensing:
8988
label database. No copyright is claimed on the facts contained within
9089
the database and can be used for any purpose. The files themselves are
9190
licensed using the MIT/X license. See [templates/LICENSE](templates/LICENSE).
91+

backends/barcode/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ set (barcode_qobject_headers
3939
Backends.h
4040
)
4141

42-
qt5_wrap_cpp (barcode_moc_sources ${barcode_qobject_headers})
42+
qt6_wrap_cpp (barcode_moc_sources ${barcode_qobject_headers})
4343

4444
#=====================================
4545
# Target
@@ -60,7 +60,7 @@ target_include_directories (Barcode
6060

6161
target_link_libraries (Barcode
6262
glbarcode
63-
Qt5::Core
63+
Qt6::Core
6464
${OPTIONAL_GNUBARCODE}
6565
${OPTIONAL_ZINT}
6666
${OPTIONAL_QRENCODE}

backends/merge/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ set (merge_qobject_headers
2323
Merge.h
2424
)
2525

26-
qt5_wrap_cpp (merge_moc_sources ${merge_qobject_headers})
26+
qt6_wrap_cpp (merge_moc_sources ${merge_qobject_headers})
2727

2828
#=====================================
2929
# Target
@@ -43,5 +43,5 @@ target_include_directories (Merge
4343
)
4444

4545
target_link_libraries (Merge
46-
Qt5::Core
46+
Qt6::Core
4747
)

cmake/Modules/FindGnuBarcode.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ endif ()
3636
if (GNUBARCODE_INCLUDE_DIR AND EXISTS "${GNUBARCODE_INCLUDE_DIR}/barcode.h")
3737
file (STRINGS "${GNUBARCODE_INCLUDE_DIR}/barcode.h" BARCODE_H REGEX "^#define BARCODE_VERSION *\"[^\"]*\"")
3838
string (REGEX REPLACE "^.*VERSION *\"([^\"]*)\"" "\\1" GNUBARCODE_VERSION_STRING "${BARCODE_H}")
39+
if (NOT "${BARCODE_H}")
40+
set(GNUBARCODE_VERSION_STRING "0.99") # ubuntu v0.99 may have barcode.h, but no version string
41+
endif()
3942
endif()
4043

4144
# handle the QUIETLY and REQUIRED arguments and set GNUBARCODE_FOUND to TRUE if

docs/BUILD-INSTRUCTIONS-LINUX.md

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ gLabels Linux Build Instructions
55
### Prerequisites
66

77
- g++
8-
- CMake 2.8.12+
9-
- Qt5 5.15+ Development Packages ( Qt5Core, Qt5Widgets, Qt5PrintSupport, Qt5Xml, Qt5Svg )
8+
- CMake 3.22+
9+
- Qt6 6.2+ Development Packages ( Qt6Core, Qt6Widgets, Qt6PrintSupport, Qt6Xml, Qt6Svg, Qt6Test )
1010
- zlib 1.2+ Development Package
1111

1212
> Even if the above library packages are installed, their corresponding development packages
@@ -26,36 +26,32 @@ $ make
2626
$ sudo make install
2727
</pre>
2828

29-
## Example: Ubuntu 19.04
29+
30+
## Example: Ubuntu 24.04
3031

3132
### Installing Prerequisites
3233
```
33-
sudo apt install cmake
34-
sudo apt install qtbase5-dev libqt5svg5-dev qttools5-dev zlib1g-dev
34+
$ sudo apt install cmake
35+
$ sudo apt install qt6-base-dev qt6-svg-dev qt6-tools-dev zlib1g-dev
3536
```
3637
_QREncode (Optional)_
3738
```
38-
sudo apt install pkgconf libqrencode-dev
39+
$ sudo apt install pkgconf libqrencode-dev
3940
```
4041
_Zint (Optional)_
4142

4243
Install zint from source:
4344
```
44-
wget https://downloads.sourceforge.net/project/zint/zint/2.6.3/zint-2.6.3_final.tar.gz
45-
tar xzf zint-2.6.3_final.tar.gz
46-
cd zint-2.6.3.src/
47-
mkdir build && cd build && cmake .. && make
48-
sudo make install
45+
$ wget https://downloads.sourceforge.net/project/zint/zint/2.6.3/zint-2.6.3_final.tar.gz
46+
$ tar xzf zint-2.6.3_final.tar.gz
47+
$ cd zint-2.6.3.src/
48+
$ mkdir build && cd build && cmake .. && make
49+
$ sudo make install
4950
```
5051
_GNU Barcode (Optional)_
5152

52-
As of version 0.99, GNU Barcode no longer installs its library. So install 0.98 from source:
5353
```
54-
wget https://ftp.gnu.org/gnu/barcode/barcode-0.98.tar.gz
55-
tar xzf barcode-0.98.tar.gz
56-
cd barcode-0.98/
57-
./configure && make
58-
sudo make install
54+
$ sudo apt install barcode
5955
```
6056
### Compile and Install gLabels
6157

@@ -67,6 +63,8 @@ $ cmake ..
6763
$ make
6864
$ sudo make install
6965
```
66+
67+
7068
## Example: Fedora 35
7169

7270
### Installing Prerequisites
@@ -76,12 +74,12 @@ We assume the build system already has things like cmake and the GNU C++ suite i
7674
$ sudo dnf install qt5-qtbase-devel qt5-qtsvg-devel qt5-linguist qt5-qttools
7775
```
7876
These installs will pull in additional packages to fill out their prerequisites.
79-
Fedora has a different package naming scheme that Ubuntu. This is to distinguish the QT5
77+
Fedora has a different package naming scheme that Ubuntu. This is to distinguish the QT6
8078
packages from the QT3 and QT4 packages that they still support for compatibility.
8179
If the Cmake pass or build has missing package errors or warnings, you can search for the needed
8280
package with:
8381
```
84-
$ sudo dnf search qt5 |grep <package name substring>
82+
$ sudo dnf search qt6 |grep <package name substring>
8583
```
8684

8785
### Compile and Install gLabels into /usr/local

docs/BUILD-INSTRUCTIONS-WINDOWS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ Visual Studio
1313
### Prerequisites
1414

1515
- Visual Studio (these instructions are for _Visual Studio 15 2017 Win64_)
16-
- CMake 3.2+
17-
- Qt5 5.9+ for your version of Visual Studio
16+
- CMake 3.22+
17+
- Qt6 6.2+ for your version of Visual Studio
1818
- NSIS 3.03+ (optional -- for creating an installer)
1919

2020
Make sure that CMake and the Qt tools are in your executable search path. For example, you may need to add something like the following to your PATH environment variable:
@@ -67,8 +67,8 @@ MSYS/MINGW
6767
- MSYS/MINGW, including the following packages
6868
+ mingw32-gcc-g++
6969
+ mingw32-libz
70-
- CMake 3.2+
71-
- Qt5 5.9+ for MINGW
70+
- CMake 3.22+
71+
- Qt6 6.2+ for MINGW
7272

7373
Make sure that Qt tools and CMake are in your executable search path. For example, add something like this to your .profile file:
7474

glabels-batch/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ int main( int argc, char **argv )
6969
// Setup translators
7070
//
7171
QLocale locale = QLocale::system();
72-
QString qtTranslationsDir = QLibraryInfo::location( QLibraryInfo::TranslationsPath );
72+
QString qtTranslationsDir = QLibraryInfo::path( QLibraryInfo::TranslationsPath );
7373
QString myTranslationsDir = glabels::model::FileUtil::translationsDir().canonicalPath();
7474

7575
QTranslator qtTranslator;

glabels/CMakeLists.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ set (glabels_resource_files
107107
images.qrc
108108
)
109109

110-
qt5_wrap_cpp (glabels_moc_sources ${glabels_qobject_headers})
111-
qt5_wrap_ui (glabels_forms_headers ${glabels_forms})
112-
qt5_add_resources (glabels_qrc_sources ${glabels_resource_files})
110+
qt6_wrap_cpp (glabels_moc_sources ${glabels_qobject_headers})
111+
qt6_wrap_ui (glabels_forms_headers ${glabels_forms})
112+
qt6_add_resources (glabels_qrc_sources ${glabels_resource_files})
113113

114114
if (WIN32)
115115
# Windows resource file
@@ -137,7 +137,7 @@ target_include_directories (glabels-qt
137137

138138
target_link_libraries (glabels-qt
139139
Model
140-
Qt5::Widgets
140+
Qt6::Widgets
141141
)
142142

143143
#=======================================
@@ -173,7 +173,6 @@ if (WIN32)
173173
env PATH="${QT_BIN_DIR}" "${WINDEPLOYQT_EXECUTABLE}"
174174
--verbose 0
175175
--no-compiler-runtime
176-
--no-angle
177176
--no-opengl-sw
178177
\"$<TARGET_FILE:glabels-qt>\"
179178
)
@@ -198,7 +197,6 @@ if (WIN32)
198197
--verbose 0
199198
--release
200199
--no-compiler-runtime
201-
--no-angle
202200
--no-opengl-sw
203201
\"$<TARGET_FILE:glabels-qt>\"
204202
)

0 commit comments

Comments
 (0)