Commit 8f2b38ae authored by Nicolas Fella's avatar Nicolas Fella
Browse files

Modernize X11-related cmake code

Use imported targets instead of variables
Use PkgConfig directly instead of wrapping calls in a find module
parent e55cff2c
......@@ -133,29 +133,25 @@ find_package(XCB
REQUIRED COMPONENTS
XCB SHM IMAGE
OPTIONAL_COMPONENTS
XKB XINPUT
XKB XINPUT ATOM RECORD
)
find_package(X11_XCB)
set_package_properties(X11_XCB PROPERTIES TYPE OPTIONAL
PURPOSE "Required for needed for touchpad KCM (X11 backend)"
)
set_package_properties(XCB PROPERTIES TYPE REQUIRED)
add_feature_info("XCB-XKB" XCB_XKB_FOUND "Required for building kcm/keyboard")
add_feature_info("libxft" X11_Xft_FOUND "X FreeType interface library required for font installation")
find_package(Evdev)
set_package_properties(Evdev PROPERTIES TYPE OPTIONAL)
add_feature_info("Evdev" EVDEV_FOUND "Evdev driver headers needed for mouse KCM")
pkg_check_modules(XORGLIBINPUT xorg-libinput IMPORTED_TARGET)
pkg_check_modules(EVDEV xorg-evdev>=2.8.99.1 IMPORTED_TARGET)
find_package(Synaptics)
set_package_properties(Synaptics PROPERTIES TYPE OPTIONAL)
add_feature_info("Synaptics" SYNAPTICS_FOUND "Synaptics libraries needed for touchpad KCM")
find_package(XorgServer)
set_package_properties(XorgServer PROPERTIES TYPE OPTIONAL)
add_feature_info("XorgServer" XORGSERVER_FOUND "XServer header needed for touchpad KCM (X11 backend)")
find_package(XorgLibinput)
set_package_properties(XorgLibinput PROPERTIES TYPE OPTIONAL)
add_feature_info("XorgLibinput" XORGLIBINPUT_FOUND "Libinput driver headers needed for mouse and touchpad KCM")
if(XORGLIBINPUT_FOUND)
set(HAVE_XORGLIBINPUT 1)
endif()
......
# - Find Xorg Evdev driver's libraries and headers.
# This module defines the following variables:
#
# EVDEV_FOUND - true if Evdev driver was found
# Evdev_INCLUDE_DIRS - include path for Evdev
# There are no libraries, just a header file
#
# Copyright (c) 2015 Yue Liu <yue.liu@mail.com>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the University nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
find_package(PkgConfig)
pkg_check_modules(PC_EVDEV xorg-evdev>=2.8.99.1)
find_path(Evdev_INCLUDE_DIRS
NAMES evdev-properties.h
HINTS ${PC_EVDEV_INCLUDE_DIRS} ${PC_EVDEV_INCLUDEDIR}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Evdev REQUIRED_VARS Evdev_INCLUDE_DIRS)
mark_as_advanced(Evdev_INCLUDE_DIRS)
# - Find synaptics's libraries and headers.
# This module defines the following variables:
#
# SYNAPTICS_FOUND - true if synaptics was found
# SYNAPTICS_INCLUDE_DIRS - include path for synaptics
# There are no libraries, just a header file
#
# Copyright (c) 2015 David Edmundson <davidedmundson@kde.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the University nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
find_package(PkgConfig)
pkg_check_modules(PC_SYNAPTICS xorg-synaptics)
find_path(Synaptics_INCLUDE_DIRS
NAMES synaptics-properties.h
HINTS ${PC_SYNAPTICS_INCLUDE_DIRS} ${PC_SYNAPTICS_INCLUDEDIR}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Synaptics REQUIRED_VARS Synaptics_INCLUDE_DIRS)
mark_as_advanced(Synaptics_INCLUDE_DIRS)
# Have it in a find module to allow force disabling it via CMAKE_DISABLE_FIND_PACKAGE_
pkg_check_modules(SYNAPTICS xorg-synaptics IMPORTED_TARGET GLOBAL)
# - Find xorg libinput's libraries and headers.
# This module defines the following variables:
#
# XORGLIBINPUT_FOUND - true if libinput was found
# XORGLIBINPUT_INCLUDE_DIRS - include path for synaptics
# There are no libraries, just a header file
#
# Copyright (c) 2017 Weng Xuetian <wengxt@gmail.com>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the University nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
find_package(PkgConfig)
pkg_check_modules(PC_XORGLIBINPUT xorg-libinput)
find_path(XORGLIBINPUT_INCLUDE_DIRS
NAMES libinput-properties.h
HINTS ${PC_XORGLIBINPUT_INCLUDE_DIRS} ${PC_XORGLIBINPUT_INCLUDEDIR}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(XorgLibinput REQUIRED_VARS XORGLIBINPUT_INCLUDE_DIRS)
mark_as_advanced(XORGLIBINPUT_INCLUDE_DIRS)
# - Find xorg-server's headers.
# This module defines the following variables:
#
# XORGSERVER_FOUND - true if xserver was found
# XORGSERVER_INCLUDE_DIRS - include path for xserver
# There are no libraries, just a header file
#
# Copyright (c) 2020 Andreas Sturmlechner <asturm@gentoo.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the University nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
find_package(PkgConfig)
pkg_check_modules(PC_XORGSERVER xorg-server)
find_path(XORGSERVER_INCLUDE_DIRS
NAMES xserver-properties.h
HINTS ${PC_XORGSERVER_INCLUDE_DIRS} ${PC_XORGSERVER_INCLUDEDIR}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(XORGSERVER REQUIRED_VARS XORGSERVER_INCLUDE_DIRS)
mark_as_advanced(XORGSERVER_INCLUDE_DIRS)
......@@ -4,7 +4,7 @@ if(X11_Xkb_FOUND AND XCB_XKB_FOUND)
add_subdirectory( keyboard )
endif()
if (EVDEV_FOUND AND XORGLIBINPUT_FOUND AND X11_Xinput_FOUND)
if (EVDEV_FOUND AND XORGLIBINPUT_FOUND AND X11_Xi_FOUND)
add_subdirectory( mouse )
endif()
......@@ -41,6 +41,6 @@ if (KF5Baloo_FOUND)
endif()
add_subdirectory(solid_actions)
if (XORGSERVER_FOUND AND SYNAPTICS_FOUND AND X11_Xinput_FOUND)
if (SYNAPTICS_FOUND AND X11_XCB_FOUND AND X11_Xi_FOUND)
add_subdirectory(touchpad)
endif()
......@@ -62,7 +62,7 @@ target_link_libraries(kded_keyboard
)
if (HAVE_XINPUT)
target_link_libraries(kded_keyboard ${X11_Xinput_LIB})
target_link_libraries(kded_keyboard X11::Xi)
endif()
if (HAVE_UDEV)
......@@ -129,9 +129,8 @@ target_link_libraries(kcm_keyboard
KF5::GuiAddons
XCB::XCB
XCB::XKB
${X11_Xkbfile_LIB}
${X11_LIBRARIES}
${text_paint_LIB}
X11::X11
X11::xkbfile
)
install(TARGETS kcm_keyboard DESTINATION ${KDE_INSTALL_PLUGINDIR} )
......
# // krazy:excludeall=copyright,license
include_directories(
${X11_X11_INCLUDE_PATH}
${X11_Xinput_INCLUDE_PATH}
${Evdev_INCLUDE_DIRS}
${XORGLIBINPUT_INCLUDE_DIRS}
)
set(backend_SRCS
${backend_SRCS}
backends/x11/x11_backend.cpp
......@@ -21,14 +14,8 @@ set(backend_LIBS
${backend_LIBS}
KF5::WindowSystem
Qt::X11Extras
${X11_X11_LIB}
${X11_Xinput_LIB}
PkgConfig::XORGLIBINPUT
X11::X11
X11::Xi
X11::Xcursor
)
if (X11_Xcursor_FOUND)
set(backend_LIBS
${X11_Xcursor_LIB}
${backend_LIBS}
)
include_directories(${X11_Xcursor_INCLUDE_PATH})
endif ()
# // krazy:excludeall=copyright,license
find_package(X11 REQUIRED)
find_package(X11_XCB REQUIRED)
find_package(XCB REQUIRED COMPONENTS ATOM RECORD)
find_package(PkgConfig REQUIRED)
if(NOT X11_Xinput_FOUND)
message(FATAL_ERROR "Xinput not found")
endif()
include_directories(${X11_Xinput_INCLUDE_PATH}
${X11_X11_INCLUDE_PATH}
${Synaptics_INCLUDE_DIRS}
${XORGSERVER_INCLUDE_DIRS}
)
SET(backend_SRCS
${backend_SRCS}
......@@ -25,30 +11,34 @@ SET(backend_SRCS
backends/x11/xrecordkeyboardmonitor.cpp
)
if (HAVE_XORGLIBINPUT)
include_directories(${XORGLIBINPUT_INCLUDE_DIRS})
if (XORGLIBINPUT_FOUND)
SET(backend_SRCS
${backend_SRCS}
backends/libinputcommon.cpp
backends/x11/libinputtouchpad.cpp
)
SET(backend_LIBS
${backend_LIBS}
PkgConfig::XORGLIBINPUT
)
endif()
SET(backend_LIBS
${backend_LIBS}
XCB::ATOM
XCB::RECORD
${X11_X11_LIB}
X11::X11
X11::Xi
X11::XCB
${X11_Xinput_LIB}
PkgConfig::SYNAPTICS
)
add_executable(kcm-touchpad-list-devices backends/x11/listdevices.cpp)
target_link_libraries(kcm-touchpad-list-devices
${X11_X11_LIB}
${X11_Xinput_LIB}
X11::X11
X11::Xi
)
install(TARGETS kcm-touchpad-list-devices
DESTINATION ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment