diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d2781d..07c8c01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,13 @@ message(STATUS "Build config: PLATFORM=${PLATFORM}, SDL_LINK_TYPE=${SDL_LINK_TYP # --- Resolve SDL --- 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 --- add_subdirectory(engine) add_subdirectory(game) \ No newline at end of file diff --git a/cmake/SDLSetup.cmake b/cmake/SDLSetup.cmake index 69cb0b5..3f151fe 100644 --- a/cmake/SDLSetup.cmake +++ b/cmake/SDLSetup.cmake @@ -30,7 +30,18 @@ if(SDL_LINK_TYPE STREQUAL "dynamic" AND WIN32) add_custom_target(copy_sdl_dll ALL COMMAND ${CMAKE_COMMAND} -E copy_if_different $ - "${CMAKE_BINARY_DIR}/game" + "${CMAKE_BINARY_DIR}/game/$" COMMENT "Copying SDL3.dll to output directory" ) +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() \ No newline at end of file diff --git a/prebuilt/linux/SDL3-dynamic/include/SDL3/SDL_revision.h b/prebuilt/linux/SDL3-dynamic/include/SDL3/SDL_revision.h index f98b314..26bb5bc 100644 --- a/prebuilt/linux/SDL3-dynamic/include/SDL3/SDL_revision.h +++ b/prebuilt/linux/SDL3-dynamic/include/SDL3/SDL_revision.h @@ -31,9 +31,9 @@ /* #undef 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 -#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 /* SDL_revision_h_ */ diff --git a/prebuilt/linux/SDL3-dynamic/lib/libSDL3.so.0 b/prebuilt/linux/SDL3-dynamic/lib/libSDL3.so.0 index 7233be7..60b77e6 120000 --- a/prebuilt/linux/SDL3-dynamic/lib/libSDL3.so.0 +++ b/prebuilt/linux/SDL3-dynamic/lib/libSDL3.so.0 @@ -1 +1 @@ -libSDL3.so.0.5.0 \ No newline at end of file +libSDL3.so.0.5 \ No newline at end of file diff --git a/prebuilt/linux/SDL3-dynamic/lib/libSDL3.so.0.5 b/prebuilt/linux/SDL3-dynamic/lib/libSDL3.so.0.5 new file mode 120000 index 0000000..7233be7 --- /dev/null +++ b/prebuilt/linux/SDL3-dynamic/lib/libSDL3.so.0.5 @@ -0,0 +1 @@ +libSDL3.so.0.5.0 \ No newline at end of file diff --git a/prebuilt/linux/SDL3-dynamic/lib/libSDL3.so.0.5.0 b/prebuilt/linux/SDL3-dynamic/lib/libSDL3.so.0.5.0 index cc18ae6..0751e0e 100644 Binary files a/prebuilt/linux/SDL3-dynamic/lib/libSDL3.so.0.5.0 and b/prebuilt/linux/SDL3-dynamic/lib/libSDL3.so.0.5.0 differ diff --git a/prebuilt/linux/SDL3-static/include/SDL3/SDL_revision.h b/prebuilt/linux/SDL3-static/include/SDL3/SDL_revision.h index f98b314..26bb5bc 100644 --- a/prebuilt/linux/SDL3-static/include/SDL3/SDL_revision.h +++ b/prebuilt/linux/SDL3-static/include/SDL3/SDL_revision.h @@ -31,9 +31,9 @@ /* #undef 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 -#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 /* SDL_revision_h_ */ diff --git a/prebuilt/linux/SDL3-static/lib/libSDL3.a b/prebuilt/linux/SDL3-static/lib/libSDL3.a index 298fd75..e0269d1 100644 Binary files a/prebuilt/linux/SDL3-static/lib/libSDL3.a and b/prebuilt/linux/SDL3-static/lib/libSDL3.a differ diff --git a/scripts/build_sdl_linux.sh b/scripts/build_sdl_linux.sh index 35b8aea..c2c5612 100644 --- a/scripts/build_sdl_linux.sh +++ b/scripts/build_sdl_linux.sh @@ -39,6 +39,32 @@ build_sdl() { 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) echo "Checking build dependencies..." sudo apt-get update -qq @@ -50,4 +76,9 @@ sudo apt-get install -y --no-install-recommends \ libgl1-mesa-dev build_sdl "dynamic" -build_sdl "static" \ No newline at end of file +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 \ No newline at end of file