diff options
author | Brad King <brad.king@kitware.com> | 2020-06-19 12:16:33 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-06-19 12:16:40 (GMT) |
commit | c19b5765e13e49d71f57e7eb9772c758dd412bca (patch) | |
tree | 3d9819e02f5e7586d04fc0b0d5eb6d2561a59506 /Tests | |
parent | d736b2ef3ac9fcf97b6a8de02337056e6fd0d971 (diff) | |
parent | 9ffd2c70bff9eddc3cd056889212a3d12cdd9ead (diff) | |
download | CMake-c19b5765e13e49d71f57e7eb9772c758dd412bca.zip CMake-c19b5765e13e49d71f57e7eb9772c758dd412bca.tar.gz CMake-c19b5765e13e49d71f57e7eb9772c758dd412bca.tar.bz2 |
Merge topic 'FindSDL-update'
9ffd2c70bf FindSDL: Add SDL_INCLUDE_DIRS, SDL_LIBRARIES, and SDL::SDL
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4902
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/FindSDL/CMakeLists.txt | 10 | ||||
-rw-r--r-- | Tests/FindSDL/Test/CMakeLists.txt | 19 | ||||
-rw-r--r-- | Tests/FindSDL/Test/main.c | 18 |
4 files changed, 48 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 4fb905e..2b343d2 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1442,6 +1442,7 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH Patch PostgreSQL Protobuf + SDL SQLite3 TIFF Vulkan diff --git a/Tests/FindSDL/CMakeLists.txt b/Tests/FindSDL/CMakeLists.txt new file mode 100644 index 0000000..e786204 --- /dev/null +++ b/Tests/FindSDL/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindSDL.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindSDL/Test" + "${CMake_BINARY_DIR}/Tests/FindSDL/Test" + ${build_generator_args} + --build-project TestFindSDL + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) 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; +} |