Skip to content

Commit a07dfec

Browse files
committed
CDRIVER-4233 fix implicit decl of arc4random and strlcpy on macOS (#910)
1 parent 1d0d298 commit a07dfec

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/libbson/CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,17 @@ set (CPACK_PACKAGE_VERSION_MAJOR ${BSON_MAJOR_VERSION})
3434
set (CPACK_PACKAGE_VERSION_MINOR ${BSON_MINOR_VERSION})
3535

3636
# Enable X/Open 7.0 / POSIX 2008
37-
add_compile_options($<$<NOT:$<PLATFORM_ID:Windows>>:-D_XOPEN_SOURCE=700>)
37+
if (NOT WIN32)
38+
add_compile_options(-D_XOPEN_SOURCE=700)
39+
# Add to CMAKE_REQUIRED_DEFINITIONS to apply to CHECK_SYMBOL_EXISTS.
40+
set (CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_XOPEN_SOURCE=700")
41+
endif ()
42+
# Enable macOS extensions for strlcpy and arc4random.
43+
if (APPLE)
44+
add_compile_options(-D_DARWIN_C_SOURCE=1)
45+
# Add to CMAKE_REQUIRED_DEFINITIONS to apply to CHECK_SYMBOL_EXISTS.
46+
set (CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_DARWIN_C_SOURCE=1")
47+
endif ()
3848

3949
include (CPack)
4050
TEST_BIG_ENDIAN (BSON_BIG_ENDIAN)

0 commit comments

Comments
 (0)