Skip to content

Commit c6e87f8

Browse files
committed
build(deps): add Qt5 compatibility support alongside Qt6
Update package dependencies and build configuration to support both Qt5 and Qt6 versions. The debian/control file now uses alternative syntax for Qt-related dependencies, allowing the package to build on systems with either Qt version. Added automatic Qt version detection in debian/rules to determine the appropriate CMake configuration at build time. This change improves package compatibility across different Debian/Ubuntu environments while maintaining the primary Qt6 support.
1 parent df92c6a commit c6e87f8

3 files changed

Lines changed: 70 additions & 27 deletions

File tree

debian/control

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ Build-Depends: debhelper-compat (= 11),
99
libcups2-dev,
1010
libgtest-dev,
1111
libkmod-dev,
12-
libqapt-qt6-dev,
13-
libqapt3-qt6-runtime,
14-
libpolkit-qt6-1-dev,
12+
libqapt-qt6-dev | libqapt-dev,
13+
libqapt3-qt6-runtime | libqapt3-runtime,
14+
libpolkit-qt6-1-dev | libpolkit-qt5-1-dev,
1515
deepin-desktop-base,
1616
libdeepin-service-framework-dev (> 1.0.9),
17-
qt6-base-dev,
18-
qt6-base-dev-tools,
19-
qt6-base-private-dev,
20-
qt6-l10n-tools,
21-
qt6-tools-dev,
22-
qt6-tools-dev-tools,
23-
libdtk6gui-dev,
24-
libdtk6widget-dev,
25-
libdtk6core-dev,
26-
qt6-svg-dev,
27-
libqt6sql6
17+
qt6-base-dev | qtbase5-dev,
18+
qt6-base-dev-tools | qtbase5-dev-tools,
19+
qt6-base-private-dev | qtbase5-private-dev,
20+
qt6-l10n-tools | qttools5-dev-tools,
21+
qt6-tools-dev | qttools5-dev,
22+
qt6-tools-dev-tools | qttools5-dev-tools,
23+
libdtk6gui-dev | libdtkgui-dev,
24+
libdtk6widget-dev | libdtkwidget-dev,
25+
libdtk6core-dev | libdtkcore-dev,
26+
qt6-svg-dev | libqt5svg5-dev,
27+
libqt6sql6 | libqt5sql5
2828
Standards-Version: 4.1.3
2929

3030
Package: deepin-devicemanager
@@ -37,7 +37,7 @@ Depends: ${shlibs:Depends}, ${misc:Depends},
3737
upower,
3838
deepin-shortcut-viewer,
3939
lshw,
40-
libdtk6core,
40+
libdtk6core | libdtkcore5,
4141
libkmod2,
4242
libdeepin-service-framework,
4343
deepin-service-manager,

debian/rules

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,34 @@ export QT_SELECT := 6
99
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
1010
include /usr/share/dpkg/default.mk
1111

12+
DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
13+
DH_AUTO_ARGS = --parallel --buildsystem=cmake
14+
15+
# Uncomment this to turn on verbose mode.
16+
export DH_VERBOSE=1
17+
18+
# 检测当前安装的Qt版本,优先使用Qt6,否则使用Qt5
19+
define detect_qt_version
20+
ifneq (,$(shell which qmake6 2>/dev/null))
21+
QT_DIR="/usr/lib/$(DEB_HOST_MULTIARCH)/cmake/Qt6"
22+
else
23+
QT_DIR="/usr/lib/$(DEB_HOST_MULTIARCH)/cmake/Qt5"
24+
endif
25+
endef
26+
27+
# 调用检测Qt版本的命令
28+
$(eval $(call detect_qt_version))
29+
1230
override_dh_auto_configure:
1331
dh_auto_configure -- \
14-
-DCMAKE_BUILD_TYPE=Release \
15-
-DCMAKE_SAFETYTEST_ARG="CMAKE_SAFETYTEST_ARG_OFF" \
16-
-DAPP_VERSION=$(DEB_VERSION_UPSTREAM) -DVERSION=$(DEB_VERSION_UPSTREAM) LIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH)
32+
-DUSE_AM_DBUS=ON \
33+
-DCMAKE_BUILD_TYPE=Release \
34+
-DCMAKE_INSTALL_PREFIX=/usr \
35+
-DAPP_VERSION=$(DEB_VERSION_UPSTREAM) \
36+
-DCVERSION=$(DEB_VERSION_UPSTREAM) \
37+
-DQT_DIR=$(QT_DIR)
1738
%:
18-
dh $@
39+
dh $@ --parallel
1940

2041
override_dh_shlibdeps:
2142
dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info

deepin-devicemanager-server/customgpuinfo/CMakeLists.txt

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@ cmake_minimum_required(VERSION 3.7)
22

33
set(BIN_NAME "customgpuinfo")
44

5-
find_package(Qt5 COMPONENTS Core REQUIRED)
5+
macro(SET_QT_VERSION)
6+
if(${QT_VERSION_MAJOR} EQUAL 6)
7+
find_package(Qt6 COMPONENTS Core REQUIRED)
8+
elseif(${QT_VERSION_MAJOR} EQUAL 5)
9+
find_package(Qt5 COMPONENTS Core REQUIRED)
10+
else()
11+
message(FATAL_ERROR "Unsupported QT_VERSION_MAJOR: ${QT_VERSION_MAJOR}")
12+
endif()
13+
endmacro()
14+
15+
SET_QT_VERSION()
616

717
file(GLOB_RECURSE SRC
818
"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
@@ -13,12 +23,24 @@ add_executable(${BIN_NAME}
1323
${SRC}
1424
)
1525

16-
target_include_directories(${BIN_NAME} PUBLIC
17-
Qt5::Core
18-
)
19-
20-
target_link_libraries(${BIN_NAME} PRIVATE
21-
Qt5::Core
22-
)
26+
if(${QT_VERSION_MAJOR} EQUAL 6)
27+
target_include_directories(${BIN_NAME} PUBLIC
28+
Qt6::Core
29+
)
30+
31+
target_link_libraries(${BIN_NAME} PRIVATE
32+
Qt6::Core
33+
)
34+
elseif(${QT_VERSION_MAJOR} EQUAL 5)
35+
target_include_directories(${BIN_NAME} PUBLIC
36+
Qt5::Core
37+
)
38+
39+
target_link_libraries(${BIN_NAME} PRIVATE
40+
Qt5::Core
41+
)
42+
else()
43+
message(FATAL_ERROR "Unsupported QT_VERSION_MAJOR: ${QT_VERSION_MAJOR}")
44+
endif()
2345

2446
install(TARGETS ${BIN_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/deepin-devicemanager)

0 commit comments

Comments
 (0)