Merge branch 'master' of git.lxde.org:/lxde/liblxqt
[lxde/liblxqt.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8.11)
2
3 project(liblxqt)
4
5 set(LXQT_MAJOR_VERSION 0)
6 set(LXQT_MINOR_VERSION 8)
7 set(LXQT_PATCH_VERSION 0)
8
9 # Set default installation paths
10 set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries")
11 set(LXQT_PKG_CONFIG_DESCRIPTION "Shared library for LXQt applications")
12
13 set(PUB_HDRS
14     aboutdialog/lxqtaboutdialog.h
15     addplugindialog/lxqtaddplugindialog.h
16     lxqthtmldelegate.h
17     lxqtsettings.h
18     lxqtplugininfo.h
19     lxqtpowermanager.h
20     lxqtscreensaver.h
21     lxqtapplication.h
22     lxqtsingleapplication.h
23     lxqttranslator.h
24     lxqtprogramfinder.h
25
26     configdialog/lxqtconfigdialog.h
27     configdialog/lxqtpageselectwidget.h
28
29     lxqtpower/lxqtpower.h
30     lxqtnotification.h
31     lxqtautostartentry.h
32     lxqtgridlayout.h
33     lxqtrotatedwidget.h
34     lxqtglobals.h
35 )
36
37 set(PUBLIC_CLASSES
38     AboutDialog
39     HtmlDelegate
40     Settings
41     PluginInfo
42     PowerManager
43     AddPluginDialog
44     ScreenSaver
45     Application
46     SingleApplication
47     Translator
48     ProgramFinder
49
50     ConfigDialog
51     PageSelectWidget
52
53     Power
54     Notification
55     AutostartEntry
56     GridLayout
57     RotatedWidget
58 )
59
60 set(PRIV_HDRS
61     aboutdialog/lxqtaboutdialog_p.h
62     aboutdialog/technicalinfo.h
63     translatorsinfo/translatorsinfo.h
64 )
65
66 set(SRCS
67     aboutdialog/lxqtaboutdialog.cpp
68     aboutdialog/technicalinfo.cpp
69     lxqthtmldelegate.cpp
70     lxqtplugininfo.cpp
71     lxqtpowermanager.cpp
72     addplugindialog/lxqtaddplugindialog.cpp
73     lxqtsettings.cpp
74     lxqtscreensaver.cpp
75     lxqtapplication.cpp
76     lxqtsingleapplication.cpp
77     lxqttranslator.cpp
78     lxqtprogramfinder.cpp
79
80     configdialog/lxqtconfigdialog.cpp
81     configdialog/lxqtpageselectwidget.cpp
82
83     lxqtpower/lxqtpower.cpp
84     lxqtpower/lxqtpowerproviders.cpp
85     lxqtautostartentry.cpp
86     lxqtnotification.cpp
87     lxqtgridlayout.cpp
88     lxqtrotatedwidget.cpp
89     translatorsinfo/translatorsinfo.cpp
90 )
91
92 set(MOCS
93     aboutdialog/lxqtaboutdialog.h
94     aboutdialog/lxqtaboutdialog_p.h
95     addplugindialog/lxqtaddplugindialog.h
96     lxqthtmldelegate.h
97     lxqtpowermanager.h
98     lxqtsettings.h
99     lxqtscreensaver.h
100     lxqtapplication.h
101
102     configdialog/lxqtconfigdialog.h
103     configdialog/lxqtpageselectwidget.h
104
105     lxqtnotification.h
106     lxqtnotification_p.h
107     lxqtpower/lxqtpower.h
108     lxqtpower/lxqtpowerproviders.h
109     lxqtgridlayout.h
110     lxqtrotatedwidget.h
111 )
112
113 set(FORMS
114     aboutdialog/lxqtaboutdialog.ui
115     configdialog/lxqtconfigdialog.ui
116     addplugindialog/lxqtaddplugindialog.ui
117 )
118
119 # additional cmake files
120 list(APPEND CMAKE_MODULE_PATH
121     ${CMAKE_CURRENT_SOURCE_DIR}/cmake
122     ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules
123 )
124
125 option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files" OFF)
126
127 set(CMAKE_INCLUDE_CURRENT_DIR ON)
128 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
129
130 set(CMAKE_AUTOMOC ON)
131 find_package(Qt5Widgets REQUIRED QUIET)
132 find_package(Qt5DBus REQUIRED QUIET)
133 find_package(Qt5X11Extras REQUIRED QUIET)
134 find_package(Qt5LinguistTools REQUIRED QUIET)
135 find_package(Qt5Xdg REQUIRED)
136 find_package(KF5WindowSystem REQUIRED QUIET)
137 message(STATUS "Building with Qt ${Qt5Core_VERSION_STRING}")
138
139 QT5_WRAP_UI(UIS ${FORMS})
140
141 QT5_ADD_DBUS_INTERFACE(SRCS
142     dbus/org.freedesktop.Notifications.xml
143     notifications_interface
144 )
145
146 QT5_ADD_DBUS_ADAPTOR(SRCS
147     dbus/org.lxqt.SingleApplication.xml
148     lxqtsingleapplication.h LxQt::SingleApplication
149 )
150
151 set(LXQT_QT_VERSION "5")
152
153 # KF5WindowSystem is missing here. KF5WindowSystem doesn't provide an .pc file.
154 set(LXQT_PKG_CONFIG_REQUIRES "Qt5Widgets Qt5Xml Qt5DBus Qt5X11Extras")
155
156 include(${QTXDG_USE_FILE})
157
158 include_directories(
159     "${QTXDG_INCLUDE_DIRS}"
160 )
161
162 # Standard directories for installation
163 include(GNUInstallDirs)
164
165 set(LXQT_VERSION ${LXQT_MAJOR_VERSION}.${LXQT_MINOR_VERSION}.${LXQT_PATCH_VERSION})
166 set(LXQT_LIBRARY_NAME "lxqt" CACHE STRING "lxqt")
167 set(LXQT_RELATIVE_SHARE_DIR "${LXQT_LIBRARY_NAME}")
168 set(LXQT_SHARE_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/${LXQT_RELATIVE_SHARE_DIR}")
169 set(LXQT_RELATIVE_TRANSLATIONS_DIR "${LXQT_LIBRARY_NAME}/translations")
170 set(LXQT_TRANSLATIONS_DIR "${LXQT_SHARE_DIR}/translations")
171
172 set(LXQT_INTREE_INCLUDE_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include")
173 set(LXQT_INTREE_TARGETS_FILE "${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}-targets.cmake")
174
175 set(LXQT_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}/${LXQT_LIBRARY_NAME}")
176 set(LXQT_INSTALL_CMAKE_DIR "${CMAKE_INSTALL_PREFIX}/share/cmake")
177
178 include(cmake/FindInstallConfigPath.cmake)
179 include(create_portable_headers)
180
181 ## Translations
182 include(LXQtTranslateTs)
183
184 lxqt_translate_ts(QM_FILES
185     UPDATE_TRANSLATIONS
186         ${UPDATE_TRANSLATIONS}
187     SOURCES
188         ${SRCS}
189         ${FORMS}
190     INSTALL_DIR
191         ${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME}
192 )
193
194 message(STATUS "")
195 message(STATUS "liblxqt version: ${LXQT_VERSION}")
196 message(STATUS "")
197
198
199 # Copy public headers
200 foreach(h ${PUB_HDRS})
201     get_filename_component(bh ${h} NAME)
202     configure_file(${h} "${LXQT_INTREE_INCLUDE_DIR}/LXQt/${bh}" COPYONLY)
203 endforeach()
204
205 # Create the portable headers
206 create_portable_headers(INTREE_PORTABLE_HEADERS ${LXQT_INTREE_INCLUDE_DIR}/LXQt ${PUBLIC_CLASSES})
207 check_portable_headers(H_FILES ${PUB_HDRS} LINKS ${INTREE_PORTABLE_HEADERS})
208
209 #************************************************
210 # Create in-tree build infrastructure
211 #************************************************
212 set(CFG_LXQT_INCLUDE_DIR    ${LXQT_INTREE_INCLUDE_DIR})
213 set(CFG_LXQT_LIBRARY        ${LXQT_LIBRARY_NAME})
214 set(CFG_LXQT_USE_FILE       ${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}_use.cmake)
215 set(CFG_LXQT_TARGETS_FILE   ${LXQT_INTREE_TARGETS_FILE})
216 set(CFG_LXQT_CMAKE_MODULES_DIR "${PROJECT_SOURCE_DIR}/cmake/modules")
217
218 configure_file(
219     ${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqtX-config.cmake.in
220     ${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}-config.cmake
221     @ONLY
222 )
223
224 configure_file(
225     ${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt_use.cmake.in
226     ${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}_use.cmake
227     @ONLY
228 )
229
230 include(${CFG_LXQT_USE_FILE})
231
232
233 #************************************************
234 # Create installable build infrastructure
235 #************************************************
236 set(CFG_LXQT_INCLUDE_DIR "${LXQT_INSTALL_INCLUDE_DIR}")
237 set(CFG_LXQT_LIBRARY ${LXQT_LIBRARY_NAME})
238 set(CFG_LXQT_USE_FILE "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}/${LXQT_LIBRARY_NAME}_use.cmake")
239 set(CFG_LXQT_TARGETS_FILE "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}/${LXQT_LIBRARY_NAME}-targets.cmake")
240 set(CFG_LXQT_CMAKE_MODULES_DIR "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}/modules")
241
242 configure_file(
243     "${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqtX-config.cmake.in"
244     "${CMAKE_CURRENT_BINARY_DIR}/install/${LXQT_LIBRARY_NAME}-config.cmake"
245     @ONLY
246 )
247
248 # use gcc visibility feature to decrease unnecessary exported symbols
249 if (CMAKE_COMPILER_IS_GNUCXX)
250     # set visibility to hidden to hide symbols, unlesss they're exported
251     # manually in the code
252     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wl,-no-undefined -Wall")
253 endif()
254 add_definitions(-DCOMPILE_LIBLXQT)
255
256
257 configure_file(
258     ${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt_use.cmake.in
259     ${CMAKE_CURRENT_BINARY_DIR}/install/${LXQT_LIBRARY_NAME}_use.cmake
260     @ONLY
261 )
262
263 install(FILES
264     ${CMAKE_CURRENT_BINARY_DIR}/install/${LXQT_LIBRARY_NAME}-config.cmake
265     ${CMAKE_CURRENT_BINARY_DIR}/install/${LXQT_LIBRARY_NAME}_use.cmake
266     DESTINATION ${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}
267     COMPONENT Devel
268 )
269
270 install(EXPORT
271     ${LXQT_LIBRARY_NAME}-targets
272     DESTINATION ${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}
273     COMPONENT Devel
274 )
275
276 file(GLOB toInstallModules
277     "${PROJECT_SOURCE_DIR}/cmake/modules/*.cmake"
278     "${PROJECT_SOURCE_DIR}/cmake/modules/*.in"
279 )
280
281 install(
282     FILES ${toInstallModules}
283     DESTINATION  "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}/modules"
284     COMPONENT Devel
285 )
286
287
288 include(translatorsinfo/CMakeLists.txt)
289 get_translatorsinfo_qrc(translatorsinfo_qrc)
290 qt5_add_resources(QRC_CXX_SOURCES ${translatorsinfo_qrc})
291
292 add_library(${LXQT_LIBRARY_NAME}
293     SHARED ${PUB_HDRS}
294            ${PRIV_HDRS}
295            ${SRCS}
296            ${dbus_generated}
297            ${UIS} ${MOCS}
298            ${QM_FILES}
299            ${QRC_CXX_SOURCES}
300
301 )
302
303 target_link_libraries(${LXQT_LIBRARY_NAME}
304     KF5::WindowSystem
305     Qt5::Widgets
306     Qt5::DBus
307     Qt5::X11Extras
308     ${QTXDG_LIBRARIES}
309 )
310
311 set_target_properties(${LXQT_LIBRARY_NAME} PROPERTIES
312     VERSION   ${LXQT_VERSION}
313     SOVERSION ${LXQT_MAJOR_VERSION}
314 )
315
316 install(TARGETS
317     ${LXQT_LIBRARY_NAME}
318     DESTINATION ${CMAKE_INSTALL_LIBDIR}
319     EXPORT ${LXQT_LIBRARY_NAME}-targets
320     LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
321 )
322
323
324 export(TARGETS ${LXQT_LIBRARY_NAME} ${QTXDG_TARGET} FILE ${LXQT_INTREE_TARGETS_FILE})
325
326 install(FILES ${PUB_HDRS} DESTINATION "${LXQT_INSTALL_INCLUDE_DIR}/LXQt")
327 install(FILES ${INTREE_PORTABLE_HEADERS} DESTINATION "${LXQT_INSTALL_INCLUDE_DIR}/LXQt")
328
329 #************************************************
330 # Create pkgconfig file
331 #************************************************
332 lxqt_create_pkgconfig_file(${LXQT_LIBRARY_NAME}
333     ${LXQT_PKG_CONFIG_DESCRIPTION}
334     ${LXQT_PKG_CONFIG_REQUIRES}
335     ${LXQT_LIBRARY_NAME}
336     ${LXQT_VERSION}
337 )
338 #************************************************
339
340
341 # building tarball with CPack -------------------------------------------------
342 include(InstallRequiredSystemLibraries)
343 set(CPACK_PACKAGE_VERSION_MAJOR ${LXQT_MAJOR_VERSION})
344 set(CPACK_PACKAGE_VERSION_MINOR ${LXQT_MINOR_VERSION})
345 set(CPACK_PACKAGE_VERSION_PATCH ${LXQT_PATCH_VERSION})
346 set(CPACK_GENERATOR TBZ2)
347 set(CPACK_SOURCE_GENERATOR TBZ2)
348 set(CPACK_SOURCE_IGNORE_FILES /build/;.gitignore;.*~;.git;.kdev4;temp)
349 include(CPack)