Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
3 changes: 3 additions & 0 deletions .evergreen/build_example_projects.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@ for project in bsoncxx mongocxx; do
cd $project

if ! ( cd cmake/$DIR && ./build.sh >|output.txt 2>&1); then
echo "Example $project/cmake/$DIR failed" 1>&2
cat cmake/$DIR/output.txt 1>&2
exit 1
fi

if ! ( cd cmake-deprecated/$DIR && ./build.sh >|output.txt 2>&1); then
echo "Example $project/cmake-deprecated/$DIR failed" 1>&2
cat cmake-deprecated/$DIR/output.txt 1>&2
exit 1
fi

if [[ ! ( "$OSTYPE" =~ cygwin ) ]]; then
if ! ( cd pkg-config/$DIR && ./build.sh >|output.txt 2>&1); then
echo "Example $project/pkg-config/$DIR failed" 1>&2
cat pkg-config/$DIR/output.txt 1>&2
exit 1
fi
Expand Down
1 change: 0 additions & 1 deletion .ycm_extra_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
'-x', 'c++',
'-Isrc',
'-Ibuild/src',
'-Ibuild/src/bsoncxx/third_party/EP_mnmlstc_core-prefix/src/EP_mnmlstc_core/include',
'-Isrc/third_party/catch/include',
'-I/usr/local/include/libmongoc-1.0',
'-I/usr/local/include/libbson-1.0',
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
- Do not build tests as part of `all` target. Configure with `BUILD_TESTING=ON` to build tests.
- Bump minimum required CMake version to 3.11 to support the FetchContent module.
- Improve handling of downloaded (non-system) mnmlstc/core as the polyfill library.
- Use `FetchContent` instead of `ExternalProject` to download and build the library.
- Do not patch include directives in mnmlstc/core headers.

### Fixed
- Explicitly document that throwing an exception from an APM callback is undefined behavior.
- Do not prematurely install mnmlstc/core headers during the CMake build step.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)

if(POLICY CMP0025)
cmake_policy(SET CMP0025 NEW)
Expand Down Expand Up @@ -458,4 +458,3 @@ endif ()
if (CMAKE_GENERATOR_TOOLSET)
message (STATUS "\tinstance: ${CMAKE_GENERATOR_TOOLSET}")
endif ()

6 changes: 2 additions & 4 deletions cmake/BsoncxxUtil.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ function(bsoncxx_add_library TARGET OUTPUT_NAME LINK_TYPE)
endif()

if(BSONCXX_POLY_USE_MNMLSTC AND NOT BSONCXX_POLY_USE_SYSTEM_MNMLSTC)
add_dependencies(${TARGET} EP_mnmlstc_core)
ExternalProject_Get_Property(EP_mnmlstc_core source_dir)
target_include_directories(
${TARGET}
PUBLIC
$<BUILD_INTERFACE:${source_dir}/include>
$<BUILD_INTERFACE:${CMAKE_INSTALL_PREFIX}/${BSONCXX_HEADER_INSTALL_DIR}>
$<BUILD_INTERFACE:${CORE_INCLUDE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/bsoncxx/v_noabi/bsoncxx/third_party/mnmlstc>
)
elseif(BSONCXX_POLY_USE_BOOST)
find_package(Boost 1.56.0 REQUIRED)
Expand Down
21 changes: 0 additions & 21 deletions debian/patches/0002_skip_mnmlstc_extra_step.patch

This file was deleted.

1 change: 0 additions & 1 deletion debian/patches/series
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
0001_remove_embedded_js.patch
0002_skip_mnmlstc_extra_step.patch
5 changes: 0 additions & 5 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,10 @@ ifneq (,$(filter pkg.mongo-cxx-driver.mnmlstc,$(DEB_BUILD_PROFILES)))
mv $(CURDIR)/debian/tmp-mnmlstc/usr/include/bsoncxx/v_noabi/bsoncxx/third_party \
$(CURDIR)/debian/tmp/usr/include/bsoncxx/v_noabi/bsoncxx/
rm -rf $(CURDIR)/debian/tmp-mnmlstc
# Fix MNMLSTC headers; handle the CMake external project step patched out
# by debian/patches/0002_skip_mnmlstc_extra_step.patch
( cd $(CURDIR)/debian/tmp/usr/include/bsoncxx/v_noabi/bsoncxx/third_party/mnmlstc; \
find . -type f | xargs perl -pi -e "s|#include <core|#include <bsoncxx/third_party/mnmlstc/core|g" )
endif

override_dh_auto_test:
# do nothing

override_dh_missing:
dh_missing --fail-missing

13 changes: 1 addition & 12 deletions docs/content/mongocxx-v3/installation/linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,7 @@ cmake .. \

### Step 4: Build and install the driver

If you are using the default MNMLSTC polyfill and are installing to a
directory requiring root permissions, you should install the polyfill with
`sudo` before building the rest of mongocxx so you don't have to run
the entire build with `sudo`:

```sh
# Only for MNMLSTC polyfill
sudo cmake --build . --target EP_mnmlstc_core
```

Once MNMLSTC is installed, or if you are using a different polyfill,
build and install the driver:
Build and install the driver:

```sh
cmake --build .
Expand Down
13 changes: 1 addition & 12 deletions docs/content/mongocxx-v3/installation/macos.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,7 @@ cmake .. \

### Step 4: Build and install the driver

If you are using the default MNMLSTC polyfill and are installing to a
directory requiring root permissions, you should install the polyfill with
`sudo` before building the rest of mongocxx so you don't have to run
the entire build with `sudo`:

```sh
# Only for MNMLSTC polyfill
sudo cmake --build . --target EP_mnmlstc_core
```

Once MNMLSTC is installed, or if you are using a different polyfill,
build and install the driver:
Build and install the driver:

```sh
cmake --build .
Expand Down
16 changes: 0 additions & 16 deletions generate_uninstall/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ if (WIN32)
"${CMAKE_INSTALL_PREFIX}"
)
install (CODE "
if (EXISTS \${CMAKE_BINARY_DIR}/src/bsoncxx/third_party/EP_mnmlstc_core-prefix/src/EP_mnmlstc_core-build/install_manifest.txt)
file (
STRINGS
\${CMAKE_BINARY_DIR}/src/bsoncxx/third_party/EP_mnmlstc_core-prefix/src/EP_mnmlstc_core-build/install_manifest.txt
ADDL_MANIFEST_FILES
)
list (APPEND CMAKE_INSTALL_MANIFEST_FILES \${ADDL_MANIFEST_FILES})
endif ()
string(REPLACE \";\" \"\\n\" MONGOCXX_INSTALL_MANIFEST_CONTENT
\"\${CMAKE_INSTALL_MANIFEST_FILES}\")
string(REPLACE \"/\" \"\\\\\" MONGOCXX_INSTALL_MANIFEST_CONTENT_WIN32
Expand Down Expand Up @@ -59,14 +51,6 @@ if (WIN32)
)
else ()
install (CODE "
if (EXISTS \${CMAKE_BINARY_DIR}/src/bsoncxx/third_party/EP_mnmlstc_core-prefix/src/EP_mnmlstc_core-build/install_manifest.txt)
file (
STRINGS
\${CMAKE_BINARY_DIR}/src/bsoncxx/third_party/EP_mnmlstc_core-prefix/src/EP_mnmlstc_core-build/install_manifest.txt
ADDL_MANIFEST_FILES
)
list (APPEND CMAKE_INSTALL_MANIFEST_FILES \${ADDL_MANIFEST_FILES})
endif ()
string(REPLACE \";\" \"\\n\" MONGOCXX_INSTALL_MANIFEST_CONTENT
\"\${CMAKE_INSTALL_MANIFEST_FILES}\")
file(WRITE \"mongocxx_install_manifest.txt\"
Expand Down
18 changes: 18 additions & 0 deletions src/bsoncxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,24 @@ message ("bsoncxx version: ${BSONCXX_VERSION}")
set(BSONCXX_INLINE_NAMESPACE "v${BSONCXX_ABI_VERSION}")
set(BSONCXX_HEADER_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/bsoncxx/${BSONCXX_INLINE_NAMESPACE}" CACHE INTERNAL "")

if (BSONCXX_POLY_USE_MNMLSTC AND NOT BSONCXX_POLY_USE_SYSTEM_MNMLSTC)
# For deprecated CMake package config files.
set(BSONCXX_POLY_MNMLSTC_DEPRECATED_INCLUDE_DIRS
"list(PREPEND LIBBSONCXX_INCLUDE_DIRS \"\${PACKAGE_PREFIX_DIR}/include/bsoncxx/v_noabi/bsoncxx/third_party/mnmlstc\")"
)
set(BSONCXX_POLY_MNMLSTC_DEPRECATED_STATIC_INCLUDE_DIRS
"list(PREPEND LIBBSONCXX_STATIC_INCLUDE_DIRS \"\${PACKAGE_PREFIX_DIR}/include/bsoncxx/v_noabi/bsoncxx/third_party/mnmlstc\")"
)

# For pkg-config files. Trailing space to separate cflags.
set(BSONCXX_POLY_MNMLSTC_PKGCONFIG_INCLUDE_DIRS
"-I\${includedir}/bsoncxx/v_noabi/bsoncxx/third_party/mnmlstc "
)
set(BSONCXX_POLY_MNMLSTC_PKGCONFIG_STATIC_INCLUDE_DIRS
"-I\${includedir}/bsoncxx/v_noabi/bsoncxx/third_party/mnmlstc "
)
endif ()

set(LIBBSON_REQUIRED_VERSION 1.24.0)
set(LIBBSON_REQUIRED_ABI_VERSION 1.0)

Expand Down
1 change: 1 addition & 0 deletions src/bsoncxx/cmake/libbsoncxx-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ set(LIBBSONCXX_PACKAGE_VERSION @BSONCXX_VERSION@)
@PACKAGE_INIT@

set_and_check(LIBBSONCXX_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/@PACKAGE_INCLUDE_INSTALL_DIRS@")
@BSONCXX_POLY_MNMLSTC_DEPRECATED_INCLUDE_DIRS@

# We want to provide an absolute path to the library and we know the
# directory and the base name, but not the suffix, so we use CMake's
Expand Down
1 change: 1 addition & 0 deletions src/bsoncxx/cmake/libbsoncxx-static-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ find_package(libbson-static-@LIBBSON_REQUIRED_ABI_VERSION@ @LIBBSON_REQUIRED_VER
@PACKAGE_INIT@

set_and_check(LIBBSONCXX_STATIC_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/@PACKAGE_INCLUDE_INSTALL_DIRS@")
@BSONCXX_POLY_MNMLSTC_DEPRECATED_STATIC_INCLUDE_DIRS@

# We want to provide an absolute path to the library and we know the directory and the base name,
# but not the suffix, so we use CMake's find_library() to pick that up.
Expand Down
2 changes: 1 addition & 1 deletion src/bsoncxx/config/libbsoncxx-static.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ Description: The MongoDB C++11 BSON Library
URL: https://github.com/mongodb/mongo-cxx-driver
Version: @BSONCXX_VERSION@
Requires: libbson-static-@LIBBSON_REQUIRED_ABI_VERSION@ >= @LIBBSON_REQUIRED_VERSION@
Cflags: -I${includedir}/bsoncxx/@BSONCXX_INLINE_NAMESPACE@ -DBSONCXX_STATIC
Cflags: @BSONCXX_POLY_MNMLSTC_PKGCONFIG_STATIC_INCLUDE_DIRS@-I${includedir}/bsoncxx/@BSONCXX_INLINE_NAMESPACE@ -DBSONCXX_STATIC
Libs: -L${libdir} -lbsoncxx-static
2 changes: 1 addition & 1 deletion src/bsoncxx/config/libbsoncxx.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ Name: libbsoncxx
Description: The MongoDB C++11 BSON Library
URL: https://github.com/mongodb/mongo-cxx-driver
Version: @BSONCXX_VERSION@
Cflags: -I${includedir}/bsoncxx/@BSONCXX_INLINE_NAMESPACE@
Cflags: @BSONCXX_POLY_MNMLSTC_PKGCONFIG_INCLUDE_DIRS@-I${includedir}/bsoncxx/@BSONCXX_INLINE_NAMESPACE@
Libs: -L${libdir} -lbsoncxx
97 changes: 82 additions & 15 deletions src/bsoncxx/third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,97 @@
# See the License for the specific language governing permissions and
# limitations under the License.

include(ExternalProject)
include(FetchContent)

if (BSONCXX_POLY_USE_MNMLSTC AND NOT BSONCXX_POLY_USE_SYSTEM_MNMLSTC)

ExternalProject_Add(
set (core-src "${CMAKE_CURRENT_BINARY_DIR}/_deps/core-src")
set (core-subbuild "${CMAKE_CURRENT_BINARY_DIR}/_deps/core-subbuild")
set (core-build "${CMAKE_CURRENT_BINARY_DIR}/_deps/core-build")
set (core-install "${CMAKE_CURRENT_BINARY_DIR}/_deps/core-install")

FetchContent_Declare(
EP_mnmlstc_core

SOURCE_DIR "${core-src}"
SUBBUILD_DIR "${core-subbuild}"
BINARY_DIR "${core-build}"
INSTALL_DIR "${core-install}"

GIT_REPOSITORY https://github.com/mnmlstc/core
GIT_TAG v1.1.0
GIT_SHALLOW TRUE
LOG_DOWNLOAD ON
LOG_CONFIGURE ON
LOG_BUILD ON
LOG_INSTALL ON
LOG_UPDATE ON
UPDATE_COMMAND ""
CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DBUILD_TESTING=Off -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}/${BSONCXX_HEADER_INSTALL_DIR}/bsoncxx/third_party/mnmlstc -DINCLUDE_INSTALL_DIR=.

FETCHCONTENT_UPDATES_DISCONNECTED ON
)
FetchContent_GetProperties (EP_mnmlstc_core)

ExternalProject_Add_Step(
EP_mnmlstc_core
fix-includes
WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${BSONCXX_HEADER_INSTALL_DIR}/bsoncxx/third_party/mnmlstc
COMMAND find . -type f | xargs perl -pi.bak -e "s|#include <core|#include <bsoncxx/third_party/mnmlstc/core|g"
COMMAND find . -name *.bak | xargs rm
DEPENDEES install
find_package (core NO_DEFAULT_PATH PATHS "${core-install}" QUIET)

if (core_FOUND AND "$CACHE{INTERNAL_MONGOC_MNMLSTC_CORE_FOUND}")
# The mnmlstc/core library is already populated and up-to-date.
else ()
if (NOT ep_mnmlstc_core_POPULATED)
message (STATUS "Downloading mnmlstc/core...")
FetchContent_Populate (EP_mnmlstc_core)
message (STATUS "Downloading mnmlstc/core... done.")
endif ()

message (STATUS "Configuring mnmlstc/core...")
execute_process (
COMMAND
"${CMAKE_COMMAND}"
"-S" "${core-src}"
"-B" "${core-build}"
"-DCMAKE_INSTALL_PREFIX=${core-install}"
"-DBUILD_TESTING=OFF"
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
RESULT_VARIABLE retval
)
if (NOT "${retval}" STREQUAL "0")
message (FATAL_ERROR "execute_process() fatal error: ${retval}")
endif ()
message (STATUS "Configuring mnmlstc/core... done.")

message (STATUS "Building mnmlstc/core...")
execute_process (
COMMAND
"${CMAKE_COMMAND}"
--build "${core-build}"
--config "${CMAKE_BUILD_TYPE}"
RESULT_VARIABLE retval
)
if (NOT "${retval}" STREQUAL "0")
message (FATAL_ERROR "execute_process() fatal error: ${retval}")
endif ()
message (STATUS "Building mnmlstc/core... done.")

message (STATUS "Installing mnmlstc/core...")
execute_process (
COMMAND
"${CMAKE_COMMAND}"
--install "${core-build}"
--config "${CMAKE_BUILD_TYPE}"
RESULT_VARIABLE retval
)
if (NOT "${retval}" STREQUAL "0")
message (FATAL_ERROR "execute_process() fatal error: ${retval}")
endif ()
message (STATUS "Installing mnmlstc/core... done.")

find_package (core REQUIRED NO_DEFAULT_PATH PATHS "${core-install}")

# Ensure the mnmlstc/core CMake configuration is also (re)configured if the cache is fresh.
set (INTERNAL_MONGOC_MNMLSTC_CORE_FOUND TRUE CACHE INTERNAL "")
endif ()

set (CORE_INCLUDE_DIR "${CORE_INCLUDE_DIR}" PARENT_SCOPE)

install (
DIRECTORY "${core-install}/include/"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/bsoncxx/v_noabi/bsoncxx/third_party/mnmlstc"
)

endif()
Expand Down