Skip to content

Commit 20cada3

Browse files
authored
MONGOCRYPT-309 do not add libm on macOS (#738)
1 parent 903b55c commit 20cada3

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
@@ -261,10 +261,17 @@ if (RT_LIBRARY)
261261
target_link_libraries (bson_shared PRIVATE ${RT_LIBRARY})
262262
endif ()
263263

264-
find_library (M_LIBRARY m)
265-
if (M_LIBRARY)
266-
target_link_libraries (bson_shared PRIVATE ${M_LIBRARY})
267-
set (BSON_LIBRARIES ${BSON_LIBRARIES} ${M_LIBRARY})
264+
# On macOS Big Sur, libm resolves to the SDK's tbd file, like:
265+
# /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libm.tbd
266+
# Not all consumers can easily link to a tbd file (notably golang will reject a tbd suffix by default)
267+
# macOS includes libm as part of libSystem (along with libc).
268+
# It does not need to be explicitly linked.
269+
if (!APPLE)
270+
find_library (M_LIBRARY m)
271+
if (M_LIBRARY)
272+
target_link_libraries (bson_shared PRIVATE ${M_LIBRARY})
273+
set (BSON_LIBRARIES ${BSON_LIBRARIES} ${M_LIBRARY})
274+
endif ()
268275
endif ()
269276

270277
set (THREADS_PREFER_PTHREAD_FLAG 1)

0 commit comments

Comments
 (0)