cmake: build tests against installed SDL prefix

This commit is contained in:
Anonymous Maarten 2023-08-02 16:03:32 +02:00
parent 7f888f98f7
commit 75a71bde4b
5 changed files with 48 additions and 4 deletions

View File

@ -1,4 +1,4 @@
# This cmake build script is meant for verifying the various CMake configuration script.
# This cmake build script is meant for verifying the various CMake configuration scripts.
cmake_minimum_required(VERSION 3.12)
project(sdl_test LANGUAGES C)
@ -35,9 +35,14 @@ add_feature_info("TEST_STATIC" TEST_STATIC "Test linking with static library")
option(TEST_TEST "Test linking to SDL3_test library" ON)
add_feature_info("TEST_TEST" TEST_STATIC "Test linking to SDL test library")
option(TEST_FULL "Run complete SDL test suite" OFF)
add_feature_info("TEST_FULL" TEST_FULL "Build full SDL testsuite")
find_package(SDL3 REQUIRED CONFIG COMPONENTS Headers)
add_library(headers_test OBJECT inc_sdl_slash.c inc_sdl_noslash.c)
target_link_libraries(headers_test PRIVATE SDL3::Headers)
add_library(headers_test_slash OBJECT inc_sdl_slash.c)
target_link_libraries(headers_test_slash PRIVATE SDL3::Headers)
add_library(headers_test_noslash OBJECT inc_sdl_noslash.c)
target_link_libraries(headers_test_noslash PRIVATE SDL3::Headers)
if(TEST_SHARED)
find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3-shared)
@ -93,6 +98,15 @@ find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3)
add_executable(gui-whatever WIN32 main_gui.c)
target_link_libraries(gui-whatever PRIVATE SDL3::SDL3)
if(TEST_FULL)
enable_testing()
set(SDL_TESTS_TIMEOUT_MULTIPLIER "1" CACHE STRING "Test timeout multiplier")
set(SDL_TESTS_LINK_SHARED ${TEST_SHARED})
add_definitions(-DNO_BUILD_CONFIG)
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/../../test" SDL_test)
endif()
if(ANDROID)
find_package(SDL3 REQUIRED CONFIG COMPONENTS Jar)
endif()

View File

@ -2,7 +2,12 @@
# CMake script for building the SDL tests
#
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake")
include(CheckIncludeFile)
include(CheckStructHasMember)
include(CMakePushCheckState)
include(sdlcompilers)
if(SDL_TESTS_LINK_SHARED)
set(sdl_name_component SDL3-shared)
@ -220,7 +225,7 @@ if(HAVE_LIBUDEV_H)
endif()
set(FFmpeg_FIND_COMPONENTS AVCODEC AVFORMAT AVUTIL SWSCALE)
include("${SDL3_SOURCE_DIR}/cmake/FindFFmpeg.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/../cmake/FindFFmpeg.cmake")
if(FFmpeg_FOUND)
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_INCLUDES "${FFmpeg_AVUTIL_INCLUDE_DIRS}")

View File

@ -2,8 +2,10 @@
* Intrinsics test suite
*/
#ifndef NO_BUILD_CONFIG
/* Disable intrinsics that are unsupported by the current compiler */
#include <build_config/SDL_build_config.h>
#endif
#include <SDL3/SDL.h>
#include <SDL3/SDL_intrin.h>

View File

@ -19,6 +19,7 @@
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef NO_BUILD_CONFIG
#include <stddef.h>
/**
@ -1907,3 +1908,23 @@ SDLTest_TestSuiteReference penTestSuite = {
penTests,
NULL
};
#else
#include <SDL3/SDL_test.h>
#include "testautomation_suites.h"
/* Sequence of Mouse test cases */
static const SDLTest_TestCaseReference *penTests[] = {
NULL
};
/* Mouse test suite (global) */
SDLTest_TestSuiteReference penTestSuite = {
"Pen",
NULL,
penTests,
NULL
};
#endif

View File

@ -22,7 +22,9 @@
#endif
#define SDL_DYNAMIC_API 0
#ifndef NO_BUILD_CONFIG
#include "../src/SDL_internal.h"
#endif
#include <stdio.h>
#include <string.h>