mirror of https://github.com/encounter/SDL.git
cmake: install SDL2::SDL2test when configuring with SDL2_TEST enabled
This commit is contained in:
parent
ae2cc29f8b
commit
1087eaad7e
|
@ -346,6 +346,7 @@ if(EMSCRIPTEN)
|
||||||
set(SDL_ATOMIC_ENABLED_BY_DEFAULT OFF)
|
set(SDL_ATOMIC_ENABLED_BY_DEFAULT OFF)
|
||||||
set(SDL_LOADSO_ENABLED_BY_DEFAULT OFF)
|
set(SDL_LOADSO_ENABLED_BY_DEFAULT OFF)
|
||||||
set(SDL_CPUINFO_ENABLED_BY_DEFAULT OFF)
|
set(SDL_CPUINFO_ENABLED_BY_DEFAULT OFF)
|
||||||
|
set(SDL_TEST_ENABLED_BY_DEFAULT OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(VITA OR PSP)
|
if(VITA OR PSP)
|
||||||
|
@ -372,6 +373,10 @@ if (NOT DEFINED SDL_SHARED_ENABLED_BY_DEFAULT)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (NOT DEFINED SDL_TEST_ENABLED_BY_DEFAULT)
|
||||||
|
set(SDL_TEST_ENABLED_BY_DEFAULT ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(LONGESTOPTIONNAME 0) # set_option and friends will change this.
|
set(LONGESTOPTIONNAME 0) # set_option and friends will change this.
|
||||||
|
|
||||||
set(SDL_SUBSYSTEMS
|
set(SDL_SUBSYSTEMS
|
||||||
|
@ -469,9 +474,10 @@ set_option(SDL_ASAN "Use AddressSanitizer to detect memory errors
|
||||||
|
|
||||||
set(SDL_SHARED ${SDL_SHARED_ENABLED_BY_DEFAULT} CACHE BOOL "Build a shared version of the library")
|
set(SDL_SHARED ${SDL_SHARED_ENABLED_BY_DEFAULT} CACHE BOOL "Build a shared version of the library")
|
||||||
set(SDL_STATIC ${SDL_STATIC_ENABLED_BY_DEFAULT} CACHE BOOL "Build a static version of the library")
|
set(SDL_STATIC ${SDL_STATIC_ENABLED_BY_DEFAULT} CACHE BOOL "Build a static version of the library")
|
||||||
|
set(SDL_TEST ${SDL_TEST_ENABLED_BY_DEFAULT} CACHE BOOL "Build the SDL2_test library")
|
||||||
|
|
||||||
dep_option(SDL_STATIC_PIC "Static version of the library should be built with Position Independent Code" OFF "SDL_STATIC" OFF)
|
dep_option(SDL_STATIC_PIC "Static version of the library should be built with Position Independent Code" OFF "SDL_STATIC" OFF)
|
||||||
set_option(SDL_TEST "Build the test directory" OFF)
|
dep_option(SDL_TESTS "Build the test directory" OFF SDL_TEST OFF)
|
||||||
set_option(SDL_INSTALL_TESTS "Install test-cases" OFF)
|
set_option(SDL_INSTALL_TESTS "Install test-cases" OFF)
|
||||||
|
|
||||||
if(VITA)
|
if(VITA)
|
||||||
|
@ -2987,11 +2993,14 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSDL_BUILD_MICRO_VERSION=${SDL_MICRO_VERSIO
|
||||||
##### Tests #####
|
##### Tests #####
|
||||||
|
|
||||||
if(SDL_TEST)
|
if(SDL_TEST)
|
||||||
include(CTest)
|
|
||||||
include_directories(BEFORE "${SDL2_BINARY_DIR}/include")
|
include_directories(BEFORE "${SDL2_BINARY_DIR}/include")
|
||||||
include_directories(AFTER "${SDL2_SOURCE_DIR}/include")
|
include_directories(AFTER "${SDL2_SOURCE_DIR}/include")
|
||||||
file(GLOB TEST_SOURCES ${SDL2_SOURCE_DIR}/src/test/*.c)
|
file(GLOB TEST_SOURCES ${SDL2_SOURCE_DIR}/src/test/*.c)
|
||||||
add_library(SDL2_test STATIC ${TEST_SOURCES})
|
add_library(SDL2_test STATIC ${TEST_SOURCES})
|
||||||
|
add_library(SDL2::SDL2test ALIAS SDL2_test)
|
||||||
|
set_target_properties(SDL2_test PROPERTIES
|
||||||
|
EXPORT_NAME SDL2test)
|
||||||
|
target_include_directories(SDL2_test PUBLIC "$<BUILD_INTERFACE:${SDL2_SOURCE_DIR}/include>" $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
##### Installation targets #####
|
##### Installation targets #####
|
||||||
|
@ -3017,6 +3026,13 @@ if(NOT SDL2_DISABLE_INSTALL)
|
||||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(SDL_TEST)
|
||||||
|
install(TARGETS SDL2_test EXPORT SDL2testTargets
|
||||||
|
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||||
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||||
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
##### Export files #####
|
##### Export files #####
|
||||||
if (WINDOWS AND NOT MINGW)
|
if (WINDOWS AND NOT MINGW)
|
||||||
set(PKG_PREFIX "cmake")
|
set(PKG_PREFIX "cmake")
|
||||||
|
@ -3054,6 +3070,14 @@ if(NOT SDL2_DISABLE_INSTALL)
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(SDL_TEST)
|
||||||
|
install(EXPORT SDL2testTargets
|
||||||
|
FILE SDL2testTargets.cmake
|
||||||
|
NAMESPACE SDL2::
|
||||||
|
DESTINATION ${PKG_PREFIX}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/SDL2Config.cmake
|
${CMAKE_CURRENT_SOURCE_DIR}/SDL2Config.cmake
|
||||||
|
@ -3119,7 +3143,8 @@ endif()
|
||||||
|
|
||||||
##### Tests subproject (must appear after the install/uninstall targets) #####
|
##### Tests subproject (must appear after the install/uninstall targets) #####
|
||||||
|
|
||||||
if(SDL_TEST)
|
if(SDL_TESTS)
|
||||||
|
enable_testing()
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,9 @@ endif()
|
||||||
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL2staticTargets.cmake")
|
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL2staticTargets.cmake")
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/SDL2staticTargets.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/SDL2staticTargets.cmake")
|
||||||
endif()
|
endif()
|
||||||
|
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL2testTargets.cmake")
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/SDL2testTargets.cmake")
|
||||||
|
endif()
|
||||||
|
|
||||||
# on static-only builds create an alias
|
# on static-only builds create an alias
|
||||||
if(NOT TARGET SDL2::SDL2 AND TARGET SDL2::SDL2-static)
|
if(NOT TARGET SDL2::SDL2 AND TARGET SDL2::SDL2-static)
|
||||||
|
|
|
@ -73,7 +73,7 @@ To use, set the following CMake variables when running CMake's configuration sta
|
||||||
|
|
||||||
- for iOS-Simulator, using the latest, installed SDK, and building SDL test apps (as .app bundles):
|
- for iOS-Simulator, using the latest, installed SDK, and building SDL test apps (as .app bundles):
|
||||||
|
|
||||||
`cmake ~/sdl -DSDL_TEST=1 -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=x86_64`
|
`cmake ~/sdl -DSDL_TESTS=1 -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=x86_64`
|
||||||
|
|
||||||
- for tvOS-Simulator, using the latest, installed SDK:
|
- for tvOS-Simulator, using the latest, installed SDK:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue