diff --git a/cmake/curl.cmake b/cmake/curl.cmake index 13752f16615..c675c45e905 100644 --- a/cmake/curl.cmake +++ b/cmake/curl.cmake @@ -2,6 +2,6 @@ # Finds libcurl via vcpkg on Linux/macOS. Windows builds do not use this module. if(SAGE_UPDATE_CHECK) - find_package(CURL CONFIG REQUIRED) + find_package(CURL REQUIRED) message(STATUS "libcurl found: ${CURL_VERSION_STRING}") endif() diff --git a/cmake/miniaudio.cmake b/cmake/miniaudio.cmake index 784c1aa0f03..257464aaea3 100644 --- a/cmake/miniaudio.cmake +++ b/cmake/miniaudio.cmake @@ -8,39 +8,56 @@ # Reference: https://github.com/feliwir/CnC_Generals_Zero_Hour (MiniAudio backend by Stephan Vedder) if(SAGE_USE_MINIAUDIO) - message(STATUS "Configuring miniaudio via FetchContent...") + set(MINIAUDIO_INCLUDE_DIR FALSE) + + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + find_path(MINIAUDIO_INCLUDE_DIR miniaudio.h) + endif() - include(FetchContent) + if(MINIAUDIO_INCLUDE_DIR) + message(STATUS "✓ Found system miniaudio header at ${MINIAUDIO_INCLUDE_DIR}") + add_library(miniaudio_lib INTERFACE) + target_include_directories(miniaudio_lib INTERFACE ${MINIAUDIO_INCLUDE_DIR}) + target_compile_definitions(miniaudio_lib INTERFACE SAGE_USE_MINIAUDIO) + + # Platform-specific audio backend configuration + if(APPLE) + target_compile_definitions(miniaudio_lib INTERFACE + MA_NO_WASAPI MA_NO_DSOUND MA_NO_WINMM) + elseif(UNIX) + target_compile_definitions(miniaudio_lib INTERFACE + MA_NO_WASAPI MA_NO_DSOUND MA_NO_WINMM MA_NO_COREAUDIO) + endif() + else() + message(STATUS "Configuring miniaudio via FetchContent...") - FetchContent_Declare( - miniaudio - URL "https://github.com/mackron/miniaudio/archive/refs/heads/master.tar.gz" - ) + include(FetchContent) - # miniaudio is a single-header library; we just need the source directory - # Use FETCHCONTENT_UPDATES_DISCONNECTED to avoid re-downloading - FetchContent_GetProperties(miniaudio) - if(NOT miniaudio_POPULATED) - FetchContent_Populate(miniaudio) - endif() + FetchContent_Declare( + miniaudio + URL "https://github.com/mackron/miniaudio/archive/refs/heads/master.tar.gz" + ) - # Create an interface target for miniaudio (single-header library) - # We don't use miniaudio's CMakeLists.txt because it builds optional node - # libraries with incorrect linking. Instead, we use the single-header approach. - add_library(miniaudio_lib INTERFACE) - target_include_directories(miniaudio_lib INTERFACE ${miniaudio_SOURCE_DIR}) - target_compile_definitions(miniaudio_lib INTERFACE SAGE_USE_MINIAUDIO) - - # Platform-specific audio backend configuration - if(APPLE) - # Use CoreAudio on macOS - target_compile_definitions(miniaudio_lib INTERFACE - MA_NO_WASAPI MA_NO_DSOUND MA_NO_WINMM) - elseif(UNIX) - # Use ALSA on Linux (PulseAudio/PipeWire via ALSA compat) - target_compile_definitions(miniaudio_lib INTERFACE - MA_NO_WASAPI MA_NO_DSOUND MA_NO_WINMM MA_NO_COREAUDIO) - endif() + FetchContent_GetProperties(miniaudio) + if(NOT miniaudio_POPULATED) + FetchContent_Populate(miniaudio) + endif() - message(STATUS "miniaudio configured: target miniaudio_lib available") + add_library(miniaudio_lib INTERFACE) + target_include_directories(miniaudio_lib INTERFACE ${miniaudio_SOURCE_DIR}) + target_compile_definitions(miniaudio_lib INTERFACE SAGE_USE_MINIAUDIO) + + # Platform-specific audio backend configuration + if(APPLE) + # Use CoreAudio on macOS + target_compile_definitions(miniaudio_lib INTERFACE + MA_NO_WASAPI MA_NO_DSOUND MA_NO_WINMM) + elseif(UNIX) + # Use ALSA on Linux (PulseAudio/PipeWire via ALSA compat) + target_compile_definitions(miniaudio_lib INTERFACE + MA_NO_WASAPI MA_NO_DSOUND MA_NO_WINMM MA_NO_COREAUDIO) + endif() + + message(STATUS "miniaudio configured: target miniaudio_lib available") + endif() endif() diff --git a/cmake/openal.cmake b/cmake/openal.cmake index df7c32917e8..f62f32b9ed9 100644 --- a/cmake/openal.cmake +++ b/cmake/openal.cmake @@ -25,30 +25,41 @@ # Reference: jmarshall OpenAL implementation uses throughout. if(SAGE_USE_OPENAL) - message(STATUS "Configuring OpenAL Soft (v1.24.2) with FetchContent...") - - include(FetchContent) - - FetchContent_Declare( - openal_soft - URL "https://github.com/kcat/openal-soft/archive/refs/tags/1.24.2.tar.gz" - URL_HASH "SHA256=7efd383d70508587fbc146e4c508771a2235a5fc8ae05bf6fe721c20a348bd7c" - ) - - # Minimal build: no utilities, examples, or tests - set(ALSOFT_INSTALL_RUNTIME_LIBS ON CACHE BOOL "Install runtime libs" FORCE) - set(ALSOFT_EXAMPLES OFF CACHE BOOL "Build examples" FORCE) - set(ALSOFT_TESTS OFF CACHE BOOL "Build tests" FORCE) - set(ALSOFT_UTILS OFF CACHE BOOL "Build utils" FORCE) - set(ALSOFT_NO_CONFIG_UTIL ON CACHE BOOL "Disable config util" FORCE) - - if(WIN32) - # Windows: WASAPI is the modern low-latency audio API - set(ALSOFT_REQUIRE_WASAPI ON CACHE BOOL "Require WASAPI backend on Windows" FORCE) + set(OPENAL_FOUND FALSE) + set(OpenAL_FOUND FALSE) + + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + find_package(OpenAL QUIET) endif() - FetchContent_MakeAvailable(openal_soft) + if(OPENAL_FOUND OR OpenAL_FOUND) + message(STATUS "✓ Found system OpenAL. Using it.") + else() + message(STATUS "Configuring OpenAL Soft (v1.24.2) with FetchContent...") + + include(FetchContent) + + FetchContent_Declare( + openal_soft + URL "https://github.com/kcat/openal-soft/archive/refs/tags/1.24.2.tar.gz" + URL_HASH "SHA256=7efd383d70508587fbc146e4c508771a2235a5fc8ae05bf6fe721c20a348bd7c" + ) + + # Minimal build: no utilities, examples, or tests + set(ALSOFT_INSTALL_RUNTIME_LIBS ON CACHE BOOL "Install runtime libs" FORCE) + set(ALSOFT_EXAMPLES OFF CACHE BOOL "Build examples" FORCE) + set(ALSOFT_TESTS OFF CACHE BOOL "Build tests" FORCE) + set(ALSOFT_UTILS OFF CACHE BOOL "Build utils" FORCE) + set(ALSOFT_NO_CONFIG_UTIL ON CACHE BOOL "Disable config util" FORCE) - # openal-soft FetchContent creates the OpenAL::OpenAL imported target - message(STATUS "OpenAL Soft configured: target OpenAL::OpenAL available") + if(WIN32) + # Windows: WASAPI is the modern low-latency audio API + set(ALSOFT_REQUIRE_WASAPI ON CACHE BOOL "Require WASAPI backend on Windows" FORCE) + endif() + + FetchContent_MakeAvailable(openal_soft) + + # openal-soft FetchContent creates the OpenAL::OpenAL imported target + message(STATUS "OpenAL Soft configured: target OpenAL::OpenAL available") + endif() endif() diff --git a/cmake/sdl3.cmake b/cmake/sdl3.cmake index c66cabe1783..8de797f00f2 100644 --- a/cmake/sdl3.cmake +++ b/cmake/sdl3.cmake @@ -8,127 +8,134 @@ # This avoids vcpkg issues with libsystemd and complex dependencies if(SAGE_USE_SDL3) - # GeneralsX @build BenderAI 22/02/2026 (updated) - # Strategy: FetchContent to compile SDL3 + SDL3_image from source - # Docker environment (ubuntu:24.04) has build dependencies pre-installed - # This ensures local build compatibility (same glibc, same distro as developer machine) - # Reference: https://github.com/libsdl-org/SDL/releases/download/release-3.4.2/SDL3-3.4.2.tar.gz + set(SDL3_FOUND FALSE) + set(SDL3_image_FOUND FALSE) - message(STATUS "Configuring SDL3 (v3.4.2) with FetchContent (native build)...") - - include(FetchContent) - - # SDL3 - Core graphics, input, events, filesystem - set(SDL3_VERSION "3.4.2") - set(SDL3_URL "https://github.com/libsdl-org/SDL/releases/download/release-${SDL3_VERSION}/SDL3-${SDL3_VERSION}.tar.gz") - set(SDL3_URL_HASH "SHA256=ef39a2e3f9a8a78296c40da701967dd1b0d0d6e267e483863ce70f8a03b4050c") - - FetchContent_Declare( - SDL3 - URL ${SDL3_URL} - URL_HASH ${SDL3_URL_HASH} - ) - - # Configure SDL3 build options - set(SDL_SHARED ON CACHE BOOL "Build SDL3 as shared library" FORCE) - set(SDL_STATIC OFF CACHE BOOL "Don't build static library" FORCE) - set(SDL_AUDIO ON CACHE BOOL "Enable audio subsystem" FORCE) - set(SDL_TIMERS ON CACHE BOOL "Enable timers" FORCE) - set(SDL_EVENTS ON CACHE BOOL "Enable events" FORCE) - set(SDL_FILESYSTEM ON CACHE BOOL "Enable filesystem" FORCE) - set(SDL_RENDER ON CACHE BOOL "Enable render subsystem" FORCE) - set(SDL_VIDEO ON CACHE BOOL "Enable video subsystem" FORCE) - - # Platform support - set(SDL_WAYLAND ON CACHE BOOL "Enable Wayland support (Linux)" FORCE) - set(SDL_X11 ON CACHE BOOL "Enable X11 support (Linux)" FORCE) - set(SDL_CAMERA OFF CACHE BOOL "Disable camera (unused)" FORCE) - set(SDL_QSPI OFF CACHE BOOL "Disable QSPI (unused)" FORCE) - - FetchContent_MakeAvailable(SDL3) - - # GeneralsX @bugfix BenderAI 22/02/2026 (updated 24/02/2026 for macOS) - # Before SDL3_image build: force PNG discovery to platform-specific libpng - # Linux: System libpng16.so is dynamic shared library - # macOS: Use Homebrew PNG or system framework - if(NOT APPLE) - # Find system shared libpng, bypassing vcpkg's static .a. - # SDL3_image requires a shared .so but vcpkg only provides static libpng16.a. - # NO_CMAKE_PATH + NO_CMAKE_FIND_ROOT_PATH skips all vcpkg-injected search paths, - # so find_library uses only system paths (/usr/lib, /usr/lib64, multilib dirs). - find_library(PNG_LIBRARY NAMES png16 png NO_CMAKE_PATH NO_CMAKE_FIND_ROOT_PATH) - find_path(PNG_PNG_INCLUDE_DIR png.h PATH_SUFFIXES libpng16 NO_CMAKE_PATH NO_CMAKE_FIND_ROOT_PATH) - find_package(PNG REQUIRED MODULE) + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + find_package(SDL3 3.4.0 QUIET) + find_package(SDL3_image 3.4.0 QUIET) + endif() + + if(SDL3_FOUND AND SDL3_image_FOUND) + message(STATUS "✓ Found system SDL3 and SDL3_image packages. Using them.") + add_library(sdl3lib INTERFACE) + target_link_libraries(sdl3lib INTERFACE SDL3::SDL3 SDL3_image::SDL3_image) else() - # macOS: Force Homebrew's dynamic libpng, bypassing vcpkg's static .a - # GeneralsX @build BenderAI 24/02/2026 - Phase 5 macOS port - # vcpkg provides static libpng16.a but SDL3_image requires dynamic .dylib - # Homebrew installs libpng16.16.dylib at /usr/local/lib (Intel) or /opt/homebrew/lib (ARM) - set(PNG_SHARED ON CACHE BOOL "Require PNG as shared library" FORCE) - # GeneralsX @bugfix BenderAI 25/02/2026 Check Apple Silicon Homebrew (/opt/homebrew) FIRST. - # A machine with both Homebrew installations (Intel Rosetta + native arm64) could have - # /usr/local/lib/libpng16.dylib (x86_64) AND /opt/homebrew/lib/libpng16.dylib (arm64). - # Linking the x86_64 dylib into an arm64 binary produces: - # ld: warning: ignoring file '...libpng16.dylib': found architecture 'x86_64', required 'arm64' - # Always prefer /opt/homebrew (arm64) for arm64 builds. - if(EXISTS "/opt/homebrew/lib/libpng16.dylib") - # Apple Silicon Mac (Homebrew prefix: /opt/homebrew) - set(PNG_INCLUDE_DIR "/opt/homebrew/include" CACHE PATH "PNG include dir (Homebrew)" FORCE) - set(PNG_LIBRARY "/opt/homebrew/lib/libpng16.dylib" CACHE FILEPATH "PNG library (Homebrew .dylib)" FORCE) - set(PNG_LIBRARY_DEBUG "/opt/homebrew/lib/libpng16.dylib" CACHE FILEPATH "" FORCE) - set(PNG_LIBRARY_RELEASE "/opt/homebrew/lib/libpng16.dylib" CACHE FILEPATH "" FORCE) - elseif(EXISTS "/usr/local/lib/libpng16.dylib") - # Intel Mac fallback (Homebrew prefix: /usr/local) - set(PNG_INCLUDE_DIR "/usr/local/include" CACHE PATH "PNG include dir (Homebrew)" FORCE) - set(PNG_LIBRARY "/usr/local/lib/libpng16.dylib" CACHE FILEPATH "PNG library (Homebrew .dylib)" FORCE) - set(PNG_LIBRARY_DEBUG "/usr/local/lib/libpng16.dylib" CACHE FILEPATH "" FORCE) - set(PNG_LIBRARY_RELEASE "/usr/local/lib/libpng16.dylib" CACHE FILEPATH "" FORCE) + message(STATUS "Configuring SDL3 (v3.4.2) with FetchContent (native build)...") + + include(FetchContent) + + # SDL3 - Core graphics, input, events, filesystem + set(SDL3_VERSION "3.4.2") + set(SDL3_URL "https://github.com/libsdl-org/SDL/releases/download/release-${SDL3_VERSION}/SDL3-${SDL3_VERSION}.tar.gz") + set(SDL3_URL_HASH "SHA256=ef39a2e3f9a8a78296c40da701967dd1b0d0d6e267e483863ce70f8a03b4050c") + + FetchContent_Declare( + SDL3 + URL ${SDL3_URL} + URL_HASH ${SDL3_URL_HASH} + ) + + # Configure SDL3 build options + set(SDL_SHARED ON CACHE BOOL "Build SDL3 as shared library" FORCE) + set(SDL_STATIC OFF CACHE BOOL "Don't build static library" FORCE) + set(SDL_AUDIO ON CACHE BOOL "Enable audio subsystem" FORCE) + set(SDL_TIMERS ON CACHE BOOL "Enable timers" FORCE) + set(SDL_EVENTS ON CACHE BOOL "Enable events" FORCE) + set(SDL_FILESYSTEM ON CACHE BOOL "Enable filesystem" FORCE) + set(SDL_RENDER ON CACHE BOOL "Enable render subsystem" FORCE) + set(SDL_VIDEO ON CACHE BOOL "Enable video subsystem" FORCE) + + # Platform support + set(SDL_WAYLAND ON CACHE BOOL "Enable Wayland support (Linux)" FORCE) + set(SDL_X11 ON CACHE BOOL "Enable X11 support (Linux)" FORCE) + set(SDL_CAMERA OFF CACHE BOOL "Disable camera (unused)" FORCE) + set(SDL_QSPI OFF CACHE BOOL "Disable QSPI (unused)" FORCE) + + FetchContent_MakeAvailable(SDL3) + + # GeneralsX @bugfix BenderAI 22/02/2026 (updated 24/02/2026 for macOS) + # Before SDL3_image build: force PNG discovery to platform-specific libpng + # Linux: System libpng16.so is dynamic shared library + # macOS: Use Homebrew PNG or system framework + if(NOT APPLE) + # Find system shared libpng, bypassing vcpkg's static .a. + # SDL3_image requires a shared .so but vcpkg only provides static libpng16.a. + # NO_CMAKE_PATH + NO_CMAKE_FIND_ROOT_PATH skips all vcpkg-injected search paths, + # so find_library uses only system paths (/usr/lib, /usr/lib64, multilib dirs). + find_library(PNG_LIBRARY NAMES png16 png NO_CMAKE_PATH NO_CMAKE_FIND_ROOT_PATH) + find_path(PNG_PNG_INCLUDE_DIR png.h PATH_SUFFIXES libpng16 NO_CMAKE_PATH NO_CMAKE_FIND_ROOT_PATH) + find_package(PNG REQUIRED MODULE) else() - message(FATAL_ERROR "libpng not found. Install: brew install libpng") + # macOS: Force Homebrew's dynamic libpng, bypassing vcpkg's static .a + # GeneralsX @build BenderAI 24/02/2026 - Phase 5 macOS port + # vcpkg provides static libpng16.a but SDL3_image requires dynamic .dylib + # Homebrew installs libpng16.16.dylib at /usr/local/lib (Intel) or /opt/homebrew/lib (ARM) + set(PNG_SHARED ON CACHE BOOL "Require PNG as shared library" FORCE) + # GeneralsX @bugfix BenderAI 25/02/2026 Check Apple Silicon Homebrew (/opt/homebrew) FIRST. + # A machine with both Homebrew installations (Intel Rosetta + native arm64) could have + # /usr/local/lib/libpng16.dylib (x86_64) AND /opt/homebrew/lib/libpng16.dylib (arm64). + # Linking the x86_64 dylib into an arm64 binary produces: + # ld: warning: ignoring file '...libpng16.dylib': found architecture 'x86_64', required 'arm64' + # Always prefer /opt/homebrew (arm64) for arm64 builds. + if(EXISTS "/opt/homebrew/lib/libpng16.dylib") + # Apple Silicon Mac (Homebrew prefix: /opt/homebrew) + set(PNG_INCLUDE_DIR "/opt/homebrew/include" CACHE PATH "PNG include dir (Homebrew)" FORCE) + set(PNG_LIBRARY "/opt/homebrew/lib/libpng16.dylib" CACHE FILEPATH "PNG library (Homebrew .dylib)" FORCE) + set(PNG_LIBRARY_DEBUG "/opt/homebrew/lib/libpng16.dylib" CACHE FILEPATH "" FORCE) + set(PNG_LIBRARY_RELEASE "/opt/homebrew/lib/libpng16.dylib" CACHE FILEPATH "" FORCE) + elseif(EXISTS "/usr/local/lib/libpng16.dylib") + # Intel Mac fallback (Homebrew prefix: /usr/local) + set(PNG_INCLUDE_DIR "/usr/local/include" CACHE PATH "PNG include dir (Homebrew)" FORCE) + set(PNG_LIBRARY "/usr/local/lib/libpng16.dylib" CACHE FILEPATH "PNG library (Homebrew .dylib)" FORCE) + set(PNG_LIBRARY_DEBUG "/usr/local/lib/libpng16.dylib" CACHE FILEPATH "" FORCE) + set(PNG_LIBRARY_RELEASE "/usr/local/lib/libpng16.dylib" CACHE FILEPATH "" FORCE) + else() + message(FATAL_ERROR "libpng not found. Install: brew install libpng") + endif() + find_package(PNG REQUIRED MODULE) endif() - find_package(PNG REQUIRED MODULE) + + # Tell CMake to find PNG - this should use our explicit system .so above, not vcpkg + + # SDL3_image - Image format support (PNG, JPG for cursor ANI loading) + message(STATUS "Configuring SDL3_image (v3.4.0) with FetchContent (native build)...") + + set(SDL3_IMAGE_VERSION "3.4.0") + set(SDL3_IMAGE_URL "https://github.com/libsdl-org/SDL_image/releases/download/release-${SDL3_IMAGE_VERSION}/SDL3_image-${SDL3_IMAGE_VERSION}.tar.gz") + set(SDL3_IMAGE_URL_HASH "SHA256=2ceb75eab4235c2c7e93dafc3ef3268ad368ca5de40892bf8cffdd510f29d9d8") + + FetchContent_Declare( + SDL3_image + URL ${SDL3_IMAGE_URL} + URL_HASH ${SDL3_IMAGE_URL_HASH} + ) + + # Configure SDL3_image build options + # Note: PNG will use system libpng-dev (installed in Docker, no vcpkg conflicts) + set(SDL3IMAGE_INSTALL ON CACHE BOOL "Install SDL3_image" FORCE) + set(SDL3IMAGE_DEPS_SHARED ON CACHE BOOL "Use system shared dependencies" FORCE) + set(SDL3IMAGE_JPG ON CACHE BOOL "Enable JPG support" FORCE) + set(SDL3IMAGE_PNG ON CACHE BOOL "Enable PNG support (ANI cursor loading)" FORCE) + set(SDL3IMAGE_TIF ON CACHE BOOL "Enable TIF support" FORCE) + set(SDL3IMAGE_WEBP ON CACHE BOOL "Enable WebP support" FORCE) + set(SDL3IMAGE_AVIF OFF CACHE BOOL "Disable AVIF (optional)" FORCE) + set(SDL3IMAGE_XCUR ON CACHE BOOL "Enable X cursor support" FORCE) + + FetchContent_MakeAvailable(SDL3_image) + + # Create unified interface library for linking + add_library(sdl3lib INTERFACE) + target_link_libraries(sdl3lib INTERFACE SDL3::SDL3 SDL3_image::SDL3_image) + + # Expose include directories + target_include_directories(sdl3lib INTERFACE + "${SDL3_SOURCE_DIR}/include" + "${sdl3_image_SOURCE_DIR}/include" + ) + + message(STATUS "✓ SDL3 (${SDL3_VERSION}) + SDL3_image (${SDL3_IMAGE_VERSION}) configured") + message(STATUS " Build approach: Native FetchContent compilation") + message(STATUS " PNG support: System libpng-dev (dynamic linking)") endif() - - # Tell CMake to find PNG - this should use our explicit system .so above, not vcpkg - - # SDL3_image - Image format support (PNG, JPG for cursor ANI loading) - message(STATUS "Configuring SDL3_image (v3.4.0) with FetchContent (native build)...") - - set(SDL3_IMAGE_VERSION "3.4.0") - set(SDL3_IMAGE_URL "https://github.com/libsdl-org/SDL_image/releases/download/release-${SDL3_IMAGE_VERSION}/SDL3_image-${SDL3_IMAGE_VERSION}.tar.gz") - set(SDL3_IMAGE_URL_HASH "SHA256=2ceb75eab4235c2c7e93dafc3ef3268ad368ca5de40892bf8cffdd510f29d9d8") - - FetchContent_Declare( - SDL3_image - URL ${SDL3_IMAGE_URL} - URL_HASH ${SDL3_IMAGE_URL_HASH} - ) - - # Configure SDL3_image build options - # Note: PNG will use system libpng-dev (installed in Docker, no vcpkg conflicts) - set(SDL3IMAGE_INSTALL ON CACHE BOOL "Install SDL3_image" FORCE) - set(SDL3IMAGE_DEPS_SHARED ON CACHE BOOL "Use system shared dependencies" FORCE) - set(SDL3IMAGE_JPG ON CACHE BOOL "Enable JPG support" FORCE) - set(SDL3IMAGE_PNG ON CACHE BOOL "Enable PNG support (ANI cursor loading)" FORCE) - set(SDL3IMAGE_TIF ON CACHE BOOL "Enable TIF support" FORCE) - set(SDL3IMAGE_WEBP ON CACHE BOOL "Enable WebP support" FORCE) - set(SDL3IMAGE_AVIF OFF CACHE BOOL "Disable AVIF (optional)" FORCE) - set(SDL3IMAGE_XCUR ON CACHE BOOL "Enable X cursor support" FORCE) - - FetchContent_MakeAvailable(SDL3_image) - - # Create unified interface library for linking - add_library(sdl3lib INTERFACE) - target_link_libraries(sdl3lib INTERFACE SDL3::SDL3 SDL3_image::SDL3_image) - - # Expose include directories - target_include_directories(sdl3lib INTERFACE - "${SDL3_SOURCE_DIR}/include" - "${sdl3_image_SOURCE_DIR}/include" - ) - - message(STATUS "✓ SDL3 (${SDL3_VERSION}) + SDL3_image (${SDL3_IMAGE_VERSION}) configured") - message(STATUS " Build approach: Native FetchContent compilation") - message(STATUS " PNG support: System libpng-dev (dynamic linking)") - endif() diff --git a/docs/BUILD/LINUX.md b/docs/BUILD/LINUX.md index c2688ba6298..99b33ef6e36 100644 --- a/docs/BUILD/LINUX.md +++ b/docs/BUILD/LINUX.md @@ -97,7 +97,7 @@ sudo dnf install gcc-c++ cmake ninja-build git sudo dnf install vulkan-loader vulkan-tools mesa-vulkan-drivers # Install SDL3 dependencies -sudo dnf install SDL3-devel +sudo dnf install SDL3-devel SDL3_image-devel # Install additional dependencies sudo dnf install mesa-libGL-devel mesa-libGLU-devel alsa-lib-devel diff --git a/flatpak/com.fbraz3.GeneralsX.yml b/flatpak/com.fbraz3.GeneralsX.yml index c8eed147685..5a9b027eed1 100644 --- a/flatpak/com.fbraz3.GeneralsX.yml +++ b/flatpak/com.fbraz3.GeneralsX.yml @@ -78,9 +78,9 @@ modules: - install -d /app/lib - cp -a /run/build/generalsx/dxvk-src/lib/libdxvk_d3d8.so* /app/lib/ - cp -a /run/build/generalsx/dxvk-src/lib/libdxvk_d3d9.so* /app/lib/ - - cp -a build-flatpak/_deps/sdl3-build/libSDL3.so* /app/lib/ - - cp -a build-flatpak/_deps/sdl3_image-build/libSDL3_image.so* /app/lib/ - - cp -a build-flatpak/_deps/openal_soft-build/libopenal.so* /app/lib/ + - if [ -d build-flatpak/_deps/sdl3-build ]; then cp -a build-flatpak/_deps/sdl3-build/libSDL3.so* /app/lib/; fi + - if [ -d build-flatpak/_deps/sdl3_image-build ]; then cp -a build-flatpak/_deps/sdl3_image-build/libSDL3_image.so* /app/lib/; fi + - if [ -d build-flatpak/_deps/openal_soft-build ]; then cp -a build-flatpak/_deps/openal_soft-build/libopenal.so* /app/lib/; fi - find build-flatpak -name "libgamespy.so*" -type f -exec cp -a {} /app/lib/ \; # SagePatch (optional QoL, gated by RTS_BUILD_OPTION_SAGE_PATCH at build). - if [ -f build-flatpak/Patches/SagePatch/libsage_patch.so ]; then cp -a build-flatpak/Patches/SagePatch/libsage_patch.so /app/lib/; fi diff --git a/flatpak/com.fbraz3.GeneralsXZH.yml b/flatpak/com.fbraz3.GeneralsXZH.yml index 0c058a81d32..e1dca4ef25f 100644 --- a/flatpak/com.fbraz3.GeneralsXZH.yml +++ b/flatpak/com.fbraz3.GeneralsXZH.yml @@ -78,9 +78,9 @@ modules: - install -d /app/lib - cp -a /run/build/generalsxzh/dxvk-src/lib/libdxvk_d3d8.so* /app/lib/ - cp -a /run/build/generalsxzh/dxvk-src/lib/libdxvk_d3d9.so* /app/lib/ - - cp -a build-flatpak/_deps/sdl3-build/libSDL3.so* /app/lib/ - - cp -a build-flatpak/_deps/sdl3_image-build/libSDL3_image.so* /app/lib/ - - cp -a build-flatpak/_deps/openal_soft-build/libopenal.so* /app/lib/ + - if [ -d build-flatpak/_deps/sdl3-build ]; then cp -a build-flatpak/_deps/sdl3-build/libSDL3.so* /app/lib/; fi + - if [ -d build-flatpak/_deps/sdl3_image-build ]; then cp -a build-flatpak/_deps/sdl3_image-build/libSDL3_image.so* /app/lib/; fi + - if [ -d build-flatpak/_deps/openal_soft-build ]; then cp -a build-flatpak/_deps/openal_soft-build/libopenal.so* /app/lib/; fi - find build-flatpak -name "libgamespy.so*" -type f -exec cp -a {} /app/lib/ \; # SagePatch (optional QoL, gated by RTS_BUILD_OPTION_SAGE_PATCH at build). # Only present when the option is ON; -f guard keeps the manifest robust. diff --git a/scripts/build/linux/deploy-linux-zh.sh b/scripts/build/linux/deploy-linux-zh.sh index 6addec904cb..20f14aaa64d 100755 --- a/scripts/build/linux/deploy-linux-zh.sh +++ b/scripts/build/linux/deploy-linux-zh.sh @@ -56,25 +56,16 @@ if [[ ! -d "${DXVK_LIB_DIR}" ]]; then exit 1 fi -# Check if SDL3 libraries exist +# Check if SDL3 libraries exist (optional if using system SDL3) if [[ ! -d "${SDL3_LIB_DIR}" ]]; then - echo "ERROR: SDL3 libraries not found at ${SDL3_LIB_DIR}" - echo "Build first: ./scripts/build/linux/docker-build-linux-zh.sh linux64-deploy" - exit 1 + echo "INFO: SDL3 build directory not found, assuming system SDL3 is used" fi if [[ ! -d "${SDL3_IMAGE_LIB_DIR}" ]]; then - echo "ERROR: SDL3_image libraries not found at ${SDL3_IMAGE_LIB_DIR}" - echo "Build first: ./scripts/build/linux/docker-build-linux-zh.sh linux64-deploy" - exit 1 + echo "INFO: SDL3_image build directory not found, assuming system SDL3_image is used" fi -# Check if GameSpy library exists -if [[ ! -f "${GAMESPY_LIB}" ]]; then - echo "ERROR: GameSpy library not found at ${GAMESPY_LIB}" - echo "Build first: ./scripts/build/linux/docker-build-linux-zh.sh linux64-deploy" - exit 1 -fi +# GameSpy check removed (it is static and built into the binary) # Create runtime directory if needed mkdir -p "${RUNTIME_DIR}" @@ -90,13 +81,20 @@ cp -v "${DXVK_LIB_DIR}"/libdxvk_d3d8.so* "${RUNTIME_DIR}/" cp -v "${DXVK_LIB_DIR}"/libdxvk_d3d9.so* "${RUNTIME_DIR}/" 2>/dev/null || true # Copy SDL3 and SDL3_image libraries (for cursor loading and window management) -echo " Copying SDL3 libraries..." -cp -v "${SDL3_LIB_DIR}"/libSDL3.so* "${RUNTIME_DIR}/" -cp -v "${SDL3_IMAGE_LIB_DIR}"/libSDL3_image.so* "${RUNTIME_DIR}/" +if compgen -G "${SDL3_LIB_DIR}/libSDL3.so*" > /dev/null; then + echo " Copying SDL3 libraries..." + cp -v "${SDL3_LIB_DIR}"/libSDL3.so* "${RUNTIME_DIR}/" +fi +if compgen -G "${SDL3_IMAGE_LIB_DIR}/libSDL3_image.so*" > /dev/null; then + echo " Copying SDL3_image libraries..." + cp -v "${SDL3_IMAGE_LIB_DIR}"/libSDL3_image.so* "${RUNTIME_DIR}/" +fi -# Copy GameSpy library (for online multiplayer) -echo " Copying GameSpy library..." -cp -v "${GAMESPY_LIB}" "${RUNTIME_DIR}/" +# Copy GameSpy library (only if built as shared) +if [[ -f "${GAMESPY_LIB}" ]]; then + echo " Copying GameSpy library..." + cp -v "${GAMESPY_LIB}" "${RUNTIME_DIR}/" +fi copy_ldd_deps() { local root="$1" @@ -125,20 +123,19 @@ copy_ldd_deps() { } # GeneralsX @build GitHubCopilot 17/05/2026 Deploy FFmpeg runtime libs transitively so runtime does not depend on host SONAME layout. +# GeneralsX @tweak Antigravity 09/07/2026 Support multiple host architectures and paths (Fedora/Red Hat, Arch, Debian/Ubuntu) echo " Copying FFmpeg runtime libraries..." shopt -s nullglob -ffmpeg_roots=( - "${FFMPEG_LIB_DIR}"/libavcodec.so* - "${FFMPEG_LIB_DIR}"/libavformat.so* - "${FFMPEG_LIB_DIR}"/libavutil.so* - "${FFMPEG_LIB_DIR}"/libswresample.so* - "${FFMPEG_LIB_DIR}"/libswscale.so* - "${FFMPEG_DEP_LIB_DIR}"/libavcodec.so* - "${FFMPEG_DEP_LIB_DIR}"/libavformat.so* - "${FFMPEG_DEP_LIB_DIR}"/libavutil.so* - "${FFMPEG_DEP_LIB_DIR}"/libswresample.so* - "${FFMPEG_DEP_LIB_DIR}"/libswscale.so* -) +ffmpeg_roots=() +for dir in "${FFMPEG_LIB_DIR}" "${FFMPEG_DEP_LIB_DIR}" "/usr/lib64" "/lib64" "/usr/lib" "/lib"; do + ffmpeg_roots+=( + "${dir}"/libavcodec.so* + "${dir}"/libavformat.so* + "${dir}"/libavutil.so* + "${dir}"/libswresample.so* + "${dir}"/libswscale.so* + ) +done shopt -u nullglob for ffmpeg_root in "${ffmpeg_roots[@]}"; do cp -a "${ffmpeg_root}" "${RUNTIME_DIR}/" 2>/dev/null || true diff --git a/scripts/build/linux/deploy-linux.sh b/scripts/build/linux/deploy-linux.sh index 9f1ad0661f5..2837678391b 100755 --- a/scripts/build/linux/deploy-linux.sh +++ b/scripts/build/linux/deploy-linux.sh @@ -109,20 +109,19 @@ copy_ldd_deps() { } # GeneralsX @build GitHubCopilot 17/05/2026 Deploy FFmpeg runtime libs transitively so runtime does not depend on host SONAME layout. +# GeneralsX @tweak Antigravity 09/07/2026 Support multiple host architectures and paths (Fedora/Red Hat, Arch, Debian/Ubuntu) echo " Copying FFmpeg runtime libraries..." shopt -s nullglob -ffmpeg_roots=( - "${FFMPEG_LIB_DIR}"/libavcodec.so* - "${FFMPEG_LIB_DIR}"/libavformat.so* - "${FFMPEG_LIB_DIR}"/libavutil.so* - "${FFMPEG_LIB_DIR}"/libswresample.so* - "${FFMPEG_LIB_DIR}"/libswscale.so* - "${FFMPEG_DEP_LIB_DIR}"/libavcodec.so* - "${FFMPEG_DEP_LIB_DIR}"/libavformat.so* - "${FFMPEG_DEP_LIB_DIR}"/libavutil.so* - "${FFMPEG_DEP_LIB_DIR}"/libswresample.so* - "${FFMPEG_DEP_LIB_DIR}"/libswscale.so* -) +ffmpeg_roots=() +for dir in "${FFMPEG_LIB_DIR}" "${FFMPEG_DEP_LIB_DIR}" "/usr/lib64" "/lib64" "/usr/lib" "/lib"; do + ffmpeg_roots+=( + "${dir}"/libavcodec.so* + "${dir}"/libavformat.so* + "${dir}"/libavutil.so* + "${dir}"/libswresample.so* + "${dir}"/libswscale.so* + ) +done shopt -u nullglob for ffmpeg_root in "${ffmpeg_roots[@]}"; do cp -a "${ffmpeg_root}" "${RUNTIME_DIR}/" 2>/dev/null || true