Fixed bug 5072 - Test resources missing when building with SDL_TEST and CMake
authorSam Lantinga
Sun, 05 Apr 2020 08:46:59 -0700
changeset 136874897f7f06e52
parent 13686 42ef99a1bde2
child 13689 c3055b205671
Fixed bug 5072 - Test resources missing when building with SDL_TEST and CMake

DominikD

There are several tests that need resources in the output directory to work:
* `testiconv` depends on `utf8.txt`
* `testoverlay2` and `teststreaming` depend on `moose.dat`

This patch adds these two files to the `RESOURCE_FILES` variable.

One could also copy `shapes\*.bmp` over to the output directory for `testshape` to use but this patch doesn't do that for three reasons:
* executable takes path as an argument and doesn't need these files side by side
* these are ~45MB and copying them over would cause build directory to swell
* there are already files in the output directory that can be used with this test (`sample.bmp` and `button.bmp`)
test/CMakeLists.txt
     1.1 --- a/test/CMakeLists.txt	Thu Apr 02 12:27:29 2020 -0700
     1.2 +++ b/test/CMakeLists.txt	Sun Apr 05 08:46:59 2020 -0700
     1.3 @@ -94,7 +94,7 @@
     1.4  file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/resources_dummy.c "int main(int argc, const char **argv){ return 1; }\n")
     1.5  add_executable(SDL2_test_resoureces ${CMAKE_CURRENT_BINARY_DIR}/resources_dummy.c)
     1.6  
     1.7 -file(GLOB RESOURCE_FILES *.bmp *.wav)
     1.8 +file(GLOB RESOURCE_FILES *.bmp *.wav moose.dat utf8.txt)
     1.9  foreach(RESOURCE_FILE ${RESOURCE_FILES})
    1.10      add_custom_command(TARGET SDL2_test_resoureces POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${RESOURCE_FILE} $<TARGET_FILE_DIR:SDL2_test_resoureces>)
    1.11  endforeach(RESOURCE_FILE)