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