diff options
Diffstat (limited to 'Tests/FindSDL/Test')
-rw-r--r-- | Tests/FindSDL/Test/CMakeLists.txt | 19 | ||||
-rw-r--r-- | Tests/FindSDL/Test/main.c | 18 |
2 files changed, 37 insertions, 0 deletions
diff --git a/Tests/FindSDL/Test/CMakeLists.txt b/Tests/FindSDL/Test/CMakeLists.txt new file mode 100644 index 0000000..61d4f4b --- /dev/null +++ b/Tests/FindSDL/Test/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.1) +project(TestFindSDL C) +include(CTest) + +find_package(SDL) + +add_definitions( + -DCMAKE_EXPECTED_SDL_VERSION_MAJOR=${SDL_VERSION_MAJOR} + -DCMAKE_EXPECTED_SDL_VERSION_MINOR=${SDL_VERSION_MINOR} + -DCMAKE_EXPECTED_SDL_VERSION_PATCH=${SDL_VERSION_PATCH}) + +add_executable(test_sdl_tgt main.c) +target_link_libraries(test_sdl_tgt SDL::SDL) +add_test(NAME test_sdl_tgt COMMAND test_sdl_tgt) + +add_executable(test_sdl_var main.c) +target_include_directories(test_sdl_var PRIVATE ${SDL_INCLUDE_DIRS}) +target_link_libraries(test_sdl_var PRIVATE ${SDL_LIBRARIES}) +add_test(NAME test_sdl_var COMMAND test_sdl_var) diff --git a/Tests/FindSDL/Test/main.c b/Tests/FindSDL/Test/main.c new file mode 100644 index 0000000..057289c --- /dev/null +++ b/Tests/FindSDL/Test/main.c @@ -0,0 +1,18 @@ +#include <SDL.h> + +int main() +{ + // Test 1 requires headers only. + SDL_version compiled; + SDL_VERSION(&compiled); + if (compiled.major != CMAKE_EXPECTED_SDL_VERSION_MAJOR || + compiled.minor != CMAKE_EXPECTED_SDL_VERSION_MINOR || + compiled.patch != CMAKE_EXPECTED_SDL_VERSION_PATCH) + return 1; + + // Test 2 requires to link to the library. + if (SDL_WasInit(SDL_INIT_VIDEO | SDL_INIT_AUDIO) != 0) + return 2; + + return 0; +} |