Alias SDL2::SDL2 to SDL2::SDL2-static on static-only builds

main
Ivan Epifanov 2021-07-13 13:47:08 +03:00 committed by Sam Lantinga
parent cd7ef24cba
commit 407867cf72
1 changed files with 9 additions and 0 deletions

View File

@ -1,5 +1,14 @@
include("${CMAKE_CURRENT_LIST_DIR}/SDL2Targets.cmake")
# on static-only builds create an alias
if(NOT TARGET SDL2::SDL2 AND TARGET SDL2::SDL2-static)
if(CMAKE_VERSION VERSION_LESS "3.18")
# Aliasing local targets is not supported on CMake < 3.18, so make it global.
set_target_properties(SDL2::SDL2-static PROPERTIES IMPORTED_GLOBAL TRUE)
endif()
add_library(SDL2::SDL2 ALIAS SDL2::SDL2-static)
endif()
# provide ${SDL2_LIBRARIES}, ${SDL2_INCLUDE_DIRS} etc, like sdl2-config.cmake does,
# for compatibility between SDL2 built with autotools and SDL2 built with CMake