cmake+tests: include SDL_build_config.h in select tests + add include paths

This commit is contained in:
Anonymous Maarten 2023-03-21 18:16:45 +01:00 committed by Ozkan Sezer
parent 0bd5ce13db
commit c30903882b
3 changed files with 22 additions and 5 deletions

View File

@ -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)

View File

@ -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>

View File

@ -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>