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