Skip to content

Commit 3ef249a

Browse files
zty199BLumia
authored andcommitted
feat: add support for Qt6
use both Qt6 and Qt5 to compile, generate gio-qt6 for Qt6 Log: add support for Qt6
1 parent 779ec19 commit 3ef249a

13 files changed

Lines changed: 183 additions & 62 deletions

File tree

.gitignore

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,64 @@
1-
# User
2-
*.user
1+
# C++ objects and libs
2+
*.slo
3+
*.lo
4+
*.o
5+
*.a
6+
*.la
7+
*.lai
8+
*.so
9+
*.so.*
10+
*.dll
11+
*.dylib
312

4-
# Build directory
5-
build/
13+
# Qt-es
14+
object_script.*.Release
15+
object_script.*.Debug
16+
*_plugin_import.cpp
17+
/.qmake.cache
18+
/.qmake.stash
19+
*.pro.user
20+
*.pro.user.*
21+
*.qbs.user
22+
*.qbs.user.*
23+
*.moc
24+
moc_*.cpp
25+
moc_*.h
26+
qrc_*.cpp
27+
ui_*.h
28+
*.qmlc
29+
*.jsc
30+
Makefile*
31+
*build-*
32+
*.qm
33+
*.prl
34+
35+
# Qt unit tests
36+
target_wrapper.*
37+
38+
# QtCreator
39+
*.autosave
40+
41+
# QtCreator Qml
42+
*.qmlproject.user
43+
*.qmlproject.user.*
44+
45+
# QtCreator CMake
46+
CMakeLists.txt.user*
47+
48+
# QtCreator 4.8< compilation database
49+
compile_commands.json
50+
51+
# QtCreator local machine specific files for imported projects
52+
*creator.user*
53+
54+
*_qmlcache.qrc
55+
56+
# debian
57+
debian/*debhelper*
58+
debian/files
59+
debian/libgio-qt/
60+
debian/libgio-qt-dev/
61+
debian/libgio-qt-doc/
62+
debian/tmp/
63+
debian/*.substvars
64+
obj-*

CMakeLists.txt

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
project(gio-qt)
2-
31
cmake_minimum_required(VERSION 3.12.4)
42

3+
project(gio-qt)
4+
55
option(BUILD_TESTS "Build tests" OFF)
66
option(BUILD_UTILS "Build utilities" ON)
77
option(BUILD_DOCS "Build documentation" ON)
@@ -29,17 +29,9 @@ endif ()
2929

3030
include(GNUInstallDirs)
3131

32-
# Find the QtWidgets library
33-
find_package(Qt5 ${QT_MINIMUM_VERSION} CONFIG REQUIRED Core)
34-
find_package(PkgConfig REQUIRED)
35-
find_package(Doxygen)
36-
37-
pkg_check_modules(GIOMM giomm-2.4) # look into FindPkgConfig.cmake
38-
39-
add_subdirectory (gio-qt)
32+
add_subdirectory(gio-qt)
4033

4134
if (BUILD_TESTS)
42-
find_package(Qt5 ${QT_MINIMUM_VERSION} CONFIG REQUIRED Test)
4335
add_subdirectory(test)
4436
endif ()
4537

@@ -48,6 +40,7 @@ if (BUILD_UTILS)
4840
endif ()
4941

5042
if (BUILD_DOCS)
43+
find_package(Doxygen)
5144
if (NOT DOXYGEN_FOUND)
5245
message(FATAL_ERROR "Doxygen is required to build the documentation.")
5346
endif ()
@@ -70,7 +63,6 @@ if (BUILD_DOCS)
7063
)
7164

7265
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/docs/gio-qt.qch DESTINATION share/qt5/doc)
73-
7466
else ()
7567
message (STATUS "")
7668
message (STATUS "To build docs, please use -DBUILD_DOCS=Yes")

debian/compat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9
1+
11

debian/control

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ Section: libs
33
Priority: optional
44
Maintainer: Gary Wang <wzc782970009@gmail.com>
55
Build-Depends:
6-
debhelper (>= 9),
6+
debhelper (>= 11),
77
cmake,
88
pkg-config,
99
qtbase5-dev,
10-
qt5-qmake,
10+
qttools5-dev-tools,
11+
qt6-base-dev,
12+
qt6-tools-dev-tools,
1113
libglibmm-2.4-dev,
12-
doxygen,
13-
qttools5-dev-tools
14+
doxygen
1415
Standards-Version: 3.9.8
1516
Homepage: https://github.com/linuxdeepin/gio-qt
1617

@@ -20,18 +21,18 @@ Conflicts: libgio-qt0
2021
Replaces: libgio-qt0
2122
Depends: ${shlibs:Depends}, ${misc:Depends}, libglibmm-2.4-1v5
2223
Description: Gio wrapper for Qt.
23-
A convenient way to bind gio with Qt5.
24+
A convenient way to bind gio with either Qt5 or Qt6.
2425

2526
Package: libgio-qt-dev
2627
Architecture: any
2728
Section: libdevel
2829
Depends: libgio-qt, ${misc:Depends}, libglibmm-2.4-dev
2930
Description: Development package for libgio-qt.
30-
A convenient way to bind gio with Qt5.
31+
A convenient way to bind gio with either Qt5 or Qt6.
3132

3233
Package: libgio-qt-doc
3334
Architecture: any
3435
Section: doc
3536
Depends: ${misc:Depends}
3637
Description: Gio wrapper for Qt (documentation)
37-
A convenient way to bind gio with Qt5.
38+
A convenient way to bind gio with either Qt5 or Qt6.

gio-qt/CMakeLists.txt

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Populate a CMake variable with the sources
22
# TODO: portable headers?
33

4-
configure_file ("gio-qt.pc.in" "gio-qt.pc" @ONLY)
4+
find_package(PkgConfig REQUIRED)
5+
6+
pkg_check_modules(GIOMM giomm-2.4) # look into FindPkgConfig.cmake
57

68
set (QGIO_PUBLIC_HEADER_FILES
79
include/dglibutils.h
@@ -34,40 +36,9 @@ set (QGIO_PRIVATE_CPP_FILES
3436
private/dgiohelper.cpp
3537
)
3638

37-
# Library
38-
add_library (gio-qt SHARED
39-
${QGIO_PUBLIC_HEADER_FILES}
40-
${QGIO_PRIVATE_HEADER_FILES}
41-
${QGIO_PRIVATE_CPP_FILES}
42-
)
43-
44-
set_target_properties(
45-
gio-qt PROPERTIES
46-
VERSION ${PROJECT_VERSION}
47-
SOVERSION ${PROJECT_VERSION_MAJOR}
48-
)
49-
50-
target_include_directories(gio-qt
51-
PRIVATE
52-
${GIOMM_INCLUDE_DIRS}
53-
${CMAKE_CURRENT_LIST_DIR}/private
54-
PUBLIC
55-
${CMAKE_CURRENT_LIST_DIR}/include
56-
)
57-
58-
target_link_libraries (gio-qt Qt5::Core ${GIOMM_LIBRARIES})
59-
60-
target_compile_definitions(gio-qt PRIVATE
61-
QT_NO_KEYWORDS
62-
)
39+
include(qt6.cmake)
40+
include(qt5.cmake)
6341

64-
## dev files
6542
install (FILES ${QGIO_PUBLIC_HEADER_FILES}
6643
DESTINATION include/gio-qt
6744
)
68-
69-
install_targets ("/${CMAKE_INSTALL_LIBDIR}" gio-qt)
70-
71-
install (FILES "${CMAKE_CURRENT_BINARY_DIR}/gio-qt.pc"
72-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
73-
)

gio-qt/gio-qt6.pc.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
prefix=@CMAKE_INSTALL_PREFIX@
2+
exec_prefix=@CMAKE_INSTALL_PREFIX@
3+
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
4+
includedir=${prefix}/include
5+
6+
Name: gio-qt6
7+
Description: Qt wrapper library for GIO.
8+
Version: @PROJECT_VERSION@
9+
Requires: glibmm-2.4, Qt6Core
10+
11+
Libs: -L${libdir} -lgio-qt6
12+
Cflags: -I${includedir} -I${includedir}/gio-qt

gio-qt/include/dgiofile.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <QObject>
99
#include <QSharedData>
1010

11+
#include <limits.h>
12+
1113
namespace Gio {
1214
class File;
1315
}

gio-qt/qt5.cmake

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Find the QtWidgets library
2+
find_package(Qt5 ${QT_MINIMUM_VERSION} CONFIG REQUIRED Core)
3+
4+
# Library
5+
add_library(${PROJECT_NAME}_qt5 SHARED
6+
${QGIO_PUBLIC_HEADER_FILES}
7+
${QGIO_PRIVATE_HEADER_FILES}
8+
${QGIO_PRIVATE_CPP_FILES}
9+
)
10+
11+
set_target_properties(
12+
${PROJECT_NAME}_qt5 PROPERTIES
13+
OUTPUT_NAME gio-qt
14+
VERSION ${PROJECT_VERSION}
15+
SOVERSION ${PROJECT_VERSION_MAJOR}
16+
)
17+
18+
target_include_directories(${PROJECT_NAME}_qt5
19+
PRIVATE
20+
${GIOMM_INCLUDE_DIRS}
21+
${CMAKE_CURRENT_LIST_DIR}/private
22+
PUBLIC
23+
${CMAKE_CURRENT_LIST_DIR}/include
24+
Qt5::Core
25+
)
26+
27+
target_link_libraries(${PROJECT_NAME}_qt5 Qt5::Core ${GIOMM_LIBRARIES})
28+
29+
target_compile_definitions(${PROJECT_NAME}_qt5 PRIVATE
30+
QT_NO_KEYWORDS
31+
)
32+
33+
install(TARGETS ${PROJECT_NAME}_qt5 DESTINATION ${CMAKE_INSTALL_LIBDIR})
34+
35+
## dev files
36+
configure_file("gio-qt.pc.in" "gio-qt.pc" @ONLY)
37+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/gio-qt.pc"
38+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
39+
)

gio-qt/qt6.cmake

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Find the QtWidgets library
2+
find_package(Qt6 REQUIRED COMPONENTS Core)
3+
4+
# Library
5+
add_library(${PROJECT_NAME}_qt6 SHARED
6+
${QGIO_PUBLIC_HEADER_FILES}
7+
${QGIO_PRIVATE_HEADER_FILES}
8+
${QGIO_PRIVATE_CPP_FILES}
9+
)
10+
11+
set_target_properties(
12+
${PROJECT_NAME}_qt6 PROPERTIES
13+
OUTPUT_NAME gio-qt6
14+
VERSION ${PROJECT_VERSION}
15+
SOVERSION ${PROJECT_VERSION_MAJOR}
16+
)
17+
18+
target_include_directories(${PROJECT_NAME}_qt6
19+
PRIVATE
20+
${GIOMM_INCLUDE_DIRS}
21+
${CMAKE_CURRENT_LIST_DIR}/private
22+
PUBLIC
23+
${CMAKE_CURRENT_LIST_DIR}/include
24+
Qt6::Core
25+
)
26+
27+
target_link_libraries(${PROJECT_NAME}_qt6 Qt6::Core ${GIOMM_LIBRARIES})
28+
29+
target_compile_definitions(${PROJECT_NAME}_qt6 PRIVATE
30+
QT_NO_KEYWORDS
31+
)
32+
33+
install(TARGETS ${PROJECT_NAME}_qt6 DESTINATION ${CMAKE_INSTALL_LIBDIR})
34+
35+
## dev files
36+
configure_file("gio-qt6.pc.in" "gio-qt6.pc" @ONLY)
37+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/gio-qt6.pc"
38+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
39+
)

qgio-tools/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
# QXdgDesktopEntryTest
2-
add_executable (qgio-tools
3-
main.cpp
4-
)
52

6-
target_link_libraries (qgio-tools gio-qt)
3+
include(qt6.cmake)
4+
include(qt5.cmake)

0 commit comments

Comments
 (0)