From f2f8884f9595900c23e358e85c0225f915931a23 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 4 Apr 2023 19:08:47 +1000 Subject: [PATCH] CMake: reset WAYLAND_PROTOCOLS_DIR when it's missing the reference XML Depending on newer API's could cause build failure for existing builds using wayland-protocols outside of Blender's 'lib' directory. Now the existence of the most recent XML file is checked on each CMake execution, resetting the cache when not found so the protocols in `../lib/linux_x86_64_glibc_228/` will be used instead. --- .../cmake/platform/platform_unix.cmake | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake index 15294e740b8..5d21fbef94e 100644 --- a/build_files/cmake/platform/platform_unix.cmake +++ b/build_files/cmake/platform/platform_unix.cmake @@ -641,18 +641,29 @@ if(WITH_GHOST_WAYLAND) pkg_check_modules(wayland-egl wayland-egl) pkg_check_modules(wayland-scanner wayland-scanner) pkg_check_modules(wayland-cursor wayland-cursor) - pkg_check_modules(wayland-protocols wayland-protocols>=1.15) + pkg_check_modules(wayland-protocols wayland-protocols>=1.31) pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir) else() + # NOTE: this file must always refer to the newest API which is used, so older + # `wayland-protocols` are never found and used which then fail to locate required protocols. + set(_wayland_protocols_reference_file "staging/fractional-scale/fractional-scale-v1.xml") + + # Reset the protocols directory the reference file from `wayland-protocols` is not found. + # This avoids developers having build failures when a cached directory is used that no + # longer contains the required file. + if(DEFINED WAYLAND_PROTOCOLS_DIR) + if(NOT EXISTS "${WAYLAND_PROTOCOLS_DIR}/${_wayland_protocols_reference_file}") + unset(WAYLAND_PROTOCOLS_DIR CACHE) + endif() + endif() + # Rocky8 packages have too old a version, a newer version exist in the pre-compiled libraries. find_path(WAYLAND_PROTOCOLS_DIR - # NOTE: this file must always refer to the newest API which is used, so older - # `wayland-protocols` are never found and used which then fail to locate required protocols. - NAMES staging/fractional-scale/fractional-scale-v1.xml - + NAMES ${_wayland_protocols_reference_file} PATH_SUFFIXES share/wayland-protocols PATHS ${LIBDIR}/wayland-protocols ) + unset(_wayland_protocols_reference_file) if(EXISTS ${WAYLAND_PROTOCOLS_DIR}) set(wayland-protocols_FOUND ON)