Skip to content

Commit

Permalink
chore: adapt to Qt6
Browse files Browse the repository at this point in the history
as title

Log: as title
  • Loading branch information
yixinshark committed Feb 5, 2025
1 parent b82c47d commit 076a871
Show file tree
Hide file tree
Showing 57 changed files with 525 additions and 605 deletions.
215 changes: 60 additions & 155 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.13.4)
cmake_minimum_required(VERSION 3.16)
project(dde-session-shell C CXX)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
Expand Down Expand Up @@ -30,13 +30,8 @@ if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "mips64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -ftree-vectorize -march=loongson3a -mhard-float -mno-micromips -mno-mips16 -flax-vector-conversions -mloongson-ext2 -mloongson-mmi")
endif()

if (NOT (${CMAKE_BUILD_TYPE} MATCHES "Debug"))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ofast")

# generate qm
execute_process(COMMAND bash "translate_generation.sh"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
endif ()
set(QT_VERSION_MAJOR 6)
set(DTK_VERSION_MAJOR 6)

if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX /usr)
Expand All @@ -46,131 +41,67 @@ include(GNUInstallDirs)
# Find the library
find_package(PAM REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(DtkWidget REQUIRED)
find_package(DtkCMake REQUIRED)
find_package(DtkCore REQUIRED)
find_package(Qt5 COMPONENTS
Core
Widgets
Concurrent
X11Extras
DBus
Xml
Svg
Network
REQUIRED)
find_package(DtkTools REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Widgets Concurrent DBus Xml Svg Network LinguistTools)
find_package(Dtk${DTK_VERSION_MAJOR} REQUIRED COMPONENTS Widget Core Tools)

pkg_check_modules(XCB_EWMH REQUIRED xcb-ewmh x11 xi xcursor xfixes xrandr xext xtst)
pkg_check_modules(QGSettings REQUIRED gsettings-qt)
pkg_check_modules(Greeter REQUIRED liblightdm-qt5-3)
pkg_check_modules(Greeter REQUIRED liblightdm-qt6-3)

## qm files
file(GLOB TS_FILES "translations/*.ts")
qt_add_translation(QM_FILES ${TS_FILES})
add_custom_target(dde-session-shell_language ALL DEPENDS ${QM_FILES})

set(Qt_LIBS
Qt5::Core
Qt5::Gui
Qt5::DBus
Qt5::Widgets
Qt5::X11Extras
Qt5::Xml
Qt5::Svg
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::DBus
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Concurrent
Qt${QT_VERSION_MAJOR}::Xml
Qt${QT_VERSION_MAJOR}::Svg
)

set(XML2CPP_DIR ${PROJECT_SOURCE_DIR}/src/global_util/dbus)

function(generation_dbus_interface xml class_name class_file)
execute_process(COMMAND ${DTK_XML2CPP} -c ${class_name} -p ${class_file} ${xml}
WORKING_DIRECTORY ${XML2CPP_DIR})
endfunction(generation_dbus_interface)

generation_dbus_interface(
${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.Authenticate1.xml
Authenticate
${XML2CPP_DIR}/authenticate_interface
)

generation_dbus_interface(
${CMAKE_SOURCE_DIR}/xml/com.huawei.switchos.xml
HuaWeiSwitchOS
${XML2CPP_DIR}/huaweiswitchos_interface
)

generation_dbus_interface(
${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.Accounts1.xml
Accounts
${XML2CPP_DIR}/accounts_interface
)

generation_dbus_interface(
${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.Accounts1.User.xml
AccountsUser
${XML2CPP_DIR}/accountsuser_interface
)

generation_dbus_interface(
${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.ImageEffect1.xml
ImageEffect
${XML2CPP_DIR}/imageeffect_interface
)

generation_dbus_interface(
${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.Logined.xml
Logined
${XML2CPP_DIR}/logined_interface
)

generation_dbus_interface(
${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.PowerManager1.xml
PowerManager
${XML2CPP_DIR}/powermanager_interface
)

generation_dbus_interface(
${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.SystemPower1.xml
SystemPower
${XML2CPP_DIR}/systempower_interface
)

generation_dbus_interface(
${CMAKE_SOURCE_DIR}/xml/com.deepin.wm.xml
wm
${XML2CPP_DIR}/wm_interface
)

generation_dbus_interface(
${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.Authenticate1.Session2.xml
AuthenticateSession2
${XML2CPP_DIR}/authenticatesession2_interface
)

generation_dbus_interface(
${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.SessionManager1.xml
SessionManager
${XML2CPP_DIR}/sessionmanager_interface
function(generation_dbus_interface xml class_file)
set(file_name ${XML2CPP_DIR}/${class_file})
execute_process(
COMMAND ${DTK_XML2CPP} -p ${file_name} ${xml}
WORKING_DIRECTORY ${XML2CPP_DIR}
)
endfunction()

set(DBUS_INTERFACES
"${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.Authenticate1.xml authenticate1interface"
"${CMAKE_SOURCE_DIR}/xml/com.huawei.switchos.xml switchosinterface"
"${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.Accounts1.xml accounts1interface"
"${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.Accounts1.User.xml userinterface"
"${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.ImageEffect1.xml imageeffect1interface"
"${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.Logined.xml loginedinterface"
"${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.PowerManager1.xml powermanager1interface"
"${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.SystemPower1.xml systempower1interface"
"${CMAKE_SOURCE_DIR}/xml/com.deepin.wm.xml wminterface"
"${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.Authenticate1.Session2.xml session2interface"
"${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.SessionManager1.xml sessionmanager1interface"
"${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.SystemDisplay1.xml systemdisplay1interface"
"${CMAKE_SOURCE_DIR}/xml/org.freedesktop.DBus.xml dbusinterface"
"${CMAKE_SOURCE_DIR}/xml/org.freedesktop.login1.session.self.xml selfinterface"
)

generation_dbus_interface(
${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.SoundThemePlayer1.xml
SoundThemePlayer
${XML2CPP_DIR}/soundthemeplayer_interface
)
foreach(interface IN LISTS DBUS_INTERFACES)
string(REPLACE " " ";" interface_list "${interface}")

generation_dbus_interface(
${CMAKE_SOURCE_DIR}/xml/org.deepin.dde.SystemDisplay1.xml
SystemDisplay
${XML2CPP_DIR}/systemdisplay_interface
)
list(GET interface_list 0 XML_FILE)
list(GET interface_list 1 CLASS_FILE)

generation_dbus_interface(
${CMAKE_SOURCE_DIR}/xml/org.freedesktop.DBus.xml
FreedesktopDBus
${XML2CPP_DIR}/freedesktopdbus_interface
)
list(LENGTH interface_list list_len)
if(list_len LESS 2)
message(FATAL_ERROR "Invalid DBus interface definition: ${interface}")
endif()

generation_dbus_interface(
${CMAKE_SOURCE_DIR}/xml/org.freedesktop.login1.session.self.xml
Login1SessionSelf
${XML2CPP_DIR}/login1sessionself_interface
)
generation_dbus_interface(${XML_FILE} ${CLASS_FILE})
endforeach()

include_directories(${PROJECT_SOURCE_DIR}/src/global_util)
include_directories(${PROJECT_SOURCE_DIR}/src/global_util/dbus)
Expand Down Expand Up @@ -198,7 +129,6 @@ set(QRCS
)

set(LOCK_SRCS
${transaction_DBUS_SCRS}
${GLOBAL_UTILS}
${GLOBAL_UTILS_DBUS}
${GLOBAL_UTILS_KEYBOARDMONITOR}
Expand All @@ -222,37 +152,26 @@ add_executable(dde-lock
)
target_include_directories(dde-lock PUBLIC
${PAM_INCLUDE_DIR}
${DTKWIDGET_INCLUDE_DIR}
${DTKCORE_INCLUDE_DIR}
${XCB_EWMH_INCLUDE_DIRS}
${Qt5Gui_PRIVATE_INCLUDE_DIRS}
${PROJECT_BINARY_DIR}
${QGSettings_INCLUDE_DIRS}
${Qt5X11Extras_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/src/dde-lock
${PROJECT_SOURCE_DIR}/src/dde-lock/dbus
${Greeter_INCLUDE_DIRS}
)

target_link_libraries(dde-lock PRIVATE
${Qt_LIBS}
${PAM_LIBRARIES}
${XCB_EWMH_LIBRARIES}
${DtkWidget_LIBRARIES}
${DtkCore_LIBRARIES}
${Qt5Widgets_LIBRARIES}
${Qt5Concurrent_LIBRARIES}
${Qt5X11Extras_LIBRARIES}
${Qt5DBus_LIBRARIES}
${Qt5Network_LIBRARIES}
${QGSettings_LIBRARIES}
Dtk${DTK_VERSION_MAJOR}::Widget
Dtk${DTK_VERSION_MAJOR}::Core
${Greeter_LIBRARIES}
${DEEPIN_PW_CHECK}
)

set(DEEPIN_PW_CHECK libdeepin_pw_check.so)

set(GREETER_SRCS
${transaction_DBUS_SCRS}
${GLOBAL_UTILS}
${GLOBAL_UTILS_DBUS}
${GLOBAL_UTILS_KEYBOARDMONITOR}
Expand All @@ -277,13 +196,8 @@ add_executable(lightdm-deepin-greeter

target_include_directories(lightdm-deepin-greeter PUBLIC
${PAM_INCLUDE_DIR}
${DTKWIDGET_INCLUDE_DIR}
${DTKCORE_INCLUDE_DIR}
${XCB_EWMH_INCLUDE_DIRS}
${Qt5Gui_PRIVATE_INCLUDE_DIRS}
${PROJECT_BINARY_DIR}
${QGSettings_INCLUDE_DIRS}
${Qt5X11Extras_INCLUDE_DIRS}
${Greeter_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/src/lightdm-deepin-greeter
)
Expand All @@ -301,14 +215,8 @@ target_link_libraries(lightdm-deepin-greeter PRIVATE
${Qt_LIBS}
${PAM_LIBRARIES}
${XCB_EWMH_LIBRARIES}
${DtkWidget_LIBRARIES}
${DtkCore_LIBRARIES}
${Qt5Widgets_LIBRARIES}
${Qt5Concurrent_LIBRARIES}
${Qt5X11Extras_LIBRARIES}
${Qt5DBus_LIBRARIES}
${Qt5Network_LIBRARIES}
${QGSettings_LIBRARIES}
Dtk${DTK_VERSION_MAJOR}::Widget
Dtk${DTK_VERSION_MAJOR}::Core
${Greeter_LIBRARIES}
${DEEPIN_PW_CHECK}
)
Expand Down Expand Up @@ -338,7 +246,6 @@ install(FILES files/deepin-greeter DESTINATION ${CMAKE_INSTALL_BINDIR})
file(GLOB SCRIPTS scripts/*)
install(PROGRAMS ${SCRIPTS} DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/deepin/greeters.d)

file(GLOB QM_FILES "translations/*.qm")
install(FILES ${QM_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/dde-session-shell/translations)
install(FILES qt-theme.ini DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/lightdm/deepin)

Expand All @@ -351,9 +258,6 @@ install(FILES files/lightdm-deepin-greeter.conf DESTINATION ${CMAKE_INSTALL_DATA
file(GLOB SERVICES files/*.service)
install(FILES ${SERVICES} DESTINATION ${CMAKE_INSTALL_DATADIR}/dbus-1/services)

#schemas
install(FILES xml/com.deepin.dde.session-shell.gschema.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/glib-2.0/schemas)

# dev
file(GLOB INTERFACE interface/*.h)
install(FILES ${INTERFACE} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dde-session-shell)
Expand All @@ -374,5 +278,6 @@ file(GLOB PAM_CONFIG files/pam.d/*)
install(FILES ${PAM_CONFIG} DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/pam.d/)

# config
dconfig_meta_files(APPID org.deepin.dde.lock FILES configs/org.deepin.dde.lock.json)
dconfig_meta_files(APPID org.deepin.dde.lightdm-deepin-greeter FILES configs/org.deepin.dde.lightdm-deepin-greeter.json)
dtk_add_config_meta_files(APPID org.deepin.dde.lock FILES configs/org.deepin.dde.lock.json)
dtk_add_config_meta_files(APPID org.deepin.dde.lightdm-deepin-greeter FILES configs/org.deepin.dde.lightdm-deepin-greeter.json)
dtk_add_config_meta_files(APPID org.deepin.dde.session-shell FILES configs/org.deepin.dde.session-shell.json)
Loading

0 comments on commit 076a871

Please sign in to comment.