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