Skip to content

Commit 1423c22

Browse files
committed
MONGOCRYPT-309 do not add libm on macOS (#738)
1 parent 8c69e5d commit 1423c22

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/libbson/CMakeLists.txt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,17 @@ if (RT_LIBRARY)
252252
target_link_libraries (bson_shared PRIVATE ${RT_LIBRARY})
253253
endif ()
254254

255-
find_library (M_LIBRARY m)
256-
if (M_LIBRARY)
257-
target_link_libraries (bson_shared PRIVATE ${M_LIBRARY})
258-
set (BSON_LIBRARIES ${BSON_LIBRARIES} ${M_LIBRARY})
255+
# On macOS Big Sur, libm resolves to the SDK's tbd file, like:
256+
# /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libm.tbd
257+
# Not all consumers can easily link to a tbd file (notably golang will reject a tbd suffix by default)
258+
# macOS includes libm as part of libSystem (along with libc).
259+
# It does not need to be explicitly linked.
260+
if (!APPLE)
261+
find_library (M_LIBRARY m)
262+
if (M_LIBRARY)
263+
target_link_libraries (bson_shared PRIVATE ${M_LIBRARY})
264+
set (BSON_LIBRARIES ${BSON_LIBRARIES} ${M_LIBRARY})
265+
endif ()
259266
endif ()
260267

261268
set (THREADS_PREFER_PTHREAD_FLAG 1)

0 commit comments

Comments
 (0)