CMakeLists.txt 11 KB
Newer Older
1 2 3 4 5 6
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
# CMP0000: Call the cmake_minimum_required() command at the beginning of the top-level
# CMakeLists.txt file even before calling the project() command.
# The cmake_minimum_required(VERSION) command implicitly invokes the cmake_policy(VERSION)
# command to specify that the current project code is written for the given range of CMake
# versions.
7 8
project(liblxqt)

9 10 11

set(LXQTBT_MINIMUM_VERSION "0.6.0")
set(KF5_MINIMUM_VERSION "5.36.0")
12
set(QT_MINIMUM_VERSION "5.7.1")
13
set(QTXDG_MINIMUM_VERSION "3.3.1")
14 15 16 17

# Major LXQt Version, belong to all components
set(LXQT_MAJOR_VERSION 0)
# Minor LXQt Version, belong to all components
18
set(LXQT_MINOR_VERSION 14)
19 20
#
# Patch Version, belong *only* to the component
21
# LXQt is 0.13 - liblxqt is at patch version 0
22 23 24 25 26 27
# The official LXQt version will follow liblxqt.
#
# In a perfect world all components would have the same major- and minor- and
# patch-version as liblxqt - in real life it will be fine if every component
# has it's own patch version within a major/minor life cyle.
#
28
set(LXQT_PATCH_VERSION 1)
29
set(LXQT_VERSION ${LXQT_MAJOR_VERSION}.${LXQT_MINOR_VERSION}.${LXQT_PATCH_VERSION})
30

31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47

option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files" OFF)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)

find_package(lxqt-build-tools ${LXQTBT_MINIMUM_VERSION} REQUIRED)
find_package(Qt5 ${QT_MINIMUM_VERSION} CONFIG REQUIRED Widgets DBus X11Extras LinguistTools)
find_package(Qt5Xdg ${QTXDG_MINIMUM_VERSION} REQUIRED)
find_package(KF5WindowSystem ${KF5_MINIMUM_VERSION} REQUIRED)
find_package(PolkitQt5-1 REQUIRED)
find_package(X11 REQUIRED)
message(STATUS "Building ${PROJECT_NAME} with Qt ${Qt5Core_VERSION}")

48 49 50
include(CMakePackageConfigHelpers)
include(GNUInstallDirs) # Standard directories for installation

51 52
add_subdirectory(lxqtbacklight/linux_backend/driver)

53 54 55 56 57 58 59 60 61 62 63 64 65 66
set(LXQT_PKG_CONFIG_DESCRIPTION "Shared library for LXQt applications")

set(PUB_HDRS
    lxqthtmldelegate.h
    lxqtsettings.h
    lxqtplugininfo.h
    lxqtpowermanager.h
    lxqtscreensaver.h
    lxqtapplication.h
    lxqtsingleapplication.h
    lxqttranslator.h
    lxqtprogramfinder.h

    configdialog/lxqtconfigdialog.h
67
    configdialog/lxqtconfigdialogcmdlineoptions.h
68 69 70 71 72 73 74 75
    configdialog/lxqtpageselectwidget.h

    lxqtpower/lxqtpower.h
    lxqtnotification.h
    lxqtautostartentry.h
    lxqtgridlayout.h
    lxqtrotatedwidget.h
    lxqtglobals.h
76 77 78
    lxqtbacklight.h
    #lxqtbacklight/virtual_backend.h
    #lxqtbacklight/linux_backend/linuxbackend.h
79 80 81 82 83 84 85 86 87 88 89 90 91 92
)

set(PUBLIC_CLASSES
    HtmlDelegate
    Settings
    PluginInfo
    PowerManager
    ScreenSaver
    Application
    SingleApplication
    Translator
    ProgramFinder

    ConfigDialog
93
    ConfigDialogCmdLineOptions
94 95 96 97 98 99 100
    PageSelectWidget

    Power
    Notification
    AutostartEntry
    GridLayout
    RotatedWidget
101 102
    Globals
    Backlight
103 104 105 106 107 108 109 110 111 112 113 114 115 116
)

set(SRCS
    lxqthtmldelegate.cpp
    lxqtplugininfo.cpp
    lxqtpowermanager.cpp
    lxqtsettings.cpp
    lxqtscreensaver.cpp
    lxqtapplication.cpp
    lxqtsingleapplication.cpp
    lxqttranslator.cpp
    lxqtprogramfinder.cpp

    configdialog/lxqtconfigdialog.cpp
117
    configdialog/lxqtconfigdialogcmdlineoptions.cpp
118 119 120 121 122 123 124 125
    configdialog/lxqtpageselectwidget.cpp

    lxqtpower/lxqtpower.cpp
    lxqtpower/lxqtpowerproviders.cpp
    lxqtautostartentry.cpp
    lxqtnotification.cpp
    lxqtgridlayout.cpp
    lxqtrotatedwidget.cpp
126 127 128
    lxqtbacklight.cpp
    lxqtbacklight/virtual_backend.cpp
    lxqtbacklight/linux_backend/linuxbackend.cpp
129 130 131 132 133 134 135 136
)

set(MOCS
    lxqthtmldelegate.h
    lxqtpowermanager.h
    lxqtsettings.h
    lxqtscreensaver.h
    lxqtapplication.h
137
    lxqtbacklight.h
138 139

    configdialog/lxqtconfigdialog.h
140
    configdialog/lxqtconfigdialog_p.h
141 142 143 144 145 146 147 148
    configdialog/lxqtpageselectwidget.h

    lxqtnotification.h
    lxqtnotification_p.h
    lxqtpower/lxqtpower.h
    lxqtpower/lxqtpowerproviders.h
    lxqtgridlayout.h
    lxqtrotatedwidget.h
149 150
    lxqtbacklight/virtual_backend.h
    lxqtbacklight/linux_backend/linuxbackend.h
151 152 153 154 155 156
)

set(FORMS
    configdialog/lxqtconfigdialog.ui
)

157 158 159 160 161 162 163 164 165 166
set(POLKIT_FILES
    "${CMAKE_CURRENT_BINARY_DIR}/org.lxqt.backlight.pkexec.policy"
)

# Build Polkit file
configure_file ( polkit/org.lxqt.backlight.pkexec.policy.in "${CMAKE_CURRENT_BINARY_DIR}/org.lxqt.backlight.pkexec.policy" )

file(GLOB LXQT_CONFIG_FILES resources/*.conf)

QT5_ADD_DBUS_INTERFACE(DBUS_INTERFACE_SRCS
167 168 169 170
    dbus/org.freedesktop.Notifications.xml
    notifications_interface
)

171
QT5_ADD_DBUS_ADAPTOR(DBUS_ADAPTOR_SRCS
172
    dbus/org.lxqt.SingleApplication.xml
173
    lxqtsingleapplication.h LXQt::SingleApplication
174 175
)

176 177
set_property(SOURCE ${DBUS_INTERFACE_SRCS} ${DBUS_ADAPTOR_SRCS} PROPERTY SKIP_AUTOGEN ON)
list(APPEND SRCS "${DBUS_INTERFACE_SRCS}" "${DBUS_ADAPTOR_SRCS}")
178 179

# KF5WindowSystem is missing here. KF5WindowSystem doesn't provide an .pc file.
180
set(LXQT_PKG_CONFIG_REQUIRES "Qt5Xdg >= ${QTXDG_MINIMUM_VERSION}, Qt5Widgets >= ${QT_MINIMUM_VERSION}, Qt5Xml >= ${QT_MINIMUM_VERSION}, Qt5DBus >= ${QT_MINIMUM_VERSION}, Qt5X11Extras >= ${QT_MINIMUM_VERSION}")
181 182 183


# Standard directories for installation
184
include(LXQtPreventInSourceBuilds)
185 186
include(LXQtCompilerSettings NO_POLICY_SCOPE)
include(LXQtCreatePkgConfigFile)
187 188
include(LXQtCreatePortableHeaders)
include(LXQtConfigVars)
189

190
set(LXQT_INTREE_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include")
191 192

set(LXQT_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}/${LXQT_LIBRARY_NAME}")
193
set(LXQT_INSTALL_CMAKE_DIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}/cmake")
194 195 196 197 198 199 200 201 202 203 204 205


## Translations
include(LXQtTranslateTs)

lxqt_translate_ts(QM_FILES
    UPDATE_TRANSLATIONS
        ${UPDATE_TRANSLATIONS}
    SOURCES
        ${SRCS}
        ${FORMS}
    INSTALL_DIR
206
        "${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME}"
207 208 209 210 211 212 213 214 215 216 217 218 219 220
)

message(STATUS "")
message(STATUS "liblxqt version: ${LXQT_VERSION}")
message(STATUS "")


# Copy public headers
foreach(h ${PUB_HDRS})
    get_filename_component(bh ${h} NAME)
    configure_file(${h} "${LXQT_INTREE_INCLUDE_DIR}/LXQt/${bh}" COPYONLY)
endforeach()

# Create the portable headers
221 222 223 224 225 226 227
lxqt_create_portable_headers(INTREE_PORTABLE_HEADERS
    NAME_PREFIX "lxqt"
    OUTPUT_DIR "${LXQT_INTREE_INCLUDE_DIR}/LXQt"
    HEADER_NAMES ${PUBLIC_CLASSES}
)

#check_portable_headers(H_FILES ${PUB_HDRS} LINKS "${INTREE_PORTABLE_HEADERS}")
228 229 230 231

#************************************************
# Create in-tree build infrastructure
#************************************************
232
set(CFG_LXQT_TARGETS_FILE   "${LXQT_INTREE_TARGETS_FILE}")
233

234 235 236 237
configure_package_config_file(
    "${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt-config.cmake.in"
    "${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}-config.cmake"
    INSTALL_DESTINATION "neverland"     # required, altough we don't install it
238 239 240 241 242 243 244
)

#************************************************
# Create installable build infrastructure
#************************************************
set(CFG_LXQT_TARGETS_FILE "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}/${LXQT_LIBRARY_NAME}-targets.cmake")

245 246
configure_package_config_file(
    "${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt-config.cmake.in"
247
    "${CMAKE_CURRENT_BINARY_DIR}/install/${LXQT_LIBRARY_NAME}-config.cmake"
248
    INSTALL_DESTINATION "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}"
249 250
)

251 252 253 254
write_basic_package_version_file(
    "${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}-config-version.cmake"
    VERSION ${LXQT_VERSION}
    COMPATIBILITY AnyNewerVersion
255 256 257
)

install(FILES
258 259 260
    "${CMAKE_CURRENT_BINARY_DIR}/install/${LXQT_LIBRARY_NAME}-config.cmake"
    "${CMAKE_BINARY_DIR}/${LXQT_LIBRARY_NAME}-config-version.cmake"
    DESTINATION "${LXQT_INSTALL_CMAKE_DIR}/${LXQT_LIBRARY_NAME}"
261 262 263 264 265
    COMPONENT Devel
)

install(EXPORT
    ${LXQT_LIBRARY_NAME}-targets
266
    DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/${LXQT_LIBRARY_NAME}"
267 268 269 270 271 272 273 274 275 276 277 278 279 280
    COMPONENT Devel
)

add_library(${LXQT_LIBRARY_NAME}
    SHARED ${PUB_HDRS}
           ${SRCS}
           ${dbus_generated}
           ${UIS} ${MOCS}
           ${QM_FILES}
           ${QRC_CXX_SOURCES}

)

target_link_libraries(${LXQT_LIBRARY_NAME}
281 282 283 284 285 286
    PUBLIC
        KF5::WindowSystem
        Qt5::Widgets
        Qt5::DBus
        Qt5::X11Extras
        Qt5Xdg
287 288 289
    PRIVATE
        ${X11_Xscreensaver_LIB}
        ${X11_X11_LIB}
290 291 292 293 294 295 296
)

set_target_properties(${LXQT_LIBRARY_NAME} PROPERTIES
    VERSION   ${LXQT_VERSION}
    SOVERSION ${LXQT_MAJOR_VERSION}
)

297
target_compile_definitions(${LXQT_LIBRARY_NAME}
298 299 300 301 302 303 304 305 306 307 308
    PRIVATE
        "LXQT_RELATIVE_SHARE_DIR=\"${LXQT_RELATIVE_SHARE_DIR}\""
        "LXQT_SHARE_DIR=\"${LXQT_SHARE_DIR}\""
        "LXQT_RELATIVE_SHARE_TRANSLATIONS_DIR=\"${LXQT_RELATIVE_TRANSLATIONS_DIR}\""
        "LXQT_SHARE_TRANSLATIONS_DIR=\"${LXQT_TRANSLATIONS_DIR}\""
        "LXQT_GRAPHICS_DIR=\"${LXQT_GRAPHICS_DIR}\""
        "LXQT_ETC_XDG_DIR=\"${LXQT_ETC_XDG_DIR}\""
        "LXQT_DATA_DIR=\"${LXQT_DATA_DIR}\""
        "LXQT_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\""
        "LXQT_VERSION=\"${LXQT_VERSION}\""
        "COMPILE_LIBLXQT"
309 310 311 312 313
        "QT_USE_QSTRINGBUILDER"
        "QT_NO_CAST_FROM_ASCII"
        "QT_NO_CAST_TO_ASCII"
        "QT_NO_URL_CAST_FROM_STRING"
        "QT_NO_CAST_FROM_BYTEARRAY"
314 315
        "$<$<CONFIG:Release>:QT_NO_DEBUG_OUTPUT>"
        "$<$<CONFIG:Release>:QT_NO_WARNING_OUTPUT>"
316 317
)

318 319 320 321 322 323 324 325
if (Qt5Core_VERSION VERSION_LESS "5.9.0")
    if (NOT DEFINED WITH_XDG_DIRS_FALLBACK)
        set(WITH_XDG_DIRS_FALLBACK ON)
    endif ()
elseif (WITH_XDG_DIRS_FALLBACK)
    set(WITH_XDG_DIRS_FALLBACK OFF)
    message(WARNING "Disabling requested WITH_XDG_DIRS_FALLBACK workaround, as proper implementation is in Qt from v5.9.0")
endif ()
326
if (WITH_XDG_DIRS_FALLBACK)
327
    message(STATUS "Building with homemade QSettings XDG fallback workaround")
328 329 330 331 332
    target_compile_definitions(${LXQT_LIBRARY_NAME}
        PRIVATE "WITH_XDG_DIRS_FALLBACK"
    )
endif ()

333
target_include_directories(${LXQT_LIBRARY_NAME}
334 335 336 337 338
    INTERFACE
        "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${LXQT_LIBRARY_NAME}>"
        "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${LXQT_LIBRARY_NAME}/LXQt>"
        "$<BUILD_INTERFACE:${LXQT_INTREE_INCLUDE_DIR}>"
        "$<BUILD_INTERFACE:${LXQT_INTREE_INCLUDE_DIR}/LXQt>"
339 340
)

341 342
install(TARGETS
    ${LXQT_LIBRARY_NAME}
343
    DESTINATION "${CMAKE_INSTALL_LIBDIR}"
344
    EXPORT ${LXQT_LIBRARY_NAME}-targets
345 346
    LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
    COMPONENT Runtime
347 348
)

349 350 351 352 353
install(FILES
    ${PUB_HDRS}
    DESTINATION "${LXQT_INSTALL_INCLUDE_DIR}/LXQt"
    COMPONENT Devel
)
354

355 356 357 358 359
install(FILES
    ${INTREE_PORTABLE_HEADERS}
    DESTINATION "${LXQT_INSTALL_INCLUDE_DIR}/LXQt"
    COMPONENT Devel
)
360

361 362 363 364 365 366 367
install(FILES ${LXQT_CONFIG_FILES}
    DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/lxqt"
    COMPONENT Runtime
)

install(FILES ${POLKIT_FILES} DESTINATION "${POLKITQT-1_POLICY_FILES_INSTALL_DIR}")

368
#************************************************
369
# Create and install pkgconfig file
370
#************************************************
371 372 373 374 375 376 377 378 379
lxqt_create_pkgconfig_file(
    PACKAGE_NAME ${LXQT_LIBRARY_NAME}
    DESCRIPTIVE_NAME ${LXQT_LIBRARY_NAME}
    DESCRIPTION ${LXQT_PKG_CONFIG_DESCRIPTION}
    INCLUDEDIRS ${LXQT_LIBRARY_NAME}
    LIBS ${LXQT_LIBRARY_NAME}
    REQUIRES ${LXQT_PKG_CONFIG_REQUIRES}
    VERSION ${LXQT_VERSION}
    INSTALL
380 381
)
#************************************************