From cf77f97b2db7c595da3da9ec0fcc79364638ae00 Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Sun, 18 Jun 2023 21:35:09 -0500 Subject: [PATCH] CMake: Wayland support --- CMake/FindWayland.cmake | 68 +++++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 6 ++++ 2 files changed, 74 insertions(+) create mode 100644 CMake/FindWayland.cmake diff --git a/CMake/FindWayland.cmake b/CMake/FindWayland.cmake new file mode 100644 index 0000000000..8b7e1863ca --- /dev/null +++ b/CMake/FindWayland.cmake @@ -0,0 +1,68 @@ +# Try to find Wayland on a Unix system +# +# This will define: +# +# Wayland_FOUND - True if Wayland is found +# +# The following imported targets: +# Wayland::Client - Imported Client +# Wayland::Server - Imported Server +# Wayland::Egl - Imported Egl +# Wayland::Cursor - Imported Cursor +# +# Copyright (c) 2013 Martin Gräßlin +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +IF (NOT WIN32) + IF (WAYLAND_INCLUDE_DIR AND WAYLAND_LIBRARIES) + # In the cache already + SET(WAYLAND_FIND_QUIETLY TRUE) + ENDIF () + + FIND_PATH(WAYLAND_CLIENT_INCLUDE_DIR NAMES wayland-client.h) + FIND_PATH(WAYLAND_SERVER_INCLUDE_DIR NAMES wayland-server.h) + FIND_PATH(WAYLAND_EGL_INCLUDE_DIR NAMES wayland-egl.h) + FIND_PATH(WAYLAND_CURSOR_INCLUDE_DIR NAMES wayland-cursor.h) + + FIND_LIBRARY(WAYLAND_CLIENT_LIBRARIES NAMES wayland-client) + FIND_LIBRARY(WAYLAND_SERVER_LIBRARIES NAMES wayland-server) + FIND_LIBRARY(WAYLAND_EGL_LIBRARIES NAMES wayland-egl) + FIND_LIBRARY(WAYLAND_CURSOR_LIBRARIES NAMES wayland-cursor) + + include(FindPackageHandleStandardArgs) + + # FIND_PACKAGE_HANDLE_STANDARD_ARGS is just meant to find the main package and set package found. Not set variables or find individual libs + FIND_PACKAGE_HANDLE_STANDARD_ARGS(Wayland REQUIRED_VARS + WAYLAND_CLIENT_LIBRARIES WAYLAND_CLIENT_INCLUDE_DIR + WAYLAND_SERVER_LIBRARIES WAYLAND_SERVER_INCLUDE_DIR + WAYLAND_EGL_LIBRARIES WAYLAND_EGL_INCLUDE_DIR + WAYLAND_CURSOR_LIBRARIES WAYLAND_CURSOR_INCLUDE_DIR + ) + + if (WAYLAND_CLIENT_INCLUDE_DIR AND WAYLAND_CLIENT_LIBRARIES AND NOT TARGET Wayland::Client) + add_library(Wayland::Client UNKNOWN IMPORTED) + set_target_properties(Wayland::Client PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${WAYLAND_CLIENT_INCLUDE_DIR}" IMPORTED_LOCATION "${WAYLAND_CLIENT_LIBRARIES}") + endif() + if (WAYLAND_SERVER_INCLUDE_DIR AND WAYLAND_SERVER_LIBRARIES AND NOT TARGET Wayland::Server) + add_library(Wayland::Server UNKNOWN IMPORTED) + set_target_properties(Wayland::Server PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${WAYLAND_SERVER_INCLUDE_DIR}" IMPORTED_LOCATION "${WAYLAND_SERVER_LIBRARIES}") + endif() + if (WAYLAND_EGL_INCLUDE_DIR AND WAYLAND_EGL_LIBRARIES AND NOT TARGET Wayland::Egl) + add_library(Wayland::Egl UNKNOWN IMPORTED) + set_target_properties(Wayland::Egl PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${WAYLAND_EGL_INCLUDE_DIR}" IMPORTED_LOCATION "${WAYLAND_EGL_LIBRARIES}") + endif() + if (WAYLAND_CURSOR_INCLUDE_DIR AND WAYLAND_CURSOR_LIBRARIES AND NOT TARGET Wayland::Cursor) + add_library(Wayland::Cursor UNKNOWN IMPORTED) + set_target_properties(Wayland::Cursor PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${WAYLAND_CURSOR_INCLUDE_DIR}" IMPORTED_LOCATION "${WAYLAND_CURSOR_LIBRARIES}") + endif() + + MARK_AS_ADVANCED( + WAYLAND_CLIENT_INCLUDE_DIR WAYLAND_CLIENT_LIBRARIES + WAYLAND_SERVER_INCLUDE_DIR WAYLAND_SERVER_LIBRARIES + WAYLAND_EGL_INCLUDE_DIR WAYLAND_EGL_LIBRARIES + WAYLAND_CURSOR_INCLUDE_DIR WAYLAND_CURSOR_LIBRARIES + ) + +ENDIF () \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index f07566c044..0c07af1811 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,6 +67,7 @@ set(DOLPHIN_DEFAULT_UPDATE_TRACK "" CACHE STRING "Name of the default update tra if(UNIX AND NOT APPLE AND NOT ANDROID) option(ENABLE_X11 "Enables X11 Support" ON) + option(ENABLE_WAYLAND "Enables Wayland support" ON) endif() if(NOT WIN32 AND NOT APPLE AND NOT HAIKU) option(ENABLE_EGL "Enables EGL OpenGL Interface" ON) @@ -514,6 +515,11 @@ if(ENABLE_X11) endif() endif() +if(ENABLE_WAYLAND) + find_package(Wayland REQUIRED) + add_definitions(-DHAVE_WAYLAND=1) +endif() + if(ENABLE_EGL) find_package(EGL) if(EGL_FOUND)