Skip to content

Commit baed7c9

Browse files
committed
switch back to static linking
1 parent 3925a47 commit baed7c9

2 files changed

Lines changed: 27 additions & 7 deletions

File tree

cmake/sdl3.cmake

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,19 @@ if(NOT SDL3_FOUND OR NOT SDL3_image_FOUND)
2020
)
2121

2222
# Official SDL configuration for a unified build tree
23-
set(SDL_SHARED ON CACHE BOOL "" FORCE)
24-
set(SDL_STATIC OFF CACHE BOOL "" FORCE)
23+
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
24+
set(SDL_SHARED OFF CACHE BOOL "" FORCE)
25+
set(SDL_STATIC ON CACHE BOOL "" FORCE)
2526
set(SDLIMAGE_VENDORED OFF CACHE BOOL "" FORCE)
26-
set(SDLIMAGE_ZLIB ON CACHE BOOL "" FORCE)
27-
set(SDLIMAGE_PNG ON CACHE BOOL "" FORCE)
28-
set(SDLIMAGE_APNG ON CACHE BOOL "" FORCE)
27+
set(SDLIMAGE_SHARED OFF CACHE BOOL "" FORCE)
28+
set(SDLIMAGE_STATIC ON CACHE BOOL "" FORCE)
29+
set(SDLIMAGE_ZLIB OFF CACHE BOOL "" FORCE)
30+
set(SDLIMAGE_PNG OFF CACHE BOOL "" FORCE)
31+
set(SDLIMAGE_APNG OFF CACHE BOOL "" FORCE)
2932

30-
# Making them available in order ensures SDL3_image can see the SDL3 targets
31-
FetchContent_MakeAvailable(SDL3 SDL3_image)
33+
# Populate SDL3 and SDL3_image
34+
FetchContent_MakeAvailable(SDL3)
35+
FetchContent_MakeAvailable(SDL3_image)
3236
endif()
3337

3438
# Uniform aliases to ensure linking works across both discovery methods
@@ -38,3 +42,15 @@ endif()
3842
if(TARGET SDL3::SDL3-static AND NOT TARGET SDL3::SDL3)
3943
add_library(SDL3::SDL3 ALIAS SDL3::SDL3-static)
4044
endif()
45+
46+
# Centralized dependency restoration for SDL3 static builds.
47+
# We apply these directly to the SDL3-static target so it correctly handles its own needs.
48+
if(TARGET SDL3-static)
49+
target_link_libraries(SDL3-static INTERFACE
50+
ws2_32.lib
51+
winmm.lib
52+
imm32.lib
53+
version.lib
54+
setupapi.lib
55+
)
56+
endif()

triplets/x86-windows.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ set(VCPKG_TARGET_ARCHITECTURE x86)
33
set(VCPKG_CRT_LINKAGE dynamic)
44
set(VCPKG_LIBRARY_LINKAGE dynamic)
55

6+
if(PORT MATCHES "sdl3")
7+
set(VCPKG_LIBRARY_LINKAGE static)
8+
endif()
9+
610
# Exclude compiler version from ABI hash so that weekly GitHub runner image
711
# updates don't invalidate the binary cache. Minor MSVC version bumps do not
812
# cause ABI incompatibilities for this project.

0 commit comments

Comments
 (0)