Skip to content

Commit 4e6ef00

Browse files
committed
fix(cmake): replace obsolete -s with -Wl,-x on Apple linker
1 parent 0181229 commit 4e6ef00

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

cmake/DefinePlatformSpecific.cmake

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,14 @@ else(MSVC)
4949
# Other compilers then MSVC don't have a static STATIC_POSTFIX at the moment
5050
set(STATIC_POSTFIX "" CACHE STRING "Set static library postfix" FORCE)
5151

52-
# Strip debug symbols from Release binaries (reduces binary size significantly)
53-
# On Windows, debug symbols go to separate .pdb files, so this is not needed
54-
# NOTE: CMAKE_BUILD_TYPE must be set to Release for this to take effect
55-
# e.g., cmake -B build -DCMAKE_BUILD_TYPE=Release
56-
add_link_options($<$<CONFIG:Release>:-s>)
52+
# Strip symbols from Release binaries. Apple's ld deprecated `-s`;
53+
# `-Wl,-x` is its documented replacement and keeps dynamic exports.
54+
# MSVC has no equivalent — symbols live in the .pdb, not the binary.
55+
if(APPLE)
56+
add_link_options($<$<CONFIG:Release>:-Wl,-x>)
57+
else()
58+
add_link_options($<$<CONFIG:Release>:-s>)
59+
endif()
5760

5861
# Dead-code stripping for macOS: Apple's -dead_strip works on Mach-O
5962
# atoms without needing -ffunction-sections/-fdata-sections.

0 commit comments

Comments
 (0)