diff --git a/.evergreen/build_example_projects.sh b/.evergreen/build_example_projects.sh index 33bf5fbf4e..d75363a09e 100755 --- a/.evergreen/build_example_projects.sh +++ b/.evergreen/build_example_projects.sh @@ -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 diff --git a/.ycm_extra_conf.py b/.ycm_extra_conf.py index 708d7c088a..71f2b56a72 100644 --- a/.ycm_extra_conf.py +++ b/.ycm_extra_conf.py @@ -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', diff --git a/CHANGELOG.md b/CHANGELOG.md index 942ad21f71..91fe4fcaa8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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.15 to support the FetchContent module and for consistency with the C Driver. +- 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. diff --git a/CMakeLists.txt b/CMakeLists.txt index d74ba2d64f..d160c8abbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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.15) if(POLICY CMP0025) cmake_policy(SET CMP0025 NEW) @@ -458,4 +458,3 @@ endif () if (CMAKE_GENERATOR_TOOLSET) message (STATUS "\tinstance: ${CMAKE_GENERATOR_TOOLSET}") endif () - diff --git a/cmake/BsoncxxUtil.cmake b/cmake/BsoncxxUtil.cmake index 5d1f077b37..ec2b596d5d 100644 --- a/cmake/BsoncxxUtil.cmake +++ b/cmake/BsoncxxUtil.cmake @@ -29,21 +29,15 @@ 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 - $ - $ + $ + $ ) elseif(BSONCXX_POLY_USE_BOOST) find_package(Boost 1.56.0 REQUIRED) - if(CMAKE_VERSION VERSION_LESS 3.15.0) - target_include_directories(${TARGET} PUBLIC ${Boost_INCLUDE_DIRS}) - else() - target_link_libraries(${TARGET} PUBLIC Boost::boost) - endif() + target_link_libraries(${TARGET} PUBLIC Boost::boost) endif() target_link_libraries(${TARGET} PRIVATE ${libbson_target}) diff --git a/cmake/make_dist/MakeDist.cmake b/cmake/make_dist/MakeDist.cmake index 53b61c5b08..68275d1262 100644 --- a/cmake/make_dist/MakeDist.cmake +++ b/cmake/make_dist/MakeDist.cmake @@ -17,9 +17,7 @@ include (MakeDistFiles) function (MAKE_DIST PACKAGE_PREFIX MONGOCXX_SOURCE_DIR BUILD_SOURCE_DIR) set (CMAKE_COMMAND_TMP "") - if (${CMAKE_VERSION} VERSION_GREATER 3.1) - set (CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env) - endif () + set (CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env) # -- Remove any existing packaging directory. diff --git a/cmake/make_dist/MakeDistCheck.cmake b/cmake/make_dist/MakeDistCheck.cmake index 5bf2581d4d..d3647d2585 100644 --- a/cmake/make_dist/MakeDistCheck.cmake +++ b/cmake/make_dist/MakeDistCheck.cmake @@ -17,9 +17,7 @@ function (RUN_DIST_CHECK PACKAGE_PREFIX EXT) endif () set (MY_CMAKE_COMMAND "") - if (${CMAKE_VERSION} VERSION_GREATER 3.1) - set (MY_CMAKE_COMMAND ${CMAKE_COMMAND} -E env) - endif () + set (MY_CMAKE_COMMAND ${CMAKE_COMMAND} -E env) find_program (MAKE_COMMAND NAMES make gmake) if (${MAKE_COMMAND} STREQUAL "MAKE_COMMAND-NOTFOUND") diff --git a/cmake/make_dist/MakeDistFiles.cmake b/cmake/make_dist/MakeDistFiles.cmake index 24c1925353..6841933ecc 100644 --- a/cmake/make_dist/MakeDistFiles.cmake +++ b/cmake/make_dist/MakeDistFiles.cmake @@ -1,8 +1,3 @@ - -if (${CMAKE_VERSION} VERSION_LESS 3.3) - include (CMakeParseArguments) -endif () - function (SET_LOCAL_DIST output) set (dist_files "") foreach (file ${ARGN}) diff --git a/debian/patches/0002_skip_mnmlstc_extra_step.patch b/debian/patches/0002_skip_mnmlstc_extra_step.patch deleted file mode 100644 index 3bb2750baa..0000000000 --- a/debian/patches/0002_skip_mnmlstc_extra_step.patch +++ /dev/null @@ -1,21 +0,0 @@ -Description: Remove an extra step in the MNMLSTC external project build; this is not used for official Debian packages and the step needs to be removed for users customizing the Debian package to build with MNMLSTC rather than Boost. -Author: Roberto C. Sánchez -Forwarded: not-needed ---- a/src/bsoncxx/third_party/CMakeLists.txt -+++ b/src/bsoncxx/third_party/CMakeLists.txt -@@ -29,15 +29,6 @@ - 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=. - ) - -- 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 = @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 diff --git a/src/bsoncxx/config/libbsoncxx.pc.in b/src/bsoncxx/config/libbsoncxx.pc.in index 9d94bf31ef..760ab2ca9e 100644 --- a/src/bsoncxx/config/libbsoncxx.pc.in +++ b/src/bsoncxx/config/libbsoncxx.pc.in @@ -20,5 +20,5 @@ Name: libbsoncxx Description: The MongoDB C++11 BSON Library URL: http://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 diff --git a/src/bsoncxx/third_party/CMakeLists.txt b/src/bsoncxx/third_party/CMakeLists.txt index c5156aa941..61856adb74 100644 --- a/src/bsoncxx/third_party/CMakeLists.txt +++ b/src/bsoncxx/third_party/CMakeLists.txt @@ -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