test: Add a `make install` target for the tests

This makes it more convenient to compile them alongside SDL, install
them in an optional package and use them as smoke-tests or diagnostic
tools. The default installation directory is taken from GNOME's
installed-tests, which seems as good a convention as any other:
https://wiki.gnome.org/Initiatives/GnomeGoals/InstalledTests

Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie 2020-11-25 13:30:29 +00:00 committed by Sam Lantinga
parent 76a7b629bf
commit 38ef678990
4 changed files with 112 additions and 0 deletions

View File

@ -472,6 +472,7 @@ set(SDL_STATIC ${SDL_STATIC_ENABLED_BY_DEFAULT} CACHE BOOL "Build a static versi
dep_option(SDL_STATIC_PIC "Static version of the library should be built with Position Independent Code" OFF "SDL_STATIC" OFF)
set_option(SDL_TEST "Build the test directory" OFF)
set_option(SDL_INSTALL_TESTS "Install test-cases" OFF)
if(VITA)
set_option(VIDEO_VITA_PIB "Build with PSVita piglet gles2 support" OFF)

View File

@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.0.0)
project(SDL2 C)
include(CTest)
if(SDL_INSTALL_TESTS)
include(GNUInstallDirs)
endif()
# Global settings for all of the test targets
# FIXME: is this wrong?
remove_definitions(-DUSING_GENERATED_CONFIG_H)
@ -136,6 +140,77 @@ add_executable(controllermap controllermap.c testutils.c)
add_executable(testvulkan testvulkan.c)
add_executable(testoffscreen testoffscreen.c)
SET(ALL_TESTS
checkkeys
checkkeysthreads
controllermap
loopwave
loopwavequeue
testatomic
testaudiocapture
testaudiohotplug
testaudioinfo
testautomation
testbounds
testcustomcursor
testdisplayinfo
testdraw2
testdrawchessboard
testdropfile
testerror
testfile
testfilesystem
testgamecontroller
testgeometry
testgesture
testgl2
testgles
testgles2
testhaptic
testhittesting
testhotplug
testiconv
testime
testintersections
testjoystick
testkeys
testloadso
testlocale
testlock
testmessage
testmouse
testmultiaudio
testnative
testoffscreen
testoverlay2
testplatform
testpower
testqsort
testrelative
testrendercopyex
testrendertarget
testresample
testrumble
testscale
testsem
testsensor
testshader
testshape
testsprite2
testspriteminimal
teststreaming
testsurround
testthread
testtimer
testurl
testver
testviewport
testvulkan
testwm2
testyuv
torturethread
)
set(NONINTERACTIVE
testatomic
testerror
@ -151,6 +226,7 @@ set(NONINTERACTIVE
)
if(LINUX)
list(APPEND ALL_TESTS testevdev)
list(APPEND NONINTERACTIVE testevdev)
endif()
@ -354,3 +430,14 @@ foreach(TESTCASE ${NONINTERACTIVE} ${NEEDS_AUDIO} ${NEEDS_DISPLAY})
PROPERTIES ENVIRONMENT "${TESTS_ENVIRONMENT}"
)
endforeach()
if(SDL_INSTALL_TESTS)
install(
TARGETS ${ALL_TESTS}
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL2
)
install(
FILES ${RESOURCE_FILES}
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL2
)
endif()

View File

@ -2,6 +2,15 @@
srcdir = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
libdir = @libdir@
libexecdir = @libexecdir@
includedir = @includedir@
datarootdir = @datarootdir@
datadir = @datadir@
CC = @CC@
EXE = @EXE@
CFLAGS = @CFLAGS@ -g
@ -81,6 +90,12 @@ TARGETS = \
all: Makefile $(TARGETS) copydatafiles
installedtestsdir = $(libexecdir)/installed-tests/SDL2
install: all
install -D -t $(DESTDIR)$(installedtestsdir) $(TARGETS)
install -m644 -D -t $(DESTDIR)$(installedtestsdir) $(DATA)
Makefile: $(srcdir)/Makefile.in
$(SHELL) config.status $@

View File

@ -99,6 +99,15 @@ AC_SUBST(ISWINDOWS)
AC_SUBST(ISUNIX)
AC_SUBST(ISOS2)
AC_SUBST([prefix])
AC_SUBST([exec_prefix])
AC_SUBST([bindir])
AC_SUBST([libdir])
AC_SUBST([libexecdir])
AC_SUBST([includedir])
AC_SUBST([datarootdir])
AC_SUBST([datadir])
dnl Check for SDL
SDL_VERSION=2.0.18
AM_PATH_SDL2($SDL_VERSION,