Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bson library #7324

Merged
merged 4 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
add_subdirectory(realm)
add_subdirectory(external/IntelRDFPMathLib20U2)
add_subdirectory(external/bson EXCLUDE_FROM_ALL)

if (REALM_ENABLE_GEOSPATIAL)
add_subdirectory(external/s2)
Expand Down
55 changes: 55 additions & 0 deletions src/external/bson/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
include(CheckFunctionExists)
include(CheckStructHasMember)

set(BSON_SRC
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set(BSON_SRC
include(CheckFunctionExists)
include(CheckStructHasMember)
set(BSON_SRC

I think it's better if we include CMake modules where we need them - it's not harmful if several different listfiles in the same project include the same modules.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

bcon.c
bson-clock.c
bson-decimal128.c
bson-error.c
bson-iso8601.c
bson-iter.c
bson-json.c
bson-keys.c
bson-memory.c
bson-oid.c
bson-reader.c
bson-string.c
bson-timegm.c
bson-utf8.c
bson-value.c
bson-version-functions.c
bson-writer.c
bson.c
common-b64.c
../jsonsl/jsonsl.c
)

if(WIN32)
set(BSON_OS 2)
else()
set(BSON_OS 1)
endif()

check_symbol_exists (snprintf stdio.h BSON_HAVE_SNPRINTF)
CHECK_STRUCT_HAS_MEMBER ("struct timespec" tv_sec time.h BSON_HAVE_TIMESPEC)
check_symbol_exists (gmtime_r time.h BSON_HAVE_GMTIME_R)
check_function_exists (rand_r BSON_HAVE_RAND_R)
check_include_file (strings.h BSON_HAVE_STRINGS_H)
check_symbol_exists (strlcpy string.h BSON_HAVE_STRLCPY)
check_include_file (stdbool.h BSON_HAVE_STDBOOL_H)
check_symbol_exists (clock_gettime time.h BSON_HAVE_CLOCK_GETTIME)
check_symbol_exists (strnlen string.h BSON_HAVE_STRNLEN)

configure_file (
"${PROJECT_SOURCE_DIR}/src/external/bson/bson-config.h.in"
"${PROJECT_BINARY_DIR}/src/external/bson/bson-config.h"
)

add_library(Bson STATIC ${BSON_SRC})
add_library(Realm::Bson ALIAS Bson)
target_compile_definitions(Bson PRIVATE _GNU_SOURCE _XOPEN_SOURCE=700 BSON_COMPILATION)
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
target_compile_definitions(Bson PRIVATE _DARWIN_C_SOURCE)
endif()
target_include_directories(Bson PUBLIC .. ${PROJECT_BINARY_DIR}/src/external)
target_compile_definitions(Bson INTERFACE BSON_STATIC)
1 change: 1 addition & 0 deletions src/external/bson/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This code is copied from git@github.com:mongodb/mongo-c-driver.git version 1.25.0.
Loading
Loading