cmake: fix installed SDL3::SDL3_test + test on ci

main
Anonymous Maarten 2023-01-31 05:26:02 +01:00
parent 72f40cb1f5
commit 0a3d038ff7
3 changed files with 22 additions and 1 deletions

View File

@ -3339,7 +3339,7 @@ if(NOT SDL_DISABLE_INSTALL)
set(SDL_SDLtest_INSTALL_RESOURCEDIR ".") set(SDL_SDLtest_INSTALL_RESOURCEDIR ".")
set(SDL_SDLtest_INSTALL_CMAKEDIR "${SDL_SDL_INSTALL_CMAKEDIR}") set(SDL_SDLtest_INSTALL_CMAKEDIR "${SDL_SDL_INSTALL_CMAKEDIR}")
set(SDL_SDLtest_INSTALL_CMAKEFILENAME "SDL3_testTargets.cmake") set(SDL_SDLtest_INSTALL_CMAKEFILENAME "SDL3testTargets.cmake")
endif() endif()
##### sdl3.pc ##### ##### sdl3.pc #####

View File

@ -27,6 +27,9 @@ add_feature_info("TEST_SHARED" TEST_SHARED "Test linking with shared library")
option(TEST_STATIC "Test linking to static SDL3 library" ON) option(TEST_STATIC "Test linking to static SDL3 library" ON)
add_feature_info("TEST_STATIC" TEST_STATIC "Test linking with static library") add_feature_info("TEST_STATIC" TEST_STATIC "Test linking with static library")
option(TEST_TEST "Test linking to SDL3_test library" ON)
add_feature_info("TEST_TEST" TEST_STATIC "Test linking to SDL test library")
find_package(SDL3 REQUIRED CONFIG COMPONENTS Headers) find_package(SDL3 REQUIRED CONFIG COMPONENTS Headers)
add_library(headers_test OBJECT inc_sdl_slash.c inc_sdl_noslash.c) add_library(headers_test OBJECT inc_sdl_slash.c inc_sdl_noslash.c)
target_link_libraries(headers_test PRIVATE SDL3::Headers) target_link_libraries(headers_test PRIVATE SDL3::Headers)
@ -54,6 +57,11 @@ if(TEST_SHARED)
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:SDL3::SDL3>" "$<TARGET_FILE_DIR:cli-shared>" COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:SDL3::SDL3>" "$<TARGET_FILE_DIR:cli-shared>"
) )
endif() endif()
if(TEST_TEST)
add_executable(sdltest-shared sdltest.c)
target_link_libraries(sdltest-shared PRIVATE SDL3::SDL3_test SDL3::SDL3)
endif()
endif() endif()
if(TEST_STATIC) if(TEST_STATIC)
@ -70,6 +78,10 @@ if(TEST_STATIC)
set_target_properties(sharedlib-static PROPERTIES C_VISIBILITY_PRESET "hidden") set_target_properties(sharedlib-static PROPERTIES C_VISIBILITY_PRESET "hidden")
endif() endif()
if(TEST_TEST)
add_executable(sdltest-static sdltest.c)
target_link_libraries(sdltest-static PRIVATE SDL3::SDL3_test SDL3::SDL3-static)
endif()
endif() endif()
feature_summary(WHAT ALL) feature_summary(WHAT ALL)

9
cmake/test/sdltest.c Normal file
View File

@ -0,0 +1,9 @@
#include <SDL3/SDL.h>
#include <SDL3/SDL_test.h>
int main(int argc, char *argv[]) {
SDLTest_CommonState state;
SDLTest_CommonDefaultArgs(&state, argc, argv);
return 0;
}