forked from sddm/sddm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
236 lines (191 loc) · 8.31 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
cmake_minimum_required(VERSION 3.4)
project(SDDM)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# Set version
set(SDDM_VERSION_MAJOR 0)
set(SDDM_VERSION_MINOR 21)
set(SDDM_VERSION_PATCH 0)
set(SDDM_VERSION_STRING "${SDDM_VERSION_MAJOR}.${SDDM_VERSION_MINOR}.${SDDM_VERSION_PATCH}")
add_compile_definitions("SDDM_VERSION=\"${SDDM_VERSION_STRING}\"")
# Options
option(BUILD_MAN_PAGES "Build man pages" OFF)
option(ENABLE_JOURNALD "Enable logging to journald" ON)
option(NO_SYSTEMD "Disable systemd support" OFF)
option(USE_ELOGIND "Use elogind instead of logind" OFF)
option(BUILD_WITH_QT6 "Build with Qt 6" OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
# Definitions
add_definitions(-Wall -Wextra -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_FOREACH)
# Default build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# Handle build type
if(CMAKE_BUILD_TYPE MATCHES [Dd]ebug)
message(STATUS "Debug build")
add_definitions(-DDEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0")
else()
message(STATUS "Release build")
add_definitions(-DNDEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
endif()
# Default absolute paths
if(NOT DEFINED CMAKE_INSTALL_SYSCONFDIR)
set(CMAKE_INSTALL_SYSCONFDIR "/etc")
endif()
if(NOT DEFINED CMAKE_INSTALL_LOCALSTATEDIR)
set(CMAKE_INSTALL_LOCALSTATEDIR "/var")
endif()
# Standard installation paths
include(GNUInstallDirs)
# Macros
include(FeatureSummary)
# PKG-CONFIG
find_package(PkgConfig)
# PAM
find_package(PAM REQUIRED)
# XAU
pkg_check_modules(LIBXAU REQUIRED "xau")
# XCB
find_package(XCB REQUIRED)
# XKB
find_package(XKB REQUIRED)
# Qt
if(BUILD_WITH_QT6)
set(QT_MAJOR_VERSION 6)
message(STATUS "Building Qt 6 version")
else()
set(QT_MAJOR_VERSION 5)
message(STATUS "Building Qt 5 version")
endif()
find_package(Qt${QT_MAJOR_VERSION} 5.15.0 CONFIG REQUIRED Core DBus Gui Qml Quick LinguistTools Test QuickTest)
# find qt5 imports dir
get_target_property(QMAKE_EXECUTABLE Qt${QT_MAJOR_VERSION}::qmake LOCATION)
if(NOT QT_IMPORTS_DIR)
execute_process(COMMAND ${QMAKE_EXECUTABLE} -query QT_INSTALL_QML OUTPUT_VARIABLE QT_IMPORTS_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
# systemd
if(NOT NO_SYSTEMD AND NOT USE_ELOGIND)
pkg_check_modules(SYSTEMD "systemd")
endif()
if(SYSTEMD_FOUND)
add_definitions(-DHAVE_SYSTEMD)
set(CMAKE_AUTOMOC_MOC_OPTIONS -DHAVE_SYSTEMD)
# libsystemd-journal was merged into libsystemd in 209
if(${SYSTEMD_VERSION} VERSION_LESS 209)
pkg_check_modules(JOURNALD "libsystemd-journal")
else()
pkg_check_modules(JOURNALD "libsystemd")
endif()
if(ENABLE_JOURNALD)
if(JOURNALD_FOUND)
add_definitions(-DHAVE_JOURNALD)
set(CMAKE_AUTOMOC_MOC_OPTIONS -DHAVE_JOURNALD)
else()
message(WARNING "Disable journald support for lack of libsystemd-journal")
endif()
endif()
if (NOT DEFINED SYSTEMD_SYSTEM_UNIT_DIR)
pkg_get_variable(SYSTEMD_SYSTEM_UNIT_DIR systemd systemdsystemunitdir)
endif()
if (NOT DEFINED SYSTEMD_SYSUSERS_DIR)
pkg_get_variable(SYSTEMD_SYSUSERS_DIR systemd sysusersdir)
endif()
if (NOT DEFINED SYSTEMD_TMPFILES_DIR)
pkg_get_variable(SYSTEMD_TMPFILES_DIR systemd tmpfilesdir)
endif()
set(HALT_COMMAND "/bin/systemctl poweroff")
set(REBOOT_COMMAND "/bin/systemctl reboot")
else()
set(SYSTEMD_FOUND 0)
endif()
add_feature_info("systemd" SYSTEMD_FOUND "systemd support")
add_feature_info("journald" JOURNALD_FOUND "journald support")
# elogind
if(NO_SYSTEMD AND USE_ELOGIND)
pkg_check_modules(ELOGIND "libelogind")
endif()
if(ELOGIND_FOUND)
add_definitions(-DHAVE_ELOGIND)
set(CMAKE_AUTOMOC_MOC_OPTIONS -DHAVE_ELOGIND)
set(HALT_COMMAND "/usr/bin/loginctl poweroff")
set(REBOOT_COMMAND "/usr/bin/loginctl reboot")
endif()
add_feature_info("elogind" ELOGIND_FOUND "elogind support")
# Default behaviour if neither systemd nor elogind is used
if (NOT ELOGIND_FOUND AND NOT SYSTEMD_FOUND)
# Set the VT on which sddm will normally appear, and the
# commands for shutdown and reboot. On FreeBSD, there are
# normally more getty's running than on Linux.
if("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
set(HALT_COMMAND "/sbin/shutdown -p now")
else()
set(HALT_COMMAND "/sbin/shutdown -h -P now")
endif()
set(REBOOT_COMMAND "/sbin/shutdown -r now")
endif()
if (SYSTEMD_FOUND)
set(RUNTIME_DIR_DEFAULT "/run/sddm")
else()
set(RUNTIME_DIR_DEFAULT "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/run/sddm")
endif()
# utmps
find_package(utmps)
add_feature_info("utmps" UTMPS_FOUND "utmps support")
# Set constants
set(DATA_INSTALL_DIR "${CMAKE_INSTALL_FULL_DATADIR}/sddm" CACHE PATH "System application data install directory")
set(DBUS_CONFIG_DIR "${CMAKE_INSTALL_FULL_DATADIR}/dbus-1/system.d" CACHE PATH "DBus config files directory")
set(STATE_DIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/sddm" CACHE PATH "State directory")
set(RUNTIME_DIR "${RUNTIME_DIR_DEFAULT}" CACHE PATH "Runtime data storage directory")
set(QML_INSTALL_DIR "${QT_IMPORTS_DIR}" CACHE PATH "QML component installation directory")
set(SESSION_COMMAND "${DATA_INSTALL_DIR}/scripts/Xsession" CACHE PATH "Script to execute when starting the X11 desktop session")
set(WAYLAND_SESSION_COMMAND "${DATA_INSTALL_DIR}/scripts/wayland-session" CACHE PATH "Script to execute when starting the Wayland desktop session")
set(CONFIG_FILE "${CMAKE_INSTALL_FULL_SYSCONFDIR}/sddm.conf" CACHE PATH "Path of the sddm config file")
set(CONFIG_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/sddm.conf.d" CACHE PATH "Path of the sddm config directory")
set(ACCOUNTSSERVICE_DATA_DIR "/var/lib/AccountsService" CACHE PATH "Path of the accountsservice data directory")
set(SYSTEM_CONFIG_DIR "${CMAKE_INSTALL_PREFIX}/lib/sddm/sddm.conf.d" CACHE PATH "Path of the system sddm config directory")
set(LOG_FILE "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/sddm.log" CACHE PATH "Path of the sddm log file")
set(DBUS_CONFIG_FILENAME "org.freedesktop.DisplayManager.conf" CACHE STRING "Name of the sddm config file")
set(COMPONENTS_TRANSLATION_DIR "${DATA_INSTALL_DIR}/translations-qt${QT_MAJOR_VERSION}" CACHE PATH "Components translations directory")
set(SDDM_INITIAL_VT "1" CACHE STRING "Initial tty to use")
# Autodetect UID_MIN and UID_MAX from /etc/login.defs
if(NOT DEFINED LOGIN_DEFS_PATH)
set(LOGIN_DEFS_PATH "/etc/login.defs" CACHE PATH "Path to login.defs")
endif()
if(NOT EXISTS "${LOGIN_DEFS_PATH}" AND NOT DEFINED UID_MIN AND NOT DEFINED UID_MAX)
message(FATAL_ERROR "Could not find login.defs at ${LOGIN_DEFS_PATH}. Try -DLOGIN_DEFS_PATH.")
endif()
if(NOT DEFINED UID_MIN)
file(STRINGS "${LOGIN_DEFS_PATH}" UID_MIN LIMIT_COUNT 1 REGEX "^UID_MIN")
string(REGEX REPLACE "^UID_MIN[\t ]+([0-9]+)" "\\1" UID_MIN "${UID_MIN}")
if(NOT UID_MIN MATCHES "[0-9]+")
message(WARNING "Could not detect a valid UID_MIN (got '${UID_MIN}'). You should review your login.defs file.")
set(UID_MIN 1000)
else()
message(STATUS "Autodetected UID_MIN=${UID_MIN} from ${LOGIN_DEFS_PATH}")
endif()
endif()
if(NOT DEFINED UID_MAX)
file(STRINGS "${LOGIN_DEFS_PATH}" UID_MAX LIMIT_COUNT 1 REGEX "^UID_MAX")
string(REGEX REPLACE "^UID_MAX[\t ]+([0-9]+)" "\\1" UID_MAX "${UID_MAX}")
if(NOT UID_MAX MATCHES "[0-9]+")
message(WARNING "Could not detect a valid UID_MAX (got '${UID_MAX}'). You should review your login.defs file.")
set(UID_MAX 65000)
else()
message(STATUS "Autodetected UID_MAX=${UID_MAX} from ${LOGIN_DEFS_PATH}")
endif()
endif()
# Add subdirectories
add_subdirectory(components)
add_subdirectory(data)
add_subdirectory(services)
add_subdirectory(src)
enable_testing()
add_subdirectory(test)
# Display feature summary
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)