@@ -102,6 +102,21 @@ define_property(TARGET PROPERTY SDL_NONINTERACTIVE BRIEF_DOCS "If true, target i
102102define_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." )
103103define_property (TARGET PROPERTY SDL_NONINTERACTIVE_TIMEOUT BRIEF_DOCS "Timeout for noninteractive executable." FULL_DOCS "Timeout for noninteractive executable." )
104104
105+ if (HAVE_X11)
106+ find_package (X11 QUIET )
107+ if (NOT TARGET X11::X11)
108+ set (HAVE_X11 OFF )
109+ endif ()
110+ endif ()
111+
112+ if (HAVE_WAYLAND)
113+ find_package (PkgConfig QUIET )
114+ pkg_check_modules(PkgWaylandClient QUIET IMPORTED_TARGET wayland-client)
115+ if (NOT TARGET PkgConfig::PkgWaylandClient)
116+ set (HAVE_WAYLAND OFF )
117+ endif ()
118+ endif ()
119+
105120function (add_sdl_test_executable TARGET )
106121 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} )
107122 if (AST_UNPARSED_ARGUMENTS)
@@ -338,15 +353,15 @@ elseif(HAVE_X11 OR HAVE_WAYLAND)
338353 add_sdl_test_executable(testnative BUILD_DEPENDENT NEEDS_RESOURCES TESTUTILS SOURCES testnative.c)
339354 if (HAVE_X11)
340355 target_sources (testnative PRIVATE testnativex11.c)
341- target_link_libraries (testnative PRIVATE X11)
356+ target_link_libraries (testnative PRIVATE X11::X11 )
342357 endif ()
343358 if (HAVE_WAYLAND)
344359 set_property (SOURCE ${SDL3_BINARY_DIR} /wayland-generated -protocols/xdg-shell-protocol.c PROPERTY GENERATED 1)
345- target_sources (testnative PRIVATE testnativewayland.c ${SDL3_BINARY_DIR} /wayland-generated -protocols/xdg-shell-protocol.c)
360+ target_sources (testnative PRIVATE testnativewayland.c " ${SDL3_BINARY_DIR} /wayland-generated-protocols/xdg-shell-protocol.c" )
346361
347362 # Needed to silence the documentation warning in the generated header file
348363 target_compile_options (testnative PRIVATE -Wno-documentation-unknown-command )
349- target_link_libraries (testnative PRIVATE wayland-client )
364+ target_link_libraries (testnative PRIVATE PkgConfig::PkgWaylandClient )
350365 endif ()
351366endif ()
352367
@@ -452,7 +467,7 @@ if (HAVE_WAYLAND)
452467 add_sdl_test_executable(testwaylandcustom NEEDS_RESOURCES SOURCES testwaylandcustom.c ${SDL3_BINARY_DIR} /wayland-generated -protocols/xdg-shell-protocol.c)
453468 # Needed to silence the documentation warning in the generated header file
454469 target_compile_options (testwaylandcustom PRIVATE -Wno-documentation-unknown-command )
455- target_link_libraries (testwaylandcustom PRIVATE wayland-client )
470+ target_link_libraries (testwaylandcustom PRIVATE PkgConfig::PkgWaylandClient )
456471endif ()
457472
458473check_c_compiler_flag(-Wformat-overflow HAVE_WFORMAT_OVERFLOW)
0 commit comments