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>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5c695de..ff430ab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index f8a21fc..0a7b8a1 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -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()
diff --git a/test/Makefile.in b/test/Makefile.in
index 8c11dbf..d14e073 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -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 $@
diff --git a/test/configure.ac b/test/configure.ac
index 694551c..3d37b6a 100644
--- a/test/configure.ac
+++ b/test/configure.ac
@@ -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,