mirror of https://github.com/libsdl-org/SDL
cmake: use compatible interface properties to disallow linking to a different version of SDL
This commit is contained in:
parent
987b748067
commit
103fbcfc05
|
@ -3245,9 +3245,13 @@ if(SDL_SHARED)
|
||||||
target_link_options(SDL3-shared PRIVATE -static-libgcc)
|
target_link_options(SDL3-shared PRIVATE -static-libgcc)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
# Use `Compatible Interface Properties` to allow consumers to enforce a shared/static library
|
# Use `Compatible Interface Properties` to:
|
||||||
set_property(TARGET SDL3-shared PROPERTY INTERFACE_SDL3_SHARED TRUE)
|
# - allow consumers to enforce a shared/static library
|
||||||
|
# - block linking to SDL libraries of different major version
|
||||||
set_property(TARGET SDL3-shared APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SDL3_SHARED)
|
set_property(TARGET SDL3-shared APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SDL3_SHARED)
|
||||||
|
set_property(TARGET SDL3-shared PROPERTY INTERFACE_SDL3_SHARED TRUE)
|
||||||
|
set_property(TARGET SDL3-shared APPEND PROPERTY COMPATIBLE_INTERFACE_STRING "SDL_VERSION")
|
||||||
|
set_property(TARGET SDL3-shared PROPERTY INTERFACE_SDL_VERSION "SDL${SDL3_VERSION_MAJOR}")
|
||||||
if(NOT CMAKE_VERSION VERSION_LESS "3.16")
|
if(NOT CMAKE_VERSION VERSION_LESS "3.16")
|
||||||
target_precompile_headers(SDL3-shared PRIVATE "${PROJECT_SOURCE_DIR}/src/SDL_internal.h")
|
target_precompile_headers(SDL3-shared PRIVATE "${PROJECT_SOURCE_DIR}/src/SDL_internal.h")
|
||||||
endif()
|
endif()
|
||||||
|
@ -3283,9 +3287,13 @@ if(SDL_STATIC)
|
||||||
# This picks up all the compiler options and such we've accumulated up to here.
|
# This picks up all the compiler options and such we've accumulated up to here.
|
||||||
target_link_libraries(SDL3-static PRIVATE $<${build_local_interface}:sdl-build-options>)
|
target_link_libraries(SDL3-static PRIVATE $<${build_local_interface}:sdl-build-options>)
|
||||||
target_link_libraries(SDL3-static PRIVATE $<${build_local_interface}:sdl-global-options>)
|
target_link_libraries(SDL3-static PRIVATE $<${build_local_interface}:sdl-global-options>)
|
||||||
# Use `Compatible Interface Properties` to allow consumers to enforce a shared/static library
|
# Use `Compatible Interface Properties` to:
|
||||||
set_property(TARGET SDL3-static PROPERTY INTERFACE_SDL3_SHARED FALSE)
|
# - allow consumers to enforce a shared/static library
|
||||||
|
# - block linking to SDL libraries of different major version
|
||||||
set_property(TARGET SDL3-static APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SDL3_SHARED)
|
set_property(TARGET SDL3-static APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SDL3_SHARED)
|
||||||
|
set_property(TARGET SDL3-static PROPERTY INTERFACE_SDL3_SHARED FALSE)
|
||||||
|
set_property(TARGET SDL3-static APPEND PROPERTY COMPATIBLE_INTERFACE_STRING "SDL_VERSION")
|
||||||
|
set_property(TARGET SDL3-static PROPERTY INTERFACE_SDL_VERSION "SDL${SDL3_VERSION_MAJOR}")
|
||||||
if(NOT CMAKE_VERSION VERSION_LESS "3.16")
|
if(NOT CMAKE_VERSION VERSION_LESS "3.16")
|
||||||
target_precompile_headers(SDL3-static PRIVATE "${PROJECT_SOURCE_DIR}/src/SDL_internal.h")
|
target_precompile_headers(SDL3-static PRIVATE "${PROJECT_SOURCE_DIR}/src/SDL_internal.h")
|
||||||
endif()
|
endif()
|
||||||
|
@ -3322,6 +3330,8 @@ if(SDL_TEST)
|
||||||
)
|
)
|
||||||
target_link_libraries(SDL3_test PUBLIC $<TARGET_NAME:SDL3::Headers>)
|
target_link_libraries(SDL3_test PUBLIC $<TARGET_NAME:SDL3::Headers>)
|
||||||
target_link_libraries(SDL3_test PRIVATE ${EXTRA_TEST_LIBS})
|
target_link_libraries(SDL3_test PRIVATE ${EXTRA_TEST_LIBS})
|
||||||
|
set_property(TARGET SDL3_test APPEND PROPERTY COMPATIBLE_INTERFACE_STRING "SDL_VERSION")
|
||||||
|
set_property(TARGET SDL3_test PROPERTY INTERFACE_SDL_VERSION "SDL${SDL3_VERSION_MAJOR}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
##### Configure installation folders #####
|
##### Configure installation folders #####
|
||||||
|
|
|
@ -72,6 +72,8 @@ if(EXISTS "${_sdl3_library}" AND EXISTS "${_sdl3_dll_library}")
|
||||||
IMPORTED_LOCATION "${_sdl3_dll_library}"
|
IMPORTED_LOCATION "${_sdl3_dll_library}"
|
||||||
COMPATIBLE_INTERFACE_BOOL "SDL3_SHARED"
|
COMPATIBLE_INTERFACE_BOOL "SDL3_SHARED"
|
||||||
INTERFACE_SDL3_SHARED "ON"
|
INTERFACE_SDL3_SHARED "ON"
|
||||||
|
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
|
||||||
|
INTERFACE_SDL_VERSION "SDL3"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
set(SDL3_SDL3-shared_FOUND TRUE)
|
set(SDL3_SDL3-shared_FOUND TRUE)
|
||||||
|
@ -91,6 +93,8 @@ if(EXISTS "${_sdl3test_library}")
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
INTERFACE_LINK_LIBRARIES "SDL3::Headers"
|
INTERFACE_LINK_LIBRARIES "SDL3::Headers"
|
||||||
IMPORTED_LOCATION "${_sdl3test_library}"
|
IMPORTED_LOCATION "${_sdl3test_library}"
|
||||||
|
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
|
||||||
|
INTERFACE_SDL_VERSION "SDL3"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
set(SDL3_SDL3_test_FOUND TRUE)
|
set(SDL3_SDL3_test_FOUND TRUE)
|
||||||
|
|
|
@ -65,6 +65,8 @@ if(NOT TARGET SDL3::SDL3-shared)
|
||||||
IMPORTED_SONAME "${_sdl3_framework_path}/SDL3"
|
IMPORTED_SONAME "${_sdl3_framework_path}/SDL3"
|
||||||
COMPATIBLE_INTERFACE_BOOL "SDL3_SHARED"
|
COMPATIBLE_INTERFACE_BOOL "SDL3_SHARED"
|
||||||
INTERFACE_SDL3_SHARED "ON"
|
INTERFACE_SDL3_SHARED "ON"
|
||||||
|
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
|
||||||
|
INTERFACE_SDL_VERSION "SDL3"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
set(SDL3_SDL3-shared_FOUND TRUE)
|
set(SDL3_SDL3-shared_FOUND TRUE)
|
||||||
|
|
Loading…
Reference in New Issue