Make lxqt globals a public header
[lxde/liblxqt.git] / CMakeLists.txt
CommitLineData
a1aa2bec 1cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
0eff6363 2
af223b3d 3project(liblxqt)
0eff6363 4
e90b2212 5set(QT_MINIMUM_VERSION "5.7.1")
45364537 6set(QTXDG_MINIMUM_VERSION "3.1.0")
e90b2212 7set(LXQTBT_MINIMUM_VERSION "0.4.1")
ecc404b4 8
05e41538 9# Major LXQt Version, belong to all components
ada50f1c 10set(LXQT_MAJOR_VERSION 0)
05e41538 11# Minor LXQt Version, belong to all components
3c9ffefb 12set(LXQT_MINOR_VERSION 12)
05e41538
AG
13#
14# Patch Version, belong *only* to the component
15# LXQt is 0.11 - liblxqt is at patch version 1
16# The official LXQt version will follow liblxqt.
17#
18# In a perfect world all components would have the same major- and minor- and
19# patch-version as liblxqt - in real life it will be fine if every component
20# has it's own patch version within a major/minor life cyle.
21#
3c9ffefb 22set(LXQT_PATCH_VERSION 0)
ada50f1c
AG
23set(LXQT_VERSION ${LXQT_MAJOR_VERSION}.${LXQT_MINOR_VERSION}.${LXQT_PATCH_VERSION})
24
4f07364e 25include(CMakePackageConfigHelpers)
06d4bbb6
LP
26include(GNUInstallDirs) # Standard directories for installation
27
06d4bbb6 28#-----------------------------------------------------------------------------
ac768bbc
LP
29# Release is the default build type
30#-----------------------------------------------------------------------------
31if (NOT CMAKE_BUILD_TYPE)
32 set(CMAKE_BUILD_TYPE Release)
33endif()
34
eedae82c 35set(LXQT_PKG_CONFIG_DESCRIPTION "Shared library for LXQt applications")
0eff6363 36
af223b3d 37set(PUB_HDRS
3e7b0203 38 lxqthtmldelegate.h
82830dc2 39 lxqtsettings.h
191d2d13 40 lxqtplugininfo.h
b6483430 41 lxqtpowermanager.h
b6483430 42 lxqtscreensaver.h
077c1e76 43 lxqtapplication.h
7e7ee62a 44 lxqtsingleapplication.h
949dba2f 45 lxqttranslator.h
b6483430 46 lxqtprogramfinder.h
ad7ee7e8 47
b6483430
AS
48 configdialog/lxqtconfigdialog.h
49 configdialog/lxqtpageselectwidget.h
ad7ee7e8 50
8e6db58a 51 lxqtpower/lxqtpower.h
0e4fbf35 52 lxqtnotification.h
739b8f7f 53 lxqtautostartentry.h
f9de00b4 54 lxqtgridlayout.h
b6483430 55 lxqtrotatedwidget.h
f9cba1ba 56 lxqtglobals.h
4ef6cee9 57)
58
b6483430 59set(PUBLIC_CLASSES
3e7b0203 60 HtmlDelegate
f324ccfb 61 Settings
f324ccfb
AS
62 PluginInfo
63 PowerManager
f324ccfb
AS
64 ScreenSaver
65 Application
7e7ee62a 66 SingleApplication
f324ccfb
AS
67 Translator
68 ProgramFinder
69
70 ConfigDialog
71 PageSelectWidget
72
73 Power
74 Notification
75 AutostartEntry
76 GridLayout
77 RotatedWidget
0c93a6d5 78 Globals
af223b3d
AS
79)
80
af223b3d 81set(SRCS
3e7b0203 82 lxqthtmldelegate.cpp
191d2d13 83 lxqtplugininfo.cpp
b6483430 84 lxqtpowermanager.cpp
82830dc2 85 lxqtsettings.cpp
b6483430 86 lxqtscreensaver.cpp
077c1e76 87 lxqtapplication.cpp
7e7ee62a 88 lxqtsingleapplication.cpp
949dba2f 89 lxqttranslator.cpp
b6483430 90 lxqtprogramfinder.cpp
ad7ee7e8 91
b6483430
AS
92 configdialog/lxqtconfigdialog.cpp
93 configdialog/lxqtpageselectwidget.cpp
ad7ee7e8 94
8e6db58a
AS
95 lxqtpower/lxqtpower.cpp
96 lxqtpower/lxqtpowerproviders.cpp
739b8f7f 97 lxqtautostartentry.cpp
b11ac14c 98 lxqtnotification.cpp
f9de00b4 99 lxqtgridlayout.cpp
b6483430 100 lxqtrotatedwidget.cpp
4ef6cee9 101)
102
af223b3d 103set(MOCS
3e7b0203 104 lxqthtmldelegate.h
b11ac14c 105 lxqtpowermanager.h
82830dc2 106 lxqtsettings.h
b6483430 107 lxqtscreensaver.h
077c1e76 108 lxqtapplication.h
ad7ee7e8 109
b6483430
AS
110 configdialog/lxqtconfigdialog.h
111 configdialog/lxqtpageselectwidget.h
ad7ee7e8 112
0e4fbf35
AS
113 lxqtnotification.h
114 lxqtnotification_p.h
8e6db58a
AS
115 lxqtpower/lxqtpower.h
116 lxqtpower/lxqtpowerproviders.h
f9de00b4 117 lxqtgridlayout.h
b6483430 118 lxqtrotatedwidget.h
4ef6cee9 119)
120
af223b3d 121set(FORMS
b6483430 122 configdialog/lxqtconfigdialog.ui
af223b3d
AS
123)
124
5ead57dd
PK
125file(GLOB LXQT_CONFIG_FILES resources/*.conf)
126
fd3dee16 127option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files" OFF)
8c931cd4 128
afd3b116
JL
129set(CMAKE_INCLUDE_CURRENT_DIR ON)
130set(CMAKE_POSITION_INDEPENDENT_CODE ON)
4681206d 131
b11ac14c 132set(CMAKE_AUTOMOC ON)
92ab355b
LP
133set(CMAKE_AUTOUIC ON)
134
eeb0aa36 135find_package(lxqt-build-tools ${LXQTBT_MINIMUM_VERSION} REQUIRED)
cd10d270 136find_package(X11 REQUIRED QUIET)
ecc404b4 137find_package(Qt5 ${QT_MINIMUM_VERSION} CONFIG REQUIRED Widgets DBus X11Extras LinguistTools)
39357b1d 138find_package(Qt5Xdg ${QTXDG_MINIMUM_VERSION} REQUIRED)
7e7ee62a 139find_package(KF5WindowSystem REQUIRED QUIET)
4e18f4e4 140message(STATUS "Building ${PROJECT_NAME} with Qt ${Qt5Core_VERSION}")
b11ac14c 141
18bc68f2 142QT5_ADD_DBUS_INTERFACE(DBUS_INTERFACE_SRCS
b11ac14c
JL
143 dbus/org.freedesktop.Notifications.xml
144 notifications_interface
145)
146
18bc68f2 147QT5_ADD_DBUS_ADAPTOR(DBUS_ADAPTOR_SRCS
7e7ee62a 148 dbus/org.lxqt.SingleApplication.xml
f05ba5af 149 lxqtsingleapplication.h LXQt::SingleApplication
7e7ee62a
LP
150)
151
18bc68f2
LP
152set_property(SOURCE ${DBUS_INTERFACE_SRCS} ${DBUS_ADAPTOR_SRCS} PROPERTY SKIP_AUTOGEN ON)
153list(APPEND SRCS "${DBUS_INTERFACE_SRCS}" "${DBUS_ADAPTOR_SRCS}")
7e7ee62a
LP
154
155# KF5WindowSystem is missing here. KF5WindowSystem doesn't provide an .pc file.
39357b1d 156set(LXQT_PKG_CONFIG_REQUIRES "Qt5Xdg >= ${QTXDG_MINIMUM_VERSION}, Qt5Widgets >= ${QT_MINIMUM_VERSION}, Qt5Xml >= ${QT_MINIMUM_VERSION}, Qt5DBus >= ${QT_MINIMUM_VERSION}, Qt5X11Extras >= ${QT_MINIMUM_VERSION}")
af223b3d 157
d7e822b0 158
7255c8df 159# Standard directories for installation
216edec1 160include(LXQtCompilerSettings NO_POLICY_SCOPE)
7255c8df 161include(LXQtCreatePkgConfigFile)
3c43e281 162include(LXQtCreatePortableHeaders)
012716c5 163include(LXQtConfigVars)
371400de 164
4f07364e 165set(LXQT_INTREE_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include")
371400de 166
b11ac14c 167set(LXQT_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}/${LXQT_LIBRARY_NAME}")
e47d1cae 168set(LXQT_INSTALL_CMAKE_DIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}/cmake")
371400de 169
f88aabc1 170
4790513b
LP
171## Translations
172include(LXQtTranslateTs)
173
174lxqt_translate_ts(QM_FILES
175 UPDATE_TRANSLATIONS
176 ${UPDATE_TRANSLATIONS}
177 SOURCES
178 ${SRCS}
179 ${FORMS}
180 INSTALL_DIR
e2eb0f8e 181 "${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME}"
db5b3bb5
PK
182 PULL_TRANSLATIONS
183 ${PULL_TRANSLATIONS}
184 CLEAN_TRANSLATIONS
185 ${CLEAN_TRANSLATIONS}
186 TRANSLATIONS_REPO
187 ${TRANSLATIONS_REPO}
188 TRANSLATIONS_REFSPEC
189 ${TRANSLATIONS_REFSPEC}
4790513b
LP
190)
191
af223b3d
AS
192message(STATUS "")
193message(STATUS "liblxqt version: ${LXQT_VERSION}")
194message(STATUS "")
195
196
371400de
AS
197# Copy public headers
198foreach(h ${PUB_HDRS})
199 get_filename_component(bh ${h} NAME)
b11ac14c 200 configure_file(${h} "${LXQT_INTREE_INCLUDE_DIR}/LXQt/${bh}" COPYONLY)
371400de
AS
201endforeach()
202
203# Create the portable headers
3c43e281
LP
204lxqt_create_portable_headers(INTREE_PORTABLE_HEADERS
205 NAME_PREFIX "lxqt"
206 OUTPUT_DIR "${LXQT_INTREE_INCLUDE_DIR}/LXQt"
207 HEADER_NAMES ${PUBLIC_CLASSES}
208)
209
210#check_portable_headers(H_FILES ${PUB_HDRS} LINKS "${INTREE_PORTABLE_HEADERS}")
371400de 211
af223b3d 212#************************************************
f324ccfb 213# Create in-tree build infrastructure
af223b3d 214#************************************************
e2eb0f8e 215set(CFG_LXQT_TARGETS_FILE "${LXQT_INTREE_TARGETS_FILE}")
af223b3d 216
4f07364e
LP
217configure_package_config_file(
218 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt-config.cmake.in"
219 "${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}-config.cmake"
220 INSTALL_DESTINATION "neverland" # required, altough we don't install it
371400de
AS
221)
222
af223b3d 223#************************************************
b11ac14c 224# Create installable build infrastructure
af223b3d 225#************************************************
b11ac14c 226set(CFG_LXQT_TARGETS_FILE "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}/${LXQT_LIBRARY_NAME}-targets.cmake")
949dba2f 227
4f07364e
LP
228configure_package_config_file(
229 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt-config.cmake.in"
b11ac14c 230 "${CMAKE_CURRENT_BINARY_DIR}/install/${LXQT_LIBRARY_NAME}-config.cmake"
4f07364e 231 INSTALL_DESTINATION "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}"
4681206d 232)
f88aabc1 233
4f07364e
LP
234write_basic_package_version_file(
235 "${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}-config-version.cmake"
236 VERSION ${LXQT_VERSION}
237 COMPATIBILITY AnyNewerVersion
f324ccfb 238)
f88aabc1 239
96a82211 240install(FILES
4f07364e
LP
241 "${CMAKE_CURRENT_BINARY_DIR}/install/${LXQT_LIBRARY_NAME}-config.cmake"
242 "${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}-config-version.cmake"
e2eb0f8e 243 DESTINATION "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}"
371400de
AS
244 COMPONENT Devel
245)
af223b3d 246
96a82211 247install(EXPORT
371400de 248 ${LXQT_LIBRARY_NAME}-targets
761d737e 249 DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/${LXQT_LIBRARY_NAME}"
371400de
AS
250 COMPONENT Devel
251)
a28cd05a 252
371400de 253add_library(${LXQT_LIBRARY_NAME}
af223b3d 254 SHARED ${PUB_HDRS}
af223b3d
AS
255 ${SRCS}
256 ${dbus_generated}
257 ${UIS} ${MOCS}
258 ${QM_FILES}
371400de 259 ${QRC_CXX_SOURCES}
96a82211 260
af223b3d 261)
4ef6cee9 262
b11ac14c 263target_link_libraries(${LXQT_LIBRARY_NAME}
9b02d1a8
LP
264 PUBLIC
265 KF5::WindowSystem
266 Qt5::Widgets
267 Qt5::DBus
268 Qt5::X11Extras
269 Qt5Xdg
cd10d270
LP
270 PRIVATE
271 ${X11_Xscreensaver_LIB}
272 ${X11_X11_LIB}
b11ac14c 273)
2d13fe11 274
371400de 275set_target_properties(${LXQT_LIBRARY_NAME} PROPERTIES
af223b3d
AS
276 VERSION ${LXQT_VERSION}
277 SOVERSION ${LXQT_MAJOR_VERSION}
4ef6cee9 278)
279
0a6fef0b 280target_compile_definitions(${LXQT_LIBRARY_NAME}
90bb8d53
LP
281 PRIVATE
282 "LXQT_RELATIVE_SHARE_DIR=\"${LXQT_RELATIVE_SHARE_DIR}\""
283 "LXQT_SHARE_DIR=\"${LXQT_SHARE_DIR}\""
284 "LXQT_RELATIVE_SHARE_TRANSLATIONS_DIR=\"${LXQT_RELATIVE_TRANSLATIONS_DIR}\""
285 "LXQT_SHARE_TRANSLATIONS_DIR=\"${LXQT_TRANSLATIONS_DIR}\""
286 "LXQT_GRAPHICS_DIR=\"${LXQT_GRAPHICS_DIR}\""
287 "LXQT_ETC_XDG_DIR=\"${LXQT_ETC_XDG_DIR}\""
288 "LXQT_DATA_DIR=\"${LXQT_DATA_DIR}\""
289 "LXQT_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\""
290 "LXQT_VERSION=\"${LXQT_VERSION}\""
291 "COMPILE_LIBLXQT"
5bf85d40 292 "QT_NO_FOREACH"
90bb8d53
LP
293 "$<$<CONFIG:Release>:QT_NO_DEBUG_OUTPUT>"
294 "$<$<CONFIG:Release>:QT_NO_WARNING_OUTPUT>"
0a6fef0b
LP
295)
296
d3fc5350 297if (Qt5Core_VERSION VERSION_LESS "5.9.0")
298 if (NOT DEFINED WITH_XDG_DIRS_FALLBACK)
299 set(WITH_XDG_DIRS_FALLBACK ON)
300 endif ()
301elseif (WITH_XDG_DIRS_FALLBACK)
302 set(WITH_XDG_DIRS_FALLBACK OFF)
303 message(WARNING "Disabling requested WITH_XDG_DIRS_FALLBACK workaround, as proper implementation is in Qt from v5.9.0")
304endif ()
b1b249e5 305if (WITH_XDG_DIRS_FALLBACK)
d3fc5350 306 message(STATUS "Building with homemade QSettings XDG fallback workaround")
b1b249e5
PK
307 target_compile_definitions(${LXQT_LIBRARY_NAME}
308 PRIVATE "WITH_XDG_DIRS_FALLBACK"
309 )
310endif ()
311
4f07364e 312target_include_directories(${LXQT_LIBRARY_NAME}
90bb8d53
LP
313 INTERFACE
314 "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${LXQT_LIBRARY_NAME}>"
315 "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${LXQT_LIBRARY_NAME}/LXQt>"
316 "$<BUILD_INTERFACE:${LXQT_INTREE_INCLUDE_DIR}>"
317 "$<BUILD_INTERFACE:${LXQT_INTREE_INCLUDE_DIR}/LXQt>"
4f07364e
LP
318)
319
96a82211
JL
320install(TARGETS
321 ${LXQT_LIBRARY_NAME}
e2eb0f8e 322 DESTINATION "${CMAKE_INSTALL_LIBDIR}"
371400de 323 EXPORT ${LXQT_LIBRARY_NAME}-targets
e2eb0f8e 324 LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
19b97322 325 COMPONENT Runtime
371400de
AS
326)
327
19b97322
LP
328install(FILES
329 ${PUB_HDRS}
330 DESTINATION "${LXQT_INSTALL_INCLUDE_DIR}/LXQt"
331 COMPONENT Devel
332)
333
334install(FILES
335 ${INTREE_PORTABLE_HEADERS}
336 DESTINATION "${LXQT_INSTALL_INCLUDE_DIR}/LXQt"
337 COMPONENT Devel
338)
af223b3d 339
5ead57dd
PK
340install(FILES ${LXQT_CONFIG_FILES}
341 DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/lxqt"
342 COMPONENT Runtime
343)
344
371400de 345#************************************************
7255c8df 346# Create and install pkgconfig file
371400de 347#************************************************
7255c8df
LP
348lxqt_create_pkgconfig_file(
349 PACKAGE_NAME ${LXQT_LIBRARY_NAME}
350 DESCRIPTIVE_NAME ${LXQT_LIBRARY_NAME}
351 DESCRIPTION ${LXQT_PKG_CONFIG_DESCRIPTION}
352 INCLUDEDIRS ${LXQT_LIBRARY_NAME}
353 LIBS ${LXQT_LIBRARY_NAME}
354 REQUIRES ${LXQT_PKG_CONFIG_REQUIRES}
355 VERSION ${LXQT_VERSION}
356 INSTALL
388b7976 357)
371400de 358#************************************************