mirror of https://github.com/encounter/SDL.git
cmake: make sure SDL2::SDL2 is always available
This commit is contained in:
parent
69df26a0d4
commit
6d1dfc8322
|
@ -3194,3 +3194,8 @@ endif()
|
||||||
|
|
||||||
##### Fix Objective C builds #####
|
##### Fix Objective C builds #####
|
||||||
set(CMAKE_OBJC_FLAGS "${CMAKE_OBJC_FLAGS} ${CMAKE_C_FLAGS}")
|
set(CMAKE_OBJC_FLAGS "${CMAKE_OBJC_FLAGS} ${CMAKE_C_FLAGS}")
|
||||||
|
|
||||||
|
# Make sure SDL2::SDL2 always exists
|
||||||
|
if(TARGET SDL2::SDL2-static AND NOT TARGET SDL2::SDL2)
|
||||||
|
add_library(SDL2::SDL2 ALIAS SDL2-static)
|
||||||
|
endif()
|
||||||
|
|
|
@ -30,12 +30,14 @@ endif()
|
||||||
check_required_components(SDL2)
|
check_required_components(SDL2)
|
||||||
|
|
||||||
# Create SDL2::SDL2 alias for static-only builds
|
# Create SDL2::SDL2 alias for static-only builds
|
||||||
if(NOT TARGET SDL2::SDL2 AND TARGET SDL2::SDL2-static)
|
if(TARGET SDL2::SDL2-static AND NOT TARGET SDL2::SDL2)
|
||||||
if(CMAKE_VERSION VERSION_LESS "3.18")
|
if(CMAKE_VERSION VERSION_LESS "3.18")
|
||||||
# Aliasing local targets is not supported on CMake < 3.18, so make it global.
|
# FIXME: Aliasing local targets is not supported on CMake < 3.18, so make it global.
|
||||||
set_target_properties(SDL2::SDL2-static PROPERTIES IMPORTED_GLOBAL TRUE)
|
add_library(SDL2::SDL2 INTERFACE IMPORTED)
|
||||||
|
set_target_properties(SDL2::SDL2 PROPERTIES INTERFACE_LINK_LIBRARIES "SDL2::SDL2-static")
|
||||||
|
else()
|
||||||
|
add_library(SDL2::SDL2 ALIAS SDL2::SDL2-static)
|
||||||
endif()
|
endif()
|
||||||
add_library(SDL2::SDL2 ALIAS SDL2::SDL2-static)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# For compatibility with autotools sdl2-config.cmake, provide SDL2_* variables.
|
# For compatibility with autotools sdl2-config.cmake, provide SDL2_* variables.
|
||||||
|
|
|
@ -192,3 +192,14 @@ macro(check_required_components _NAME)
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
check_required_components(SDL2)
|
check_required_components(SDL2)
|
||||||
|
|
||||||
|
# Create SDL2::SDL2 alias for static-only builds
|
||||||
|
if(TARGET SDL2::SDL2-static AND NOT TARGET SDL2::SDL2)
|
||||||
|
if(CMAKE_VERSION VERSION_LESS "3.18")
|
||||||
|
# FIXME: Aliasing local targets is not supported on CMake < 3.18, so make it global.
|
||||||
|
add_library(SDL2::SDL2 INTERFACE IMPORTED)
|
||||||
|
set_target_properties(SDL2::SDL2 PROPERTIES INTERFACE_LINK_LIBRARIES "SDL2::SDL2-static")
|
||||||
|
else()
|
||||||
|
add_library(SDL2::SDL2 ALIAS SDL2::SDL2-static)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
Loading…
Reference in New Issue