From 1a86c9c52b30902890d173f371ac4ecb0794fec7 Mon Sep 17 00:00:00 2001 From: fleroviux Date: Tue, 3 Oct 2023 13:04:53 +0200 Subject: [PATCH] CI: attempt to fix static linking of SDL2 --- .github/workflows/build-macOS.yml | 2 +- src/platform/sdl/CMakeLists.txt | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-macOS.yml b/.github/workflows/build-macOS.yml index 834c2dd..19b2d3c 100644 --- a/.github/workflows/build-macOS.yml +++ b/.github/workflows/build-macOS.yml @@ -17,7 +17,7 @@ jobs: run: | cmake -Bbuild \ -DCMAKE_CXX_FLAGS="-s" \ - -DSDL2_STATIC=ON \ + -DBUILD_STATIC=ON \ -DCMAKE_BUILD_TYPE=Release cd build make -j$(getconf _NPROCESSORS_ONLN) diff --git a/src/platform/sdl/CMakeLists.txt b/src/platform/sdl/CMakeLists.txt index 678d9a9..e98e9c7 100644 --- a/src/platform/sdl/CMakeLists.txt +++ b/src/platform/sdl/CMakeLists.txt @@ -19,8 +19,18 @@ set(HEADERS src/sdl2_audio_driver.hpp ) -find_package(SDL2 REQUIRED) +find_package(PkgConfig REQUIRED) + +option(BUILD_STATIC "Build a statically linked executable" OFF) + +if(BUILD_STATIC) + list(APPEND PKG_CONFIG_EXECUTABLE "--static") +endif() + +pkg_check_modules(SDL2 REQUIRED IMPORTED_TARGET sdl2) + +#find_package(SDL2 REQUIRED) add_executable(dual-sdl ${SOURCES} ${HEADERS}) target_include_directories(dual-sdl PRIVATE src) -target_link_libraries(dual-sdl PRIVATE dual SDL2::SDL2) \ No newline at end of file +target_link_libraries(dual-sdl PRIVATE dual PkgConfig::SDL2) \ No newline at end of file