Skip to content

Commit 9fb466e

Browse files
smcvslouken
authored andcommitted
test: Optionally install manual tests for "as-installed" testing
This provides a convenient way to install manual tests onto a test system. For example in Debian these are packaged into the libsdl1.2-compat-tests binary package, from which they can be run with commands like: cd /usr/libexec/installed-tests/SDL12_compat ./testoverlay2 (The path used was historically /usr/libexec/installed-tests/libsdl1.2-compat, but this version uses a path that is more consistent with SDL2_compat.) Signed-off-by: Simon McVittie <[email protected]>
1 parent eee7543 commit 9fb466e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ if(NOT TARGET SDL::SDLmain)
1919
endif()
2020
endif()
2121

22+
option(SDL12COMPAT_INSTALL_TESTS "Install manual tests into libexecdir" OFF)
23+
24+
set(SDL12COMPAT_TEST_EXECUTABLES)
25+
set(SDL12COMPAT_TEST_RESOURCE_FILES)
26+
2227
if(NOT (WIN32 OR APPLE OR CYGWIN OR HAIKU OR BEOS))
2328
find_library(MATH_LIBRARY m)
2429
endif()
@@ -37,6 +42,7 @@ endif()
3742

3843
macro(test_program _NAME _SRCS)
3944
add_executable(${_NAME} ${_SRCS})
45+
list(APPEND SDL12COMPAT_TEST_EXECUTABLES ${_NAME})
4046
target_include_directories(${_NAME} PRIVATE "include/SDL")
4147
target_link_libraries(${_NAME} PRIVATE SDL::SDLmain SDL::SDL)
4248
# Turn off MSVC's aggressive C runtime warnings for the old test programs.
@@ -95,4 +101,16 @@ endif()
95101

96102
foreach(fname "icon.bmp" "moose.dat" "picture.xbm" "sail.bmp" "sample.bmp" "sample.wav" "utf8.txt")
97103
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/${fname}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
104+
list(APPEND SDL12COMPAT_TEST_RESOURCE_FILES "${fname}")
98105
endforeach(fname)
106+
107+
if(SDL12COMPAT_INSTALL_TESTS)
108+
install(
109+
TARGETS ${SDL12COMPAT_TEST_EXECUTABLES}
110+
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL12_compat
111+
)
112+
install(
113+
FILES ${SDL12COMPAT_TEST_RESOURCE_FILES}
114+
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL12_compat
115+
)
116+
endif()

0 commit comments

Comments
 (0)