Files
hdk-sdl/cmake/hdk-sdlBundledSDL3Targets.cmake.in
T
2026-05-13 19:48:22 +00:00

37 lines
1.3 KiB
CMake

# Bundled SDL3 static library targets
# This file defines SDL3::SDL3 as an IMPORTED STATIC target pointing to the bundled
# SDL3 static library. This allows consumers of hdk-sdl to link against the bundled
# SDL3 without requiring system SDL3 to be installed.
# Compute the install prefix from this file's location
get_filename_component(_sdl3_install_prefix "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE)
macro(set_and_check _var _file)
set(${_var} "${_file}")
if(NOT EXISTS "${_file}")
message(FATAL_ERROR "File or directory ${_var}=${_file} referenced by hdk-sdlBundledSDL3Targets does not exist!")
endif()
endmacro()
# Validate the bundled SDL3 static library
set_and_check(_sdl3_lib_path "${_sdl3_install_prefix}/lib/cmake/hdk-sdl/sdl3-static/libSDL3.a")
# Define SDL3::SDL3 as IMPORTED STATIC target
if(NOT TARGET SDL3::SDL3)
add_library(SDL3::SDL3 STATIC IMPORTED GLOBAL)
set_target_properties(SDL3::SDL3 PROPERTIES
IMPORTED_LOCATION "${_sdl3_lib_path}"
VERSION "3.4.8"
)
# SDL3 is a static library; link dependencies would go here if needed
# For now, SDL3 is self-contained in the .a file
endif()
# Optionally define SDL3::SDL3-static as an alias for clarity
if(NOT TARGET SDL3::SDL3-static)
add_library(SDL3::SDL3-static ALIAS SDL3::SDL3)
endif()
unset(_sdl3_install_prefix)
unset(_sdl3_lib_path)