From ed1e4ab1bf3ea4e817c8a81cdee350b9adf04986 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Fri, 30 Jul 2021 22:03:12 +0100 Subject: cmake: disable WITH_GHOST_WAYLAND if any Wayland dependency is missing This sets WITH_GHOST_WAYLAND to ON and auto-disables it again, if one of the required Wayland development libraries is missing. Differential Revision: D11489 --- CMakeLists.txt | 2 +- build_files/cmake/platform/platform_unix.cmake | 63 ++++++++++++++++++++------ intern/ghost/CMakeLists.txt | 14 ------ 3 files changed, 50 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 201608a531a..ac5e977fba1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -221,7 +221,7 @@ if(UNIX AND NOT (APPLE OR HAIKU)) option(WITH_GHOST_X11 "Enable building Blender against X11 for windowing" ON) mark_as_advanced(WITH_GHOST_X11) - option(WITH_GHOST_WAYLAND "Enable building Blender against Wayland for windowing (under development)" OFF) + option(WITH_GHOST_WAYLAND "Enable building Blender against Wayland for windowing (under development)" ON) mark_as_advanced(WITH_GHOST_WAYLAND) endif() diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake index ffdbbc3f8c5..038a9ba4dac 100644 --- a/build_files/cmake/platform/platform_unix.cmake +++ b/build_files/cmake/platform/platform_unix.cmake @@ -574,20 +574,55 @@ endif() if(WITH_GHOST_WAYLAND) find_package(PkgConfig) - pkg_check_modules(wayland-client REQUIRED wayland-client>=1.12) - pkg_check_modules(wayland-egl REQUIRED wayland-egl) - pkg_check_modules(wayland-scanner REQUIRED wayland-scanner) - pkg_check_modules(xkbcommon REQUIRED xkbcommon) - pkg_check_modules(wayland-cursor REQUIRED wayland-cursor) - pkg_check_modules(dbus REQUIRED dbus-1) - - list(APPEND PLATFORM_LINKLIBS - ${wayland-client_LINK_LIBRARIES} - ${wayland-egl_LINK_LIBRARIES} - ${xkbcommon_LINK_LIBRARIES} - ${wayland-cursor_LINK_LIBRARIES} - ${dbus_LINK_LIBRARIES} - ) + pkg_check_modules(wayland-client QUIET wayland-client>=1.12) + pkg_check_modules(wayland-egl QUIET wayland-egl) + pkg_check_modules(wayland-scanner QUIET wayland-scanner) + pkg_check_modules(wayland-cursor QUIET wayland-cursor) + pkg_check_modules(xkbcommon QUIET xkbcommon) + pkg_check_modules(dbus QUIET dbus-1) + pkg_check_modules(wayland-protocols QUIET wayland-protocols>=1.15) + + if (${wayland-protocols_FOUND}) + pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir) + else() + find_path(WAYLAND_PROTOCOLS_DIR + NAMES unstable/xdg-decoration/xdg-decoration-unstable-v1.xml + PATH_SUFFIXES share/wayland-protocols + ) + endif() + + if(NOT wayland-client_FOUND) + message(STATUS "wayland-client not found, disabling WITH_GHOST_WAYLAND") + set(WITH_GHOST_WAYLAND OFF) + elseif(NOT wayland-egl_FOUND) + message(STATUS "wayland-egl not found, disabling WITH_GHOST_WAYLAND") + set(WITH_GHOST_WAYLAND OFF) + elseif(NOT wayland-scanner_FOUND) + message(STATUS "wayland-scanner not found, disabling WITH_GHOST_WAYLAND") + set(WITH_GHOST_WAYLAND OFF) + elseif(NOT wayland-cursor_FOUND) + message(STATUS "wayland-cursor not found, disabling WITH_GHOST_WAYLAND") + set(WITH_GHOST_WAYLAND OFF) + elseif(NOT xkbcommon_FOUND) + message(STATUS "xkbcommon not found, disabling WITH_GHOST_WAYLAND") + set(WITH_GHOST_WAYLAND OFF) + elseif(NOT dbus_FOUND) + message(STATUS "dbus not found, disabling WITH_GHOST_WAYLAND") + set(WITH_GHOST_WAYLAND OFF) + elseif(NOT EXISTS ${WAYLAND_PROTOCOLS_DIR}) + message(STATUS "wayland-protocols not found, disabling WITH_GHOST_WAYLAND") + set(WITH_GHOST_WAYLAND OFF) + endif() + + if(WITH_GHOST_WAYLAND) + list(APPEND PLATFORM_LINKLIBS + ${wayland-client_LINK_LIBRARIES} + ${wayland-egl_LINK_LIBRARIES} + ${xkbcommon_LINK_LIBRARIES} + ${wayland-cursor_LINK_LIBRARIES} + ${dbus_LINK_LIBRARIES} + ) + endif() endif() if(WITH_GHOST_X11) diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt index 76cac1049fb..83686fe9cc0 100644 --- a/intern/ghost/CMakeLists.txt +++ b/intern/ghost/CMakeLists.txt @@ -306,20 +306,6 @@ elseif(WITH_GHOST_X11 OR WITH_GHOST_WAYLAND) pkg_get_variable(WAYLAND_SCANNER wayland-scanner wayland_scanner) - pkg_check_modules(wayland-protocols wayland-protocols>=1.15) - if (${wayland-protocols_FOUND}) - pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir) - else() - find_path(WAYLAND_PROTOCOLS_DIR - NAMES unstable/xdg-decoration/xdg-decoration-unstable-v1.xml - PATH_SUFFIXES share/wayland-protocols - ) - endif() - - if (NOT EXISTS ${WAYLAND_PROTOCOLS_DIR}) - message(FATAL_ERROR "path to wayland-protocols not found") - endif() - # Generate protocols bindings. macro(generate_protocol_bindings NAME PROT_DEF) add_custom_command( -- cgit v1.2.3