From c30903882b0de9cb77e1ae43b74964724f0bd8e8 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Tue, 21 Mar 2023 18:16:45 +0100
Subject: [PATCH] cmake+tests: include SDL_build_config.h in select tests + add
include paths
---
test/CMakeLists.txt | 19 ++++++++++++++-----
test/testautomation_intrinsics.c | 4 ++++
test/testautomation_syswm.c | 4 ++++
3 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index b0a2e85ec423..0fd0f0c45676 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -30,6 +30,12 @@ if(NOT TARGET SDL3::${sdl_name_component})
find_package(SDL3 3.0.0 REQUIRED CONFIG COMPONENTS ${sdl_name_component} SDL3_test)
endif()
+if(TARGET sdl-build-options)
+ set(SDL3_TESTS_SUBPROJECT ON)
+else()
+ set(SDL3_TESTS_SUBPROJECT OFF)
+endif()
+
# CMake incorrectly detects opengl32.lib being present on MSVC ARM64
if(NOT MSVC OR NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64")
# Prefer GLVND, if present
@@ -115,6 +121,13 @@ macro(add_sdl_test_executable TARGET)
if(TARGET sdl-global-options)
target_link_libraries(${TARGET} PRIVATE $<BUILD_INTERFACE:sdl-global-options>)
endif()
+
+ if(SDL3_TESTS_SUBPROJECT)
+ # FIXME: only add "${SDL3_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>" + include paths of external dependencies
+ target_include_directories(${TARGET} PRIVATE "$<TARGET_PROPERTY:SDL3::${sdl_name_component},INCLUDE_DIRECTORIES>")
+ else()
+ target_include_directories(${TARGET} PRIVATE "../include")
+ endif()
endmacro()
check_include_file(signal.h HAVE_SIGNAL_H)
@@ -149,7 +162,7 @@ add_sdl_test_executable(testdrawchessboard SOURCES testdrawchessboard.c)
add_sdl_test_executable(testdropfile SOURCES testdropfile.c)
add_sdl_test_executable(testerror NONINTERACTIVE SOURCES testerror.c)
-if(LINUX AND TARGET sdl-build-options)
+if(LINUX AND SDL3_TESTS_SUBPROJECT)
set(build_options_dependent_tests )
add_sdl_test_executable(testevdev NONINTERACTIVE SOURCES testevdev.c)
@@ -258,10 +271,6 @@ if(HAVE_WFORMAT_EXTRA_ARGS)
target_compile_definitions(testautomation PRIVATE HAVE_WFORMAT_EXTRA_ARGS)
endif()
-if(NOT HAVE_X11)
- target_compile_definitions(testautomation PRIVATE SDL_DISABLE_SYSWM_X11)
-endif()
-
if(SDL_DUMMYAUDIO)
set_property(TARGET testaudioinfo PROPERTY SDL_NONINTERACTIVE 1)
set_property(TARGET testsurround PROPERTY SDL_NONINTERACTIVE 1)
diff --git a/test/testautomation_intrinsics.c b/test/testautomation_intrinsics.c
index bbc452d9fcb2..2add76957538 100644
--- a/test/testautomation_intrinsics.c
+++ b/test/testautomation_intrinsics.c
@@ -1,6 +1,10 @@
/**
* Intrinsics test suite
*/
+
+/* Disable intrinsics that are unsupported by the current compiler */
+#include <build_config/SDL_build_config.h>
+
#include <SDL3/SDL.h>
#include <SDL3/SDL_intrin.h>
#include <SDL3/SDL_test.h>
diff --git a/test/testautomation_syswm.c b/test/testautomation_syswm.c
index 74b4c49a5b1d..069c4b13cce9 100644
--- a/test/testautomation_syswm.c
+++ b/test/testautomation_syswm.c
@@ -1,6 +1,10 @@
/**
* SysWM test suite
*/
+
+/* Avoid inclusion of e.g. X11 headers when these are not installed */
+#include <build_config/SDL_build_config.h>
+
#include <SDL3/SDL.h>
#include <SDL3/SDL_syswm.h>
#include <SDL3/SDL_test.h>