CMakeLists.txt 6.95 KB
Newer Older
1
add_definitions(-DTRANSLATION_DOMAIN=\"powerdevil\" -DQT_USE_QSTRINGBUILDER)
Lukáš Tinkl's avatar
Lukáš Tinkl committed
2

Dario Freddi's avatar
Dario Freddi committed
3 4
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
                    ${CMAKE_CURRENT_BINARY_DIR})
5

Dario Freddi's avatar
Dario Freddi committed
6
add_subdirectory(actions)
7

8 9
set(POWERDEVIL_CORE_VERSION_MAJOR 2)
set(POWERDEVIL_CORE_VERSION_MINOR 0)
Dario Freddi's avatar
Dario Freddi committed
10 11 12
set(POWERDEVIL_CORE_VERSION_MICRO 0)
set(POWERDEVIL_CORE_VERSION_STRING ${POWERDEVIL_CORE_VERSION_MAJOR}.${POWERDEVIL_CORE_VERSION_MINOR}.${POWERDEVIL_CORE_VERSION_MICRO})

Kai Uwe Broulik's avatar
Kai Uwe Broulik committed
13 14 15 16
ecm_setup_version(${POWERDEVIL_CORE_VERSION_STRING} VARIABLE_PREFIX POWERDEVIL
                  VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/powerdevil_version.h"
)

Dario Freddi's avatar
Dario Freddi committed
17 18
# Add bundled actions
set(powerdevil_bundled_actions_SRCS
19
    powerdevil_debug.cpp
Dario Freddi's avatar
Dario Freddi committed
20 21
    actions/bundled/suspendsession.cpp
    actions/bundled/brightnesscontrol.cpp
22
    actions/bundled/keyboardbrightnesscontrol.cpp
Dario Freddi's avatar
Dario Freddi committed
23 24
    actions/bundled/dimdisplay.cpp
    actions/bundled/runscript.cpp
25
    actions/bundled/handlebuttonevents.cpp
Dario Freddi's avatar
Dario Freddi committed
26 27
)

28 29 30 31 32 33
if(HAVE_WIRELESS_SUPPORT)
    set(powerdevil_bundled_actions_SRCS ${powerdevil_bundled_actions_SRCS}
        actions/bundled/wirelesspowersaving.cpp
    )
endif()

Dario Freddi's avatar
Dario Freddi committed
34 35
# target no.1 - powerdevil core library
set(powerdevilcore_SRCS
36
    powerdevil_debug.cpp
Dario Freddi's avatar
Dario Freddi committed
37 38 39 40 41
    powerdevilaction.cpp
    powerdevilactionpool.cpp
    powerdevilbackendinterface.cpp
    powerdevilcore.cpp
    powerdevilpolicyagent.cpp
42
    powerdevilprofilegenerator.cpp
Nikita Skovoroda's avatar
Nikita Skovoroda committed
43 44 45
    powerdevilbrightnesslogic.cpp
    powerdevilscreenbrightnesslogic.cpp
    powerdevilkeyboardbrightnesslogic.cpp
46
    powerdevilpowermanagement.cpp
47
    brightnessosdwidget.cpp
48
    kwinkscreenhelpereffect.cpp
Dario Freddi's avatar
Dario Freddi committed
49
)
Dario Freddi's avatar
Dario Freddi committed
50

51 52 53 54 55 56
ecm_qt_declare_logging_category(powerdevilcore_SRCS
   HEADER powerdevil_debug.h
   IDENTIFIER POWERDEVIL
   CATEGORY_NAME org.kde.powerdevil
   DEFAULT_SEVERITY Warning)

Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
57
kconfig_add_kcfg_files(powerdevilcore_SRCS ../PowerDevilSettings.kcfgc)
Dario Freddi's avatar
Dario Freddi committed
58

59
# Action DBus Adaptors
60
qt5_add_dbus_adaptor(powerdevilcore_SRCS actions/bundled/org.kde.Solid.PowerManagement.Actions.BrightnessControl.xml
61
                     actions/bundled/brightnesscontrol.h PowerDevil::BundledActions::BrightnessControl)
62
qt5_add_dbus_adaptor(powerdevilcore_SRCS actions/bundled/org.kde.Solid.PowerManagement.Actions.KeyboardBrightnessControl.xml
63
                     actions/bundled/keyboardbrightnesscontrol.h PowerDevil::BundledActions::KeyboardBrightnessControl)
64
qt5_add_dbus_adaptor(powerdevilcore_SRCS actions/bundled/org.kde.Solid.PowerManagement.Actions.HandleButtonEvents.xml
65
                     actions/bundled/handlebuttonevents.h PowerDevil::BundledActions::HandleButtonEvents)
66
qt5_add_dbus_adaptor(powerdevilcore_SRCS actions/bundled/org.kde.Solid.PowerManagement.Actions.SuspendSession.xml
67
                     actions/bundled/suspendsession.h PowerDevil::BundledActions::SuspendSession)
68 69 70 71
if(HAVE_WIRELESS_SUPPORT)
    qt5_add_dbus_adaptor(powerdevilcore_SRCS actions/bundled/org.kde.Solid.PowerManagement.Actions.WirelessPowerSaving.xml
                         actions/bundled/wirelesspowersaving.h PowerDevil::BundledActions::WirelessPowerSaving)
endif()
72

73 74
qt5_add_dbus_interface(powerdevilcore_SRCS org.freedesktop.ScreenSaver.xml screenlocker_interface)

Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
75
add_library(powerdevilcore SHARED ${powerdevilcore_SRCS} ${powerdevil_bundled_actions_SRCS})
Dario Freddi's avatar
Dario Freddi committed
76
set_target_properties(powerdevilcore PROPERTIES VERSION ${POWERDEVIL_CORE_VERSION_STRING} SOVERSION ${POWERDEVIL_CORE_VERSION_MAJOR})
Dario Freddi's avatar
Dario Freddi committed
77

78
# not exported, so just make the deps public
Dario Freddi's avatar
Dario Freddi committed
79
target_link_libraries(powerdevilcore
80
    KF5::Activities
81 82
    KF5::ConfigCore
    KF5::ConfigGui
83
    KF5::DBusAddons
84 85 86 87
    KF5::I18n
    KF5::Solid
    KF5::IdleTime
    KF5::GlobalAccel
88
    KF5::Screen
89 90 91 92 93
    KF5::Service
    KF5::WidgetsAddons
    KF5::Notifications
    KF5::XmlGui
    PW::KWorkspace
Dario Freddi's avatar
Dario Freddi committed
94 95
)

96 97 98 99 100 101 102
if(HAVE_WIRELESS_SUPPORT)
    target_link_libraries(powerdevilcore
        KF5::NetworkManagerQt
        KF5::BluezQt
    )
endif()

Kai Uwe Broulik's avatar
Kai Uwe Broulik committed
103
if (XCB_FOUND) # kwin kscreen helper effect
104 105 106
    target_link_libraries(powerdevilcore Qt5::X11Extras XCB::XCB)
endif ()

Dario Freddi's avatar
Dario Freddi committed
107
# target no.2 - powerdevil kded module
108
set(powerdevil_SRCS
109
    powerdevil_debug.cpp
110
    powerdevilapp.cpp
111
    powerdevilfdoconnector.cpp
Dario Freddi's avatar
Dario Freddi committed
112 113
)

114
# DBus Adaptors
115 116
qt5_add_dbus_adaptor(powerdevil_SRCS org.kde.Solid.PowerManagement.xml powerdevilcore.h PowerDevil::Core)
qt5_add_dbus_adaptor(powerdevil_SRCS org.kde.Solid.PowerManagement.PolicyAgent.xml
117 118 119
                                         powerdevilpolicyagent.h PowerDevil::PolicyAgent
                                         powermanagementpolicyagentadaptor PowerManagementPolicyAgentAdaptor)

120 121
qt5_add_dbus_adaptor(powerdevil_SRCS org.freedesktop.PowerManagement.xml powerdevilfdoconnector.h PowerDevil::FdoConnector powermanagementfdoadaptor PowerManagementFdoAdaptor)
qt5_add_dbus_adaptor(powerdevil_SRCS org.freedesktop.PowerManagement.Inhibit.xml powerdevilfdoconnector.h PowerDevil::FdoConnector powermanagementinhibitadaptor PowerManagementInhibitAdaptor)
122

123 124 125 126 127 128 129
# KAuth charge threshold helper
add_executable(chargethresholdhelper chargethresholdhelper.cpp powerdevil_debug.cpp ${chargethresholdhelper_mocs})
target_link_libraries(chargethresholdhelper Qt5::Core KF5::AuthCore)
install(TARGETS chargethresholdhelper DESTINATION ${KAUTH_HELPER_INSTALL_DIR})
kauth_install_helper_files(chargethresholdhelper org.kde.powerdevil.chargethresholdhelper root)
kauth_install_actions(org.kde.powerdevil.chargethresholdhelper chargethreshold_helper_actions.actions)

130
# Backends
131
add_subdirectory(backends)
132

133 134 135 136
add_executable(powerdevil ${powerdevil_SRCS})
set_target_properties(powerdevil PROPERTIES OUTPUT_NAME org_kde_powerdevil)
configure_file(powerdevil.desktop.cmake
               ${CMAKE_CURRENT_BINARY_DIR}/powerdevil.desktop)
Dario Freddi's avatar
Dario Freddi committed
137

138 139
target_link_libraries(powerdevil
    KF5::Crash
140 141 142
    KF5::ConfigCore
    KF5::CoreAddons
    KF5::I18n
Martin Klapetek's avatar
Martin Klapetek committed
143
    KF5::DBusAddons
144
    PW::KWorkspace
Dario Freddi's avatar
Dario Freddi committed
145 146
    powerdevilcore
)
Kai Uwe Broulik's avatar
Kai Uwe Broulik committed
147
if (XCB_FOUND)
148
    target_link_libraries(powerdevil Qt5::X11Extras)
149
endif ()
Dario Freddi's avatar
Dario Freddi committed
150

151
target_link_libraries(powerdevil ${UDEV_LIBS})
152

153
install(TARGETS powerdevil DESTINATION ${KDE_INSTALL_FULL_LIBEXECDIR})
154 155 156 157 158 159
if (HAVE_LIBCAP)
    install(
    CODE "execute_process(
            COMMAND
                ${SETCAP_EXECUTABLE}
                CAP_WAKE_ALARM=+ep
160
                \$ENV{DESTDIR}${KDE_INSTALL_FULL_LIBEXECDIR}/org_kde_powerdevil)"
161 162 163
    )
endif()

164 165
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/powerdevil.desktop
        DESTINATION ${KDE_INSTALL_AUTOSTARTDIR})
166
install(TARGETS powerdevilcore ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
Dario Freddi's avatar
Dario Freddi committed
167 168 169 170 171 172

# target no.3 - powerdevil ui library
set(powerdevilui_SRCS
    powerdevilactionconfig.cpp
)

173
add_library(powerdevilui ${powerdevilui_SRCS})
174
set_target_properties(powerdevilui PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
Dario Freddi's avatar
Dario Freddi committed
175

176
# not exported, so just make the deps public
Dario Freddi's avatar
Dario Freddi committed
177
target_link_libraries(powerdevilui
178 179 180
    PUBLIC
        Qt5::Widgets
        KF5::ConfigCore
Dario Freddi's avatar
Dario Freddi committed
181 182
)

Kai Uwe Broulik's avatar
Kai Uwe Broulik committed
183
set(HAVE_XCB ${XCB_FOUND})
Dario Freddi's avatar
Dario Freddi committed
184 185
configure_file(config-powerdevil.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-powerdevil.h )

186
install(TARGETS powerdevilui ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
187 188
ecm_install_configured_files(INPUT plasma-powerdevil.service.in @ONLY DESTINATION
        ${SYSTEMD_USER_UNIT_INSTALL_DIR})