Skip to content

Commit

Permalink
Qt 6 and ECM
Browse files Browse the repository at this point in the history
  • Loading branch information
plfiorini committed Dec 29, 2023
1 parent e8158a3 commit b95bb9c
Show file tree
Hide file tree
Showing 21 changed files with 261 additions and 276 deletions.
62 changes: 38 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,49 +1,63 @@
cmake_minimum_required(VERSION 3.10.0)
cmake_minimum_required(VERSION 3.19)

project("Session"
VERSION "0.1.0"
DESCRIPTION "Session manager"
LANGUAGES CXX C
)

## Shared macros and functions:
if(NOT LIRI_LOCAL_ECM)
find_package(LiriCMakeShared "2.0.0" REQUIRED NO_MODULE)
list(APPEND CMAKE_MODULE_PATH "${LCS_MODULE_PATH}")
## Only build on the appropriate platforms.
if(NOT (UNIX OR NOT CMAKE_SYSTEM_NAME MATCHES "Android"))
message(NOTICE "Skipping the build as the condition \"UNIX OR NOT Android\" is not met.")
return()
endif()

## Set minimum versions required:
set(QT_MIN_VERSION "5.10.0")
## ECM:
find_package(ECM 5.245.0 REQUIRED NO_MODULE)
list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH})

## Installation directories:
include(KDEInstallDirs)

## Compiler settings:
set(KDE_SKIP_NULLPTR_WARNINGS_SETTINGS TRUE)
include(KDECompilerSettings NO_POLICY_SCOPE)

## Enable keywords such as emit:
# TODO: Replace keywords such as emit with Q_EMIT
remove_definitions(-DQT_NO_KEYWORDS)

## CMake settings:
include(KDECMakeSettings)

## QML module:
include(ECMQmlModule)

## Disable use of C++ API deprecated in Qt 5.15
add_compile_definitions(QT_DISABLE_DEPRECATED_UP_TO=0x050F00)

## Shared macros and functions:
find_package(LiriCMakeShared "2.0.99" REQUIRED NO_MODULE)
list(APPEND CMAKE_MODULE_PATH "${LCS_MODULE_PATH}")

## Liri specific setup common for all modules:
include(LiriSetup)

## Only build on the appropriate platforms.
if(NOT UNIX OR ANDROID)
message(NOTICE "Skipping the build as the condition \"UNIX OR ANDROID\" is not met.")
return()
endif()

## Features:
option(LIRI_SESSION_DEVELOPMENT_BUILD "Development build" OFF)
add_feature_info("Session::DevelopmentBuild" LIRI_SESSION_DEVELOPMENT_BUILD "Build for development")
option(LIRI_ENABLE_SYSTEMD "Enable systemd support" ON)
add_feature_info("Liri::Systemd" LIRI_ENABLE_SYSTEMD "Enable systemd support")

## Variables:
if(LIRI_ENABLE_SYSTEMD)
set(INSTALL_SYSTEMDUSERUNITDIR "${INSTALL_LIBDIR}/systemd/user" CACHE PATH "systemd user unit directory [PREFIX/lib/systemd/user]")
set(INSTALL_SYSTEMDUSERGENERATORSDIR "${INSTALL_LIBDIR}/systemd/user-generators" CACHE PATH "systemd user generators directory [PREFIX/lib/systemd/user-generators]")
endif()

## Find Qt 5:
find_package(Qt5 "${QT_MIN_VERSION}"
CONFIG REQUIRED
## Find Qt:
set(QT_MIN_VERSION "6.6.0")
find_package(Qt6 "${QT_MIN_VERSION}"
REQUIRED
COMPONENTS
Core
DBus
Xml
Gui
Xml
Gui
LinguistTools
)

Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ XDG autostart applications.

## Dependencies

Qt >= 5.10.0 with at least the following modules is required:
Qt >= 6.6.0 with at least the following modules is required:

* [qtbase](http://code.qt.io/cgit/qt/qtbase.git)

The following modules and their dependencies are required:

* [cmake](https://gitlab.kitware.com/cmake/cmake) >= 3.10.0
* [cmake-shared](https://github.com/lirios/cmake-shared.git) >= 1.0.0
* [qtgsettings](https://github.com/lirios/qtgsettings) >= 1.1.0
* [cmake](https://gitlab.kitware.com/cmake/cmake) >= 3.19.0
* [extra-cmake-modules](https://invent.kde.org/frameworks/extra-cmake-modules) >= 5.245.0
* [cmake-shared](https://github.com/lirios/cmake-shared.git) >= 2.0.99
* [qtgsettings](https://github.com/lirios/qtgsettings) >= 2.0.0
* [libliri](https://github.com/lirios/libliri)

## Installation
Expand Down
4 changes: 2 additions & 2 deletions data/menu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ install(
liri-system.directory
liri-work.directory
DESTINATION
"${INSTALL_DATADIR}/desktop-directories"
"${KDE_INSTALL_DATADIR}/desktop-directories"
)

install(
FILES
liri-applications.menu
DESTINATION
"${INSTALL_SYSCONFDIR}/xdg/menus"
"${KDE_INSTALL_SYSCONFDIR}/xdg/menus"
)
2 changes: 1 addition & 1 deletion data/settings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ install(
io.liri.session.gschema.xml
io.liri.session.locale.gschema.xml
DESTINATION
"${INSTALL_DATADIR}/glib-2.0/schemas"
"${KDE_INSTALL_DATADIR}/glib-2.0/schemas"
)
15 changes: 4 additions & 11 deletions data/systemd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
if(IS_ABSOLUTE "${INSTALL_BINDIR}")
set(ABSOLUTE_BINDIR "${INSTALL_BINDIR}")
else()
set(ABSOLUTE_BINDIR "${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}")
endif()
if(IS_ABSOLUTE "${INSTALL_LIBEXECDIR}")
set(ABSOLUTE_LIBEXECDIR "${INSTALL_LIBEXECDIR}")
else()
set(ABSOLUTE_LIBEXECDIR "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBEXECDIR}")
endif()
set(ABSOLUTE_BINDIR "${KDE_INSTALL_FULL_BINDIR}")
set(ABSOLUTE_LIBEXECDIR "${KDE_INSTALL_FULL_LIBEXECDIR}")

configure_file(
"liri-daemon-locale.service.in"
"${CMAKE_CURRENT_BINARY_DIR}/liri-daemon-locale.service"
Expand All @@ -28,5 +21,5 @@ install(
"${CMAKE_CURRENT_BINARY_DIR}/liri-session-shutdown.service"
liri-session.target
DESTINATION
"${INSTALL_SYSTEMDUSERUNITDIR}"
"${KDE_INSTALL_SYSTEMDUSERUNITDIR}"
)
2 changes: 1 addition & 1 deletion data/systemd/autostart/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ install(
FILES
pulseaudio.desktop
DESTINATION
"${INSTALL_DATADIR}/liri-session/systemd-user/autostart"
"${KDE_INSTALL_DATADIR}/liri-session/systemd-user/autostart"
)
64 changes: 27 additions & 37 deletions src/daemon/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,46 +1,36 @@
# Defines
set(DEFINES "")
if(LIRI_SESSION_DEVELOPMENT_BUILD)
list(APPEND DEFINES "DEVELOPMENT_BUILD")
endif()
qt6_add_dbus_adaptor(_dbus_sources io.liri.Daemon.xml daemoninterface.h)
set(_sources
daemon.cpp daemon.h
daemoninterface.cpp daemoninterface.h
main.cpp
pluginregistry.cpp pluginregistry.h
${_dbus_sources}
)
add_executable(LiriDaemon ${_sources})

# Absolute paths
if(IS_ABSOLUTE "${INSTALL_PLUGINSDIR}")
set(PLUGINSDIR "${INSTALL_PLUGINSDIR}")
else()
set(PLUGINSDIR "${CMAKE_INSTALL_PREFIX}/${INSTALL_PLUGINSDIR}")
endif()
set_target_properties(LiriDaemon PROPERTIES OUTPUT_NAME liri-daemon)

target_compile_definitions(LiriDaemon
PRIVATE
LIRI_DAEMON_VERSION="${PROJECT_VERSION}"
PLUGINSDIR="${KDE_INSTALL_FULL_PLUGINSDIR}"
)

if(LIRI_SESSION_DEVELOPMENT_BUILD)
target_compile_definitions(LiriDaemon PRIVATE DEVELOPMENT_BUILD)
endif()
if(LIRI_ENABLE_SYSTEMD)
list(APPEND DEFINES "ENABLE_SYSTEMD")
target_compile_definitions(LiriDaemon PRIVATE ENABLE_SYSTEMD)
endif()

liri_add_executable(LiriDaemon
OUTPUT_NAME
"liri-daemon"
SOURCES
daemon.cpp
daemon.h
daemoninterface.cpp
daemoninterface.h
main.cpp
pluginregistry.cpp
pluginregistry.h
DBUS_ADAPTOR_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/io.liri.Daemon.xml"
DEFINES
QT_NO_CAST_FROM_ASCII
QT_NO_FOREACH
LIRI_DAEMON_VERSION="${PROJECT_VERSION}"
${DEFINES}
PLUGINSDIR="${PLUGINSDIR}"
INSTALL_DIRECTORY
"${INSTALL_LIBEXECDIR}"
LIBRARIES
Qt5::Core
Qt5::DBus
target_link_libraries(LiriDaemon
PRIVATE
Qt6::Core
Qt6::DBus
Sigwatch
Liri::Daemon
)

liri_finalize_executable(LiriDaemon)
install(TARGETS LiriDaemon
DESTINATION ${KDE_INSTALL_LIBEXECDIR}
)
2 changes: 1 addition & 1 deletion src/daemon/daemoninterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include "daemon.h"
#include "daemoninterface.h"
#include "daemon_adaptor.h"
#include "daemonadaptor.h"

#define SERVICE_NAME QStringLiteral("io.liri.Daemon")
#define OBJECT_PATH QStringLiteral("/io/liri/Daemon")
Expand Down
43 changes: 26 additions & 17 deletions src/imports/session/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
liri_add_qml_plugin(SessionQmlPlugin
MODULE_PATH
"Liri/Session"
VERSION
"1.0"
OUTPUT_NAME
"sessionplugin"
SOURCES
# SPDX-FileCopyrightText: 2024 Pier Luigi Fiorini <[email protected]>
# SPDX-License-Identifier: BSD-3-Clause

ecm_add_qml_module(SessionQmlPlugin
URI Liri.Session
CLASS_NAME SessionPlugin
TYPEINFO sessionplugin.qmltypes
NO_GENERATE_PLUGIN_SOURCE
DEPENDENCIES QtQuick
)

target_sources(SessionQmlPlugin
PRIVATE
plugin.cpp
qmllauncher.cpp qmllauncher.h
qmlsessionmanager.cpp qmlsessionmanager.h
QML_FILES
qmldir
DEFINES
QT_NO_CAST_FROM_ASCII
QT_NO_FOREACH
PUBLIC_LIBRARIES
Qt5::Core
Qt5::DBus
)

liri_finalize_qml_plugin(SessionQmlPlugin)
set_target_properties(SessionQmlPlugin
PROPERTIES
OUTPUT_NAME sessionplugin
)

target_link_libraries(SessionQmlPlugin
PRIVATE
Qt6::Core
Qt6::DBus
Qt6::Qml
)

ecm_finalize_qml_module(SessionQmlPlugin)
4 changes: 0 additions & 4 deletions src/imports/session/qmldir

This file was deleted.

26 changes: 9 additions & 17 deletions src/libdaemon/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
# Defines
set(DEFINES "")

if(LIRI_ENABLE_SYSTEMD)
list(APPEND DEFINES "ENABLE_SYSTEMD")
endif()

liri_add_module(Daemon
DESCRIPTION
"Daemon"
SOURCES
daemonmodule.cpp
daemonmodule.h
DEFINES
QT_NO_CAST_FROM_ASCII
QT_NO_FOREACH
${DEFINES}
daemonmodule.cpp daemonmodule.h
PUBLIC_LIBRARIES
Qt5::Core
Qt5::DBus
Qt6::Core
Qt6::DBus
PKGCONFIG_DEPENDENCIES
Qt5Core
Qt5DBus
Qt6Core
Qt6DBus
)

if(LIRI_ENABLE_SYSTEMD)
target_compile_definitions(Daemon PRIVATE ENABLE_SYSTEMD)
endif()

liri_finalize_module(Daemon)
8 changes: 3 additions & 5 deletions src/libsession/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ liri_add_module(Session
DESCRIPTION
"Session manager"
SOURCES
sessionmodule.cpp
sessionmodule.h
sessionmodule_p.h
sessionmodule.cpp sessionmodule.h sessionmodule_p.h
DEFINES
QT_NO_CAST_FROM_ASCII
QT_NO_FOREACH
PUBLIC_LIBRARIES
Qt5::Core
Qt6::Core
PKGCONFIG_DEPENDENCIES
Qt5Core
Qt6Core
)

liri_finalize_module(Session)
2 changes: 1 addition & 1 deletion src/libsigwatch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set(SOURCES
)

add_library(Sigwatch STATIC ${SOURCES})
target_link_libraries(Sigwatch Qt5::Core)
target_link_libraries(Sigwatch Qt6::Core)
target_include_directories(Sigwatch PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
)
Loading

0 comments on commit b95bb9c

Please sign in to comment.