Fixed bug 4092 - CMake support for building everything in the "test" directory
Eric Wasylishen Patch to support building the tests with cmake. Disabled by default, use: "cmake .. -DSDL_TEST=YES" to enable the tests. Tested on macOS 10.13 with the ninja, makefile, and Xcode generators, and Windows 10 with the Visual Studio 2017 generator.
This commit is contained in:
@@ -340,6 +340,7 @@ set(SDL_SHARED ${SDL_SHARED_ENABLED_BY_DEFAULT} CACHE BOOL "Build a shared versi
|
||||
set(SDL_STATIC ON CACHE BOOL "Build a static version of the library")
|
||||
|
||||
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)
|
||||
|
||||
# General source files
|
||||
file(GLOB SOURCE_FILES
|
||||
@@ -1746,6 +1747,15 @@ if(SDL_STATIC)
|
||||
target_include_directories(SDL2-static PUBLIC $<INSTALL_INTERFACE:include>)
|
||||
endif()
|
||||
|
||||
##### Tests #####
|
||||
|
||||
if(SDL_TEST)
|
||||
file(GLOB TEST_SOURCES ${SDL2_SOURCE_DIR}/src/test/*.c)
|
||||
add_library(SDL2_test STATIC ${TEST_SOURCES})
|
||||
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
##### Installation targets #####
|
||||
install(TARGETS ${_INSTALL_LIBS} EXPORT SDL2Targets
|
||||
LIBRARY DESTINATION "lib${LIB_SUFFIX}"
|
||||
|
||||
Reference in New Issue
Block a user