diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e8dfd9361..74a97aee23 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -309,6 +309,14 @@ set_package_properties(QAccessibilityClient PROPERTIES ) set(HAVE_ACCESSIBILITY ${QAccessibilityClient_FOUND}) +if(CMAKE_SYSTEM MATCHES "FreeBSD") + find_package(epoll) + set_package_properties(epoll PROPERTIES DESCRIPTION "I/O event notification facility" + TYPE REQUIRED + PURPOSE "Needed for running kwin_wayland" + ) +endif() + include(ECMQMLModules) ecm_find_qmlmodule(QtQuick 2.3) ecm_find_qmlmodule(QtQuick.Controls 1.2) @@ -578,6 +586,13 @@ if (HAVE_LINUX_VT_H) ) endif() +if(CMAKE_SYSTEM MATCHES "FreeBSD") + # We know it has epoll, so supports VT as well + set(kwin_SRCS ${kwin_SRCS} + virtual_terminal.cpp + ) +endif() + kconfig_add_kcfg_files(kwin_SRCS settings.kcfgc) kconfig_add_kcfg_files(kwin_SRCS colorcorrection/colorcorrect_settings.kcfgc) kconfig_add_kcfg_files(kwin_SRCS rulesettings.kcfgc) @@ -690,6 +705,12 @@ set_target_properties(kwin PROPERTIES target_link_libraries(kwin ${kwinLibs} kwinglutils ${epoxy_LIBRARY}) generate_export_header(kwin EXPORT_FILE_NAME kwin_export.h) +if(CMAKE_SYSTEM MATCHES "FreeBSD") + # epoll is required, includes live under ${LOCALBASE}, separate library + target_include_directories(kwin PUBLIC ${epoll_INCLUDE_DIRS}) + target_link_libraries(kwin ${kwinLibs} ${epoll_LIBRARIES}) +endif() + add_executable(kwin_x11 main_x11.cpp) target_link_libraries(kwin_x11 kwin KF5::Crash Qt5::X11Extras) diff --git a/cmake/modules/Findepoll.cmake b/cmake/modules/Findepoll.cmake new file mode 100644 index 0000000000..35ae99ba0a --- /dev/null +++ b/cmake/modules/Findepoll.cmake @@ -0,0 +1,78 @@ +#.rest: +# FindEpoll +# -------------- +# +# Try to find epoll or epoll-shim on this system. This finds: +# - some shim on Unix like systems (FreeBSD), or +# - the kernel's epoll on Linux systems. +# +# This will define the following variables: +# +# ``epoll_FOUND`` +# True if epoll is available +# ``epoll_LIBRARIES`` +# This has to be passed to target_link_libraries() +# ``epoll_INCLUDE_DIRS`` +# This has to be passed to target_include_directories() +# +# On Linux, the libraries and include directories are empty, +# even though epoll_FOUND may be set to TRUE. This is because +# no special includes or libraries are needed. On other systems +# these may be needed to use epoll. + +#============================================================================= +# Copyright 2019 Tobias C. Berner +# +# 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 copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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_path(epoll_INCLUDE_DIRS sys/epoll.h PATH_SUFFIXES libepoll-shim) + +if(epoll_INCLUDE_DIRS) + # On Linux there is no library to link against, on the BSDs there is. + # On the BSD's, epoll is implemented through a library, libepoll-shim. + if( CMAKE_SYSTEM_NAME MATCHES "Linux") + set(epoll_FOUND TRUE) + set(epoll_LIBRARIES "") + set(epoll_INCLUDE_DIRS "") + else() + find_library(epoll_LIBRARIES NAMES epoll-shim) + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(epoll + FOUND_VAR + epoll_FOUND + REQUIRED_VARS + epoll_LIBRARIES + epoll_INCLUDE_DIRS + ) + mark_as_advanced(epoll_LIBRARIES epoll_INCLUDE_DIRS) + include(FeatureSummary) + set_package_properties(epoll PROPERTIES + URL "https://github.com/FreeBSDDesktop/epoll-shim" + DESCRIPTION "small epoll implementation using kqueue" + ) + endif() +else() + set(epoll_FOUND FALSE) +endif() + +mark_as_advanced(epoll_LIBRARIES epoll_INCLUDE_DIRS)