Skip to content

Commit 54f65e2

Browse files
committed
fix: build AWS SDK statically to avoid macOS shared-link failure
1 parent 69b9a87 commit 54f65e2

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

cmake/aws-sdk-cpp.cmake

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,22 @@ FetchContent_Declare(aws-sdk-cpp
2323
OVERRIDE_FIND_PACKAGE
2424
)
2525

26-
FetchContent_MakeAvailable(aws-sdk-cpp)
26+
# Always build the AWS SDK as static archives, even when our own library is
27+
# being built shared (LD_BUILD_SHARED_LIBS=ON). Building aws-sdk-cpp as
28+
# BUILD_SHARED_LIBS=ON produces dylibs on macOS whose dynamodb component
29+
# fails to find AWS Core symbols at link time (the AWS SDK's visibility
30+
# configuration doesn't export them consistently across its FetchContent
31+
# build). Linking aws-sdk-cpp statically into our shared wrapper sidesteps
32+
# the issue and matches the redis pattern of pinning dep build shape via
33+
# a scoped variable rather than overwriting the global BUILD_SHARED_LIBS.
34+
#
35+
# Using a function for scope: `set(BUILD_SHARED_LIBS OFF)` inside the
36+
# function shadows any cached/parent value during FetchContent_MakeAvailable
37+
# without persisting after the call, so user `-D LD_BUILD_SHARED_LIBS=ON`
38+
# for the rest of the project remains untouched.
39+
function(_ld_fetch_aws_sdk_cpp_static)
40+
set(BUILD_SHARED_LIBS OFF)
41+
FetchContent_MakeAvailable(aws-sdk-cpp)
42+
endfunction()
43+
44+
_ld_fetch_aws_sdk_cpp_static()

0 commit comments

Comments
 (0)