Skip to content

Commit 1523c42

Browse files
authored
CDRIVER-4233 fix implicit decl of arc4random and strlcpy on macOS (#910)
1 parent 8159201 commit 1523c42

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
@@ -36,7 +36,17 @@ set (CPACK_PACKAGE_VERSION_MAJOR ${BSON_MAJOR_VERSION})
3636
set (CPACK_PACKAGE_VERSION_MINOR ${BSON_MINOR_VERSION})
3737

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

4151
include (CPack)
4252
TEST_BIG_ENDIAN (BSON_BIG_ENDIAN)

0 commit comments

Comments
 (0)