-
Notifications
You must be signed in to change notification settings - Fork 50
/
CMakeLists.txt
406 lines (337 loc) · 11.3 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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
cmake_minimum_required(VERSION 3.18.0 FATAL_ERROR)
# CMP0000: Call the cmake_minimum_required() command at the beginning of the top-level
# CMakeLists.txt file even before calling the project() command.
# The cmake_minimum_required(VERSION) command implicitly invokes the cmake_policy(VERSION)
# command to specify that the current project code is written for the given range of CMake
# versions.
project(liblxqt)
set(LXQTBT_MINIMUM_VERSION "2.1.0")
set(KF6_MINIMUM_VERSION "6.0.0")
set(QT_MINIMUM_VERSION "6.6.0")
set(QTXDG_MINIMUM_VERSION "4.1.0")
# Major LXQt Version, belong to all components
set(LXQT_MAJOR_VERSION 2)
# Minor LXQt Version, belong to all components
set(LXQT_MINOR_VERSION 1)
#
# Patch Version, belong *only* to the component
# LXQt is 0.13 - liblxqt is at patch version 0
# The official LXQt version will follow liblxqt.
#
# In a perfect world all components would have the same major- and minor- and
# patch-version as liblxqt - in real life it will be fine if every component
# has it's own patch version within a major/minor life cyle.
#
set(LXQT_PATCH_VERSION 0)
set(LXQT_VERSION ${LXQT_MAJOR_VERSION}.${LXQT_MINOR_VERSION}.${LXQT_PATCH_VERSION})
option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files" OFF)
option(BUILD_BACKLIGHT_LINUX_BACKEND "Build the Linux backend for the backlight" ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
find_package(lxqt2-build-tools ${LXQTBT_MINIMUM_VERSION} REQUIRED)
find_package(Qt6 ${QT_MINIMUM_VERSION} CONFIG REQUIRED Widgets DBus LinguistTools)
find_package(Qt6Xdg ${QTXDG_MINIMUM_VERSION} REQUIRED)
find_package(KF6WindowSystem ${KF6_MINIMUM_VERSION} REQUIRED)
if (BUILD_BACKLIGHT_LINUX_BACKEND)
find_package(PolkitQt6-1 REQUIRED)
endif (BUILD_BACKLIGHT_LINUX_BACKEND)
if (NOT APPLE)
find_package(X11 REQUIRED)
endif()
message(STATUS "Building ${PROJECT_NAME} with Qt ${Qt6Core_VERSION}")
include(CMakePackageConfigHelpers)
include(GNUInstallDirs) # Standard directories for installation
if (BUILD_BACKLIGHT_LINUX_BACKEND)
add_subdirectory(lxqtbacklight/linux_backend/driver)
add_definitions(-DUSE_BACKLIGHT_LINUX_BACKEND)
endif (BUILD_BACKLIGHT_LINUX_BACKEND)
set(LXQT_PKG_CONFIG_DESCRIPTION "Shared library for LXQt applications")
set(PUB_HDRS
lxqthtmldelegate.h
lxqtsettings.h
lxqtplugininfo.h
lxqtpowermanager.h
lxqtapplication.h
lxqtsingleapplication.h
lxqttranslator.h
lxqtprogramfinder.h
configdialog/lxqtconfigdialog.h
configdialog/lxqtconfigdialogcmdlineoptions.h
configdialog/lxqtpageselectwidget.h
lxqtpower/lxqtpower.h
lxqtnotification.h
lxqtautostartentry.h
lxqtgridlayout.h
lxqtrotatedwidget.h
lxqtglobals.h
lxqtbacklight.h
#lxqtbacklight/virtual_backend.h
#lxqtbacklight/linux_backend/linuxbackend.h
)
if (NOT APPLE)
list (APPEND PUB_HDRS
lxqtscreensaver.h
)
endif (NOT APPLE)
set(PUBLIC_CLASSES
HtmlDelegate
Settings
PluginInfo
PowerManager
Application
SingleApplication
Translator
ProgramFinder
ConfigDialog
ConfigDialogCmdLineOptions
PageSelectWidget
Power
Notification
AutostartEntry
GridLayout
RotatedWidget
Globals
Backlight
)
if (NOT APPLE)
list (APPEND PUBLIC_CLASSES
ScreenSaver
)
endif (NOT APPLE)
set(SRCS
lxqthtmldelegate.cpp
lxqtplugininfo.cpp
lxqtpowermanager.cpp
lxqtsettings.cpp
lxqtapplication.cpp
lxqtsingleapplication.cpp
lxqttranslator.cpp
lxqtprogramfinder.cpp
configdialog/lxqtconfigdialog.cpp
configdialog/lxqtconfigdialogcmdlineoptions.cpp
configdialog/lxqtpageselectwidget.cpp
lxqtpower/lxqtpower.cpp
lxqtpower/lxqtpowerproviders.cpp
lxqtautostartentry.cpp
lxqtnotification.cpp
lxqtgridlayout.cpp
lxqtrotatedwidget.cpp
lxqtbacklight.cpp
lxqtbacklight/virtual_backend.cpp
)
if (NOT APPLE)
list (APPEND SRCS
lxqtscreensaver.cpp
)
endif (NOT APPLE)
if (BUILD_BACKLIGHT_LINUX_BACKEND)
list (APPEND SRCS
lxqtbacklight/linux_backend/linuxbackend.cpp
)
endif (BUILD_BACKLIGHT_LINUX_BACKEND)
set(MOCS
lxqthtmldelegate.h
lxqtpowermanager.h
lxqtsettings.h
lxqtapplication.h
lxqtbacklight.h
configdialog/lxqtconfigdialog.h
configdialog/lxqtconfigdialog_p.h
configdialog/lxqtpageselectwidget.h
lxqtnotification.h
lxqtnotification_p.h
lxqtpower/lxqtpower.h
lxqtpower/lxqtpowerproviders.h
lxqtgridlayout.h
lxqtrotatedwidget.h
lxqtbacklight/virtual_backend.h
)
if (NOT APPLE)
list (APPEND MOCS
lxqtscreensaver.h
)
endif (NOT APPLE)
if (BUILD_BACKLIGHT_LINUX_BACKEND)
list (APPEND SRCS
lxqtbacklight/linux_backend/linuxbackend.h
)
endif (BUILD_BACKLIGHT_LINUX_BACKEND)
set(FORMS
configdialog/lxqtconfigdialog.ui
)
set(POLKIT_FILES
"${CMAKE_CURRENT_BINARY_DIR}/org.lxqt.backlight.pkexec.policy"
)
# Build Polkit file
configure_file ( polkit/org.lxqt.backlight.pkexec.policy.in "${CMAKE_CURRENT_BINARY_DIR}/org.lxqt.backlight.pkexec.policy" )
file(GLOB LXQT_CONFIG_FILES resources/*.conf)
qt6_add_dbus_interface(DBUS_INTERFACE_SRCS
dbus/org.freedesktop.Notifications.xml
notifications_interface
)
qt6_add_dbus_adaptor(DBUS_ADAPTOR_SRCS
dbus/org.lxqt.SingleApplication.xml
lxqtsingleapplication.h LXQt::SingleApplication
)
set_property(SOURCE ${DBUS_INTERFACE_SRCS} ${DBUS_ADAPTOR_SRCS} PROPERTY SKIP_AUTOGEN ON)
list(APPEND SRCS "${DBUS_INTERFACE_SRCS}" "${DBUS_ADAPTOR_SRCS}")
# KF6WindowSystem is missing here. KF5WindowSystem doesn't provide an .pc file. TODO: check if things changed in KF6
set(LXQT_PKG_CONFIG_REQUIRES "Qt6Xdg >= ${QTXDG_MINIMUM_VERSION}, Qt6Widgets >= ${QT_MINIMUM_VERSION}, Qt6Xml >= ${QT_MINIMUM_VERSION}, Qt6DBus >= ${QT_MINIMUM_VERSION}")
# Standard directories for installation
include(LXQtPreventInSourceBuilds)
include(LXQtCompilerSettings NO_POLICY_SCOPE)
include(LXQtCreatePkgConfigFile)
include(LXQtCreatePortableHeaders)
include(LXQtConfigVars)
set(LXQT_INTREE_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include")
set(LXQT_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}/${LXQT_LIBRARY_NAME}")
set(LXQT_INSTALL_CMAKE_DIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}/cmake")
## Translations
include(LXQtTranslateTs)
lxqt_translate_ts(QM_FILES
UPDATE_TRANSLATIONS
${UPDATE_TRANSLATIONS}
SOURCES
${SRCS}
${FORMS}
INSTALL_DIR
"${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME}"
)
message(STATUS "")
message(STATUS "liblxqt version: ${LXQT_VERSION}")
message(STATUS "")
# Copy public headers
foreach(h ${PUB_HDRS})
get_filename_component(bh ${h} NAME)
configure_file(${h} "${LXQT_INTREE_INCLUDE_DIR}/LXQt/${bh}" COPYONLY)
endforeach()
# Create the portable headers
lxqt_create_portable_headers(INTREE_PORTABLE_HEADERS
NAME_PREFIX "lxqt"
OUTPUT_DIR "${LXQT_INTREE_INCLUDE_DIR}/LXQt"
HEADER_NAMES ${PUBLIC_CLASSES}
)
#check_portable_headers(H_FILES ${PUB_HDRS} LINKS "${INTREE_PORTABLE_HEADERS}")
#************************************************
# Create in-tree build infrastructure
#************************************************
set(CFG_LXQT_TARGETS_FILE "${LXQT_INTREE_TARGETS_FILE}")
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt-config.cmake.in"
"${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}-config.cmake"
INSTALL_DESTINATION "neverland" # required, altough we don't install it
)
#************************************************
# Create installable build infrastructure
#************************************************
set(CFG_LXQT_TARGETS_FILE "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}/${LXQT_LIBRARY_NAME}-targets.cmake")
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/install/${LXQT_LIBRARY_NAME}-config.cmake"
INSTALL_DESTINATION "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}"
)
write_basic_package_version_file(
"${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}-config-version.cmake"
VERSION ${LXQT_VERSION}
COMPATIBILITY AnyNewerVersion
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/install/${LXQT_LIBRARY_NAME}-config.cmake"
"${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}-config-version.cmake"
DESTINATION "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}"
COMPONENT Devel
)
install(EXPORT
${LXQT_LIBRARY_NAME}-targets
DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/${LXQT_LIBRARY_NAME}"
COMPONENT Devel
)
add_library(${LXQT_LIBRARY_NAME}
SHARED ${PUB_HDRS}
${SRCS}
${dbus_generated}
${UIS} ${MOCS}
${QM_FILES}
${QRC_CXX_SOURCES}
)
target_link_libraries(${LXQT_LIBRARY_NAME}
PUBLIC
KF6::WindowSystem
Qt6::Widgets
Qt6::DBus
Qt6Xdg
)
if (NOT APPLE)
target_link_libraries(${LXQT_LIBRARY_NAME}
PRIVATE
${X11_Xscreensaver_LIB}
${X11_X11_LIB}
)
endif (NOT APPLE)
set_target_properties(${LXQT_LIBRARY_NAME} PROPERTIES
VERSION ${LXQT_VERSION}
SOVERSION ${LXQT_MAJOR_VERSION}
)
target_compile_definitions(${LXQT_LIBRARY_NAME}
PRIVATE
"LXQT_RELATIVE_SHARE_DIR=\"${LXQT_RELATIVE_SHARE_DIR}\""
"LXQT_SHARE_DIR=\"${LXQT_SHARE_DIR}\""
"LXQT_RELATIVE_SHARE_TRANSLATIONS_DIR=\"${LXQT_RELATIVE_TRANSLATIONS_DIR}\""
"LXQT_SHARE_TRANSLATIONS_DIR=\"${LXQT_TRANSLATIONS_DIR}\""
"LXQT_GRAPHICS_DIR=\"${LXQT_GRAPHICS_DIR}\""
"LXQT_ETC_XDG_DIR=\"${LXQT_ETC_XDG_DIR}\""
"LXQT_DATA_DIR=\"${LXQT_DATA_DIR}\""
"LXQT_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\""
"LXQT_VERSION=\"${LXQT_VERSION}\""
"COMPILE_LIBLXQT"
"$<$<CONFIG:Release>:QT_NO_DEBUG_OUTPUT>"
"$<$<CONFIG:Release>:QT_NO_WARNING_OUTPUT>"
"QT_NO_KEYWORDS"
)
target_include_directories(${LXQT_LIBRARY_NAME}
INTERFACE
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${LXQT_LIBRARY_NAME}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${LXQT_LIBRARY_NAME}/LXQt>"
"$<BUILD_INTERFACE:${LXQT_INTREE_INCLUDE_DIR}>"
"$<BUILD_INTERFACE:${LXQT_INTREE_INCLUDE_DIR}/LXQt>"
)
install(TARGETS
${LXQT_LIBRARY_NAME}
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
EXPORT ${LXQT_LIBRARY_NAME}-targets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT Runtime
)
install(FILES
${PUB_HDRS}
DESTINATION "${LXQT_INSTALL_INCLUDE_DIR}/LXQt"
COMPONENT Devel
)
install(FILES
${INTREE_PORTABLE_HEADERS}
DESTINATION "${LXQT_INSTALL_INCLUDE_DIR}/LXQt"
COMPONENT Devel
)
install(FILES ${LXQT_CONFIG_FILES}
DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/lxqt"
COMPONENT Runtime
)
if (BUILD_BACKLIGHT_LINUX_BACKEND)
install(FILES ${POLKIT_FILES} DESTINATION "${POLKITQT-1_POLICY_FILES_INSTALL_DIR}")
endif (BUILD_BACKLIGHT_LINUX_BACKEND)
#************************************************
# Create and install pkgconfig file
#************************************************
lxqt_create_pkgconfig_file(
PACKAGE_NAME ${LXQT_LIBRARY_NAME}
DESCRIPTIVE_NAME ${LXQT_LIBRARY_NAME}
DESCRIPTION ${LXQT_PKG_CONFIG_DESCRIPTION}
INCLUDEDIRS ${LXQT_LIBRARY_NAME}
LIBS ${LXQT_LIBRARY_NAME}
REQUIRES ${LXQT_PKG_CONFIG_REQUIRES}
VERSION ${LXQT_VERSION}
INSTALL
)
#************************************************