all variants (windows/linux)(static/dynamic) now work

This commit is contained in:
Colin Sames
2026-04-03 17:27:10 +02:00
parent 9e56634fd5
commit 7b07d01400
9 changed files with 57 additions and 7 deletions

View File

@@ -18,6 +18,13 @@ message(STATUS "Build config: PLATFORM=${PLATFORM}, SDL_LINK_TYPE=${SDL_LINK_TYP
# --- Resolve SDL --- # --- Resolve SDL ---
include(cmake/SDLSetup.cmake) include(cmake/SDLSetup.cmake)
# --- Apply Linux dynamic RPATH globally so all targets can find libSDL3.so.0
# at runtime. SDL_LINUX_RPATH is set by SDLSetup.cmake only on Linux + dynamic.
if(DEFINED SDL_LINUX_RPATH)
message(STATUS "Setting CMAKE_BUILD_RPATH to: ${SDL_LINUX_RPATH}")
set(CMAKE_BUILD_RPATH "${SDL_LINUX_RPATH}")
endif()
# --- Subdirectories --- # --- Subdirectories ---
add_subdirectory(engine) add_subdirectory(engine)
add_subdirectory(game) add_subdirectory(game)

View File

@@ -30,7 +30,18 @@ if(SDL_LINK_TYPE STREQUAL "dynamic" AND WIN32)
add_custom_target(copy_sdl_dll ALL add_custom_target(copy_sdl_dll ALL
COMMAND ${CMAKE_COMMAND} -E copy_if_different COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:SDL3::SDL3> $<TARGET_FILE:SDL3::SDL3>
"${CMAKE_BINARY_DIR}/game" "${CMAKE_BINARY_DIR}/game/$<TARGET_FILE_NAME:SDL3::SDL3>"
COMMENT "Copying SDL3.dll to output directory" COMMENT "Copying SDL3.dll to output directory"
) )
endif() endif()
# On Linux with dynamic linking, embed the absolute path to the prebuilt lib
# directory in the binary's RPATH. The prebuilt/linux directory is built
# in-place on Linux by build_sdl_linux.sh and is never synced from Windows,
# so the path is always valid on the remote machine.
if(SDL_LINK_TYPE STREQUAL "dynamic" AND UNIX AND NOT APPLE)
get_target_property(SDL3_SO_LOCATION SDL3::SDL3 LOCATION)
get_filename_component(SDL3_LIB_DIR "${SDL3_SO_LOCATION}" DIRECTORY)
message(STATUS "SDL3 runtime library directory: ${SDL3_LIB_DIR}")
set(SDL_LINUX_RPATH "${SDL3_LIB_DIR}" CACHE INTERNAL "")
endif()

View File

@@ -31,9 +31,9 @@
/* #undef SDL_VENDOR_INFO */ /* #undef SDL_VENDOR_INFO */
#ifdef SDL_VENDOR_INFO #ifdef SDL_VENDOR_INFO
#define SDL_REVISION "SDL-3.5.0-release-3.4.0-501-gf3a3b4b95 (" SDL_VENDOR_INFO ")" #define SDL_REVISION "SDL-3.5.0-release-3.4.0-502-gf4255e15b (" SDL_VENDOR_INFO ")"
#else #else
#define SDL_REVISION "SDL-3.5.0-release-3.4.0-501-gf3a3b4b95" #define SDL_REVISION "SDL-3.5.0-release-3.4.0-502-gf4255e15b"
#endif #endif
#endif /* SDL_revision_h_ */ #endif /* SDL_revision_h_ */

View File

@@ -1 +1 @@
libSDL3.so.0.5.0 libSDL3.so.0.5

View File

@@ -0,0 +1 @@
libSDL3.so.0.5.0

View File

@@ -31,9 +31,9 @@
/* #undef SDL_VENDOR_INFO */ /* #undef SDL_VENDOR_INFO */
#ifdef SDL_VENDOR_INFO #ifdef SDL_VENDOR_INFO
#define SDL_REVISION "SDL-3.5.0-release-3.4.0-501-gf3a3b4b95 (" SDL_VENDOR_INFO ")" #define SDL_REVISION "SDL-3.5.0-release-3.4.0-502-gf4255e15b (" SDL_VENDOR_INFO ")"
#else #else
#define SDL_REVISION "SDL-3.5.0-release-3.4.0-501-gf3a3b4b95" #define SDL_REVISION "SDL-3.5.0-release-3.4.0-502-gf4255e15b"
#endif #endif
#endif /* SDL_revision_h_ */ #endif /* SDL_revision_h_ */

View File

@@ -39,6 +39,32 @@ build_sdl() {
echo "=== Done: $OUT_DIR ===" echo "=== Done: $OUT_DIR ==="
} }
create_dynamic_symlinks() {
local LIB_DIR="$PREBUILT_DIR/SDL3-dynamic/lib"
local REAL_FILE
REAL_FILE="$(find "$LIB_DIR" -maxdepth 1 -name 'libSDL3.so.*.*' | head -1)"
if [ -z "$REAL_FILE" ]; then
echo "ERROR: No versioned libSDL3.so file found in $LIB_DIR" >&2
exit 1
fi
local REAL_NAME
REAL_NAME="$(basename "$REAL_FILE")"
local SONAME="${REAL_NAME%.*}"
echo ""
echo "=== Creating SDL3 symlinks in $LIB_DIR ==="
echo " $SONAME -> $REAL_NAME"
echo " libSDL3.so -> $SONAME"
ln -sf "$REAL_NAME" "$LIB_DIR/$SONAME"
ln -sf "$SONAME" "$LIB_DIR/libSDL3.so"
echo "=== Done ==="
}
# Install build dependencies if needed (Debian 12 bookworm) # Install build dependencies if needed (Debian 12 bookworm)
echo "Checking build dependencies..." echo "Checking build dependencies..."
sudo apt-get update -qq sudo apt-get update -qq
@@ -51,3 +77,8 @@ sudo apt-get install -y --no-install-recommends \
build_sdl "dynamic" build_sdl "dynamic"
build_sdl "static" build_sdl "static"
# Always recreate symlinks regardless of whether the build was a no-op.
# cmake --install does not preserve symlinks and Ninja may skip the build
# entirely if sources are unchanged, leaving the lib directory without them.
create_dynamic_symlinks