forked from lxqt/liblxqt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
328 lines (267 loc) · 9.19 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
cmake_minimum_required(VERSION 2.8.9)
project(liblxqt)
set(LXQT_MAJOR_VERSION 0)
set(LXQT_MINOR_VERSION 8)
set(LXQT_PATCH_VERSION 0)
# Set default installation paths
set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries")
set(LXQT_PKG_CONFIG_DESCRIPTION "Shared library for LXQt applications")
set(PUB_HDRS
aboutdialog/lxqtaboutdialog.h
addplugindialog/lxqtaddplugindialog.h
lxqtsettings.h
lxqtxfitman.h
lxqtplugininfo.h
lxqtpowermanager.h
lxqtscreensaver.h
lxqtapplication.h
lxqttranslator.h
lxqtprogramfinder.h
configdialog/lxqtconfigdialog.h
configdialog/lxqtpageselectwidget.h
lxqtpower/lxqtpower.h
lxqtnotification.h
lxqtautostartentry.h
lxqtgridlayout.h
lxqtrotatedwidget.h
lxqtglobals.h
)
set(PUBLIC_CLASSES
AboutDialog
Settings
XfitMan
PluginInfo
PowerManager
AddPluginDialog
ScreenSaver
Application
Translator
ProgramFinder
ConfigDialog
PageSelectWidget
Power
Notification
AutostartEntry
GridLayout
RotatedWidget
)
set(PRIV_HDRS
aboutdialog/lxqtaboutdialog_p.h
aboutdialog/technicalinfo.h
translatorsinfo/translatorsinfo.h
)
set(SRCS
aboutdialog/lxqtaboutdialog.cpp
aboutdialog/technicalinfo.cpp
lxqtxfitman.cpp
lxqtplugininfo.cpp
lxqtpowermanager.cpp
addplugindialog/lxqtaddplugindialog.cpp
lxqtsettings.cpp
lxqtscreensaver.cpp
lxqtapplication.cpp
lxqttranslator.cpp
lxqtprogramfinder.cpp
configdialog/lxqtconfigdialog.cpp
configdialog/lxqtpageselectwidget.cpp
lxqtpower/lxqtpower.cpp
lxqtpower/lxqtpowerproviders.cpp
lxqtautostartentry.cpp
lxqtnotification.cpp
lxqtgridlayout.cpp
lxqtrotatedwidget.cpp
translatorsinfo/translatorsinfo.cpp
)
set(MOCS
aboutdialog/lxqtaboutdialog.h
aboutdialog/lxqtaboutdialog_p.h
addplugindialog/lxqtaddplugindialog.h
lxqtpowermanager.h
lxqtsettings.h
lxqtscreensaver.h
lxqtapplication.h
configdialog/lxqtconfigdialog.h
configdialog/lxqtpageselectwidget.h
lxqtnotification.h
lxqtnotification_p.h
lxqtpower/lxqtpower.h
lxqtpower/lxqtpowerproviders.h
lxqtgridlayout.h
lxqtrotatedwidget.h
)
set(FORMS
aboutdialog/lxqtaboutdialog.ui
configdialog/lxqtconfigdialog.ui
addplugindialog/lxqtaddplugindialog.ui
)
set(TRANSLATION_TEMPLATE "${CMAKE_CURRENT_SOURCE_DIR}/translations/source.ts")
file(GLOB TS_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/translations/liblxqt_*.ts"
)
# additional cmake files
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_AUTOMOC ON)
find_package(Qt5Widgets REQUIRED QUIET)
find_package(Qt5DBus REQUIRED QUIET)
find_package(Qt5X11Extras REQUIRED QUIET)
find_package(Qt5LinguistTools REQUIRED QUIET)
find_package(Qt5Xdg REQUIRED)
message(STATUS "Building with Qt ${Qt5Core_VERSION_STRING}")
QT5_WRAP_UI(UIS ${FORMS})
if (UPDATE_TRANSLATIONS)
qt5_create_translation(QM_FILES ${SRCS} ${FORMS} ${TS_FILES} OPTIONS -locations absolute)
qt5_create_translation(TS_SOURCE_FILE
${SRCS} ${FORMS}
${TRANSLATION_TEMPLATE}
OPTIONS -locations absolute
)
else()
QT5_ADD_TRANSLATION(QM_FILES ${TS_FILES})
endif()
QT5_ADD_DBUS_INTERFACE(SRCS
dbus/org.freedesktop.Notifications.xml
notifications_interface
)
set(LXQT_QT_VERSION "5")
set(LXQT_QT_VERSION_SUFFIX "-qt5")
set(LXQT_PKG_CONFIG_REQUIRES "Qt5Widgets Qt5Xml Qt5DBus Qt5X11Extras")
include(${QTXDG_USE_FILE})
find_package(X11 REQUIRED QUIET)
include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}"
"${X11_INCLUDE_DIR}"
"${QTXDG_INCLUDE_DIRS}"
)
# Standard directories for installation
include(GNUInstallDirs)
set(LXQT_VERSION ${LXQT_MAJOR_VERSION}.${LXQT_MINOR_VERSION}.${LXQT_PATCH_VERSION})
set(LXQT_LIBRARY_NAME "lxqt${LXQT_QT_VERSION_SUFFIX}")
set(LXQT_RELATIVE_SHARE_DIR "${LXQT_LIBRARY_NAME}")
set(LXQT_SHARE_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/${LXQT_RELATIVE_SHARE_DIR}")
set(LXQT_RELATIVE_TRANSLATIONS_DIR "${LXQT_LIBRARY_NAME}/translations")
set(LXQT_TRANSLATIONS_DIR "${LXQT_SHARE_DIR}/translations")
set(LXQT_INTREE_INCLUDE_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include")
set(LXQT_INTREE_TARGETS_FILE "${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}-targets.cmake")
set(LXQT_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}/${LXQT_LIBRARY_NAME}")
set(LXQT_INSTALL_CMAKE_DIR "${CMAKE_INSTALL_PREFIX}/share/cmake")
include(cmake/FindInstallConfigPath.cmake)
include(create_portable_headers)
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
create_portable_headers(INTREE_PORTABLE_HEADERS ${LXQT_INTREE_INCLUDE_DIR}/LXQt ${PUBLIC_CLASSES})
check_portable_headers(H_FILES ${PUB_HDRS} LINKS ${INTREE_PORTABLE_HEADERS})
#************************************************
# Create in-tree build infrastructure
#************************************************
set(CFG_LXQT_INCLUDE_DIR ${LXQT_INTREE_INCLUDE_DIR})
set(CFG_LXQT_LIBRARY ${LXQT_LIBRARY_NAME})
set(CFG_LXQT_USE_FILE ${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}_use.cmake)
set(CFG_LXQT_TARGETS_FILE ${LXQT_INTREE_TARGETS_FILE})
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqtX-config.cmake.in
${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}-config.cmake
@ONLY
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt_use.cmake.in
${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}_use.cmake
@ONLY
)
include(${CFG_LXQT_USE_FILE})
#************************************************
# Create installable build infrastructure
#************************************************
set(CFG_LXQT_INCLUDE_DIR "${LXQT_INSTALL_INCLUDE_DIR}")
set(CFG_LXQT_LIBRARY ${LXQT_LIBRARY_NAME})
set(CFG_LXQT_USE_FILE "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}/${LXQT_LIBRARY_NAME}_use.cmake")
set(CFG_LXQT_TARGETS_FILE "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}/${LXQT_LIBRARY_NAME}-targets.cmake")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqtX-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/install/${LXQT_LIBRARY_NAME}-config.cmake"
@ONLY
)
# use gcc visibility feature to decrease unnecessary exported symbols
if (CMAKE_COMPILER_IS_GNUCXX)
# set visibility to hidden to hide symbols, unlesss they're exported
# manually in the code
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wl,-no-undefined -Wall")
endif()
add_definitions(-DCOMPILE_LIBLXQT)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt_use.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/install/${LXQT_LIBRARY_NAME}_use.cmake
@ONLY
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/install/${LXQT_LIBRARY_NAME}-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/install/${LXQT_LIBRARY_NAME}_use.cmake
DESTINATION ${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}
COMPONENT Devel
)
install(EXPORT
${LXQT_LIBRARY_NAME}-targets
DESTINATION ${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}
COMPONENT Devel
)
include(translatorsinfo/CMakeLists.txt)
get_translatorsinfo_qrc(translatorsinfo_qrc)
qt5_add_resources(QRC_CXX_SOURCES ${translatorsinfo_qrc})
add_library(${LXQT_LIBRARY_NAME}
SHARED ${PUB_HDRS}
${PRIV_HDRS}
${SRCS}
${dbus_generated}
${UIS} ${MOCS}
${QM_FILES}
${TS_SOURCE_FILE}
${QRC_CXX_SOURCES}
)
qt5_use_modules(${LXQT_LIBRARY_NAME} Widgets DBus X11Extras)
target_link_libraries(${LXQT_LIBRARY_NAME}
${X11_X11_LIB}
${QTXDG_LIBRARIES}
)
set_target_properties(${LXQT_LIBRARY_NAME} PROPERTIES
VERSION ${LXQT_VERSION}
SOVERSION ${LXQT_MAJOR_VERSION}
)
install(TARGETS
${LXQT_LIBRARY_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR}
EXPORT ${LXQT_LIBRARY_NAME}-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
)
export(TARGETS ${LXQT_LIBRARY_NAME} ${QTXDG_TARGET} FILE ${LXQT_INTREE_TARGETS_FILE})
install(FILES ${PUB_HDRS} DESTINATION "${LXQT_INSTALL_INCLUDE_DIR}/LXQt")
install(FILES ${INTREE_PORTABLE_HEADERS} DESTINATION "${LXQT_INSTALL_INCLUDE_DIR}/LXQt")
install(FILES ${QM_FILES} DESTINATION "${LXQT_TRANSLATIONS_DIR}/liblxqt")
#************************************************
# Create pkgconfig file
#************************************************
lxqt_create_pkgconfig_file(${LXQT_LIBRARY_NAME}
${LXQT_PKG_CONFIG_DESCRIPTION}
${LXQT_PKG_CONFIG_REQUIRES}
${LXQT_LIBRARY_NAME}
${LXQT_VERSION}
)
#************************************************
# building tarball with CPack -------------------------------------------------
include(InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_VERSION_MAJOR ${LXQT_MAJOR_VERSION})
set(CPACK_PACKAGE_VERSION_MINOR ${LXQT_MINOR_VERSION})
set(CPACK_PACKAGE_VERSION_PATCH ${LXQT_PATCH_VERSION})
set(CPACK_GENERATOR TBZ2)
set(CPACK_SOURCE_GENERATOR TBZ2)
set(CPACK_SOURCE_IGNORE_FILES /build/;.gitignore;.*~;.git;.kdev4;temp)
include(CPack)