tests: find X11 and wayland-client

This commit is contained in:
Anonymous Maarten
2025-12-08 19:38:37 +01:00
committed by Anonymous Maarten
parent d19b010d4e
commit f896e26f59

View File

@@ -102,6 +102,21 @@ define_property(TARGET PROPERTY SDL_NONINTERACTIVE BRIEF_DOCS "If true, target i
define_property(TARGET PROPERTY SDL_NONINTERACTIVE_ARGUMENTS BRIEF_DOCS "Argument(s) to run executable in non-interactive mode." FULL_DOCS "Argument(s) to run executable in non-interactive mode.") define_property(TARGET PROPERTY SDL_NONINTERACTIVE_ARGUMENTS BRIEF_DOCS "Argument(s) to run executable in non-interactive mode." FULL_DOCS "Argument(s) to run executable in non-interactive mode.")
define_property(TARGET PROPERTY SDL_NONINTERACTIVE_TIMEOUT BRIEF_DOCS "Timeout for noninteractive executable." FULL_DOCS "Timeout for noninteractive executable.") define_property(TARGET PROPERTY SDL_NONINTERACTIVE_TIMEOUT BRIEF_DOCS "Timeout for noninteractive executable." FULL_DOCS "Timeout for noninteractive executable.")
if(HAVE_X11)
find_package(X11 QUIET)
if(NOT TARGET X11::X11)
set(HAVE_X11 OFF)
endif()
endif()
if(HAVE_WAYLAND)
find_package(PkgConfig QUIET)
pkg_check_modules(PkgWaylandClient QUIET IMPORTED_TARGET wayland-client)
if(NOT TARGET PkgConfig::PkgWaylandClient)
set(HAVE_WAYLAND OFF)
endif()
endif()
function(add_sdl_test_executable TARGET) function(add_sdl_test_executable TARGET)
cmake_parse_arguments(AST "BUILD_DEPENDENT;NONINTERACTIVE;NEEDS_RESOURCES;TESTUTILS;THREADS;MAIN_CALLBACKS;NOTRACKMEM" "" "DEPENDS;DISABLE_THREADS_ARGS;NONINTERACTIVE_TIMEOUT;NONINTERACTIVE_ARGS;INSTALLED_ARGS;SOURCES" ${ARGN}) cmake_parse_arguments(AST "BUILD_DEPENDENT;NONINTERACTIVE;NEEDS_RESOURCES;TESTUTILS;THREADS;MAIN_CALLBACKS;NOTRACKMEM" "" "DEPENDS;DISABLE_THREADS_ARGS;NONINTERACTIVE_TIMEOUT;NONINTERACTIVE_ARGS;INSTALLED_ARGS;SOURCES" ${ARGN})
if(AST_UNPARSED_ARGUMENTS) if(AST_UNPARSED_ARGUMENTS)
@@ -338,15 +353,15 @@ elseif(HAVE_X11 OR HAVE_WAYLAND)
add_sdl_test_executable(testnative BUILD_DEPENDENT NEEDS_RESOURCES TESTUTILS SOURCES testnative.c) add_sdl_test_executable(testnative BUILD_DEPENDENT NEEDS_RESOURCES TESTUTILS SOURCES testnative.c)
if(HAVE_X11) if(HAVE_X11)
target_sources(testnative PRIVATE testnativex11.c) target_sources(testnative PRIVATE testnativex11.c)
target_link_libraries(testnative PRIVATE X11) target_link_libraries(testnative PRIVATE X11::X11)
endif() endif()
if(HAVE_WAYLAND) if(HAVE_WAYLAND)
set_property(SOURCE ${SDL3_BINARY_DIR}/wayland-generated-protocols/xdg-shell-protocol.c PROPERTY GENERATED 1) set_property(SOURCE ${SDL3_BINARY_DIR}/wayland-generated-protocols/xdg-shell-protocol.c PROPERTY GENERATED 1)
target_sources(testnative PRIVATE testnativewayland.c ${SDL3_BINARY_DIR}/wayland-generated-protocols/xdg-shell-protocol.c) target_sources(testnative PRIVATE testnativewayland.c "${SDL3_BINARY_DIR}/wayland-generated-protocols/xdg-shell-protocol.c")
# Needed to silence the documentation warning in the generated header file # Needed to silence the documentation warning in the generated header file
target_compile_options(testnative PRIVATE -Wno-documentation-unknown-command) target_compile_options(testnative PRIVATE -Wno-documentation-unknown-command)
target_link_libraries(testnative PRIVATE wayland-client) target_link_libraries(testnative PRIVATE PkgConfig::PkgWaylandClient)
endif () endif ()
endif() endif()
@@ -452,7 +467,7 @@ if (HAVE_WAYLAND)
add_sdl_test_executable(testwaylandcustom NEEDS_RESOURCES SOURCES testwaylandcustom.c ${SDL3_BINARY_DIR}/wayland-generated-protocols/xdg-shell-protocol.c) add_sdl_test_executable(testwaylandcustom NEEDS_RESOURCES SOURCES testwaylandcustom.c ${SDL3_BINARY_DIR}/wayland-generated-protocols/xdg-shell-protocol.c)
# Needed to silence the documentation warning in the generated header file # Needed to silence the documentation warning in the generated header file
target_compile_options(testwaylandcustom PRIVATE -Wno-documentation-unknown-command) target_compile_options(testwaylandcustom PRIVATE -Wno-documentation-unknown-command)
target_link_libraries(testwaylandcustom PRIVATE wayland-client) target_link_libraries(testwaylandcustom PRIVATE PkgConfig::PkgWaylandClient)
endif() endif()
check_c_compiler_flag(-Wformat-overflow HAVE_WFORMAT_OVERFLOW) check_c_compiler_flag(-Wformat-overflow HAVE_WFORMAT_OVERFLOW)