diff --git a/.evergreen/scripts/check-installed-files-bson.bat b/.evergreen/scripts/check-installed-files-bson.bat deleted file mode 100644 index bc3bb27b57e..00000000000 --- a/.evergreen/scripts/check-installed-files-bson.bat +++ /dev/null @@ -1,76 +0,0 @@ -rem Validations shared by link-sample-program-msvc-bson.bat and -rem link-sample-program-mingw-bson.bat - -echo off - -rem Notice that the dll goes in "bin". -set DLL=%INSTALL_DIR%\bin\bson-1.0.dll -set LIB_DLL=%INSTALL_DIR%\bin\libbson-1.0.dll -set LIB_LIB=%INSTALL_DIR%\lib\libbson-1.0.lib -if "%MINGW%"=="1" ( - if not exist %LIB_DLL% ( - echo %LIB_DLL% is missing! - exit /B 1 - ) else ( - echo libbson-1.0.dll check ok - ) - if exist %DLL% ( - echo %DLL% is present and should not be! - exit /B 1 - ) -) else ( - if not exist %DLL% ( - echo %DLL% is missing! - exit /B 1 - ) else ( - echo bson-1.0.dll check ok - ) - if exist %LIB_LIB% ( - echo %LIB_LIB% is present and should not be! - exit /B 1 - ) else ( - echo libbson-1.0.lib check ok - ) -) -if not exist %INSTALL_DIR%\lib\pkgconfig\libbson-1.0.pc ( - echo libbson-1.0.pc missing! - exit /B 1 -) else ( - echo libbson-1.0.pc check ok -) -if not exist %INSTALL_DIR%\lib\cmake\bson-1.0\bson-1.0-config.cmake ( - echo bson-1.0-config.cmake missing! - exit /B 1 -) else ( - echo bson-1.0-config.cmake check ok -) -if not exist %INSTALL_DIR%\lib\cmake\bson-1.0\bson-1.0-config-version.cmake ( - echo bson-1.0-config-version.cmake missing! - exit /B 1 -) else ( - echo bson-1.0-config-version.cmake check ok -) -if not exist %INSTALL_DIR%\lib\cmake\bson-1.0\bson-targets.cmake ( - echo bson-targets.cmake missing! - exit /B 1 -) else ( - echo bson-targets.cmake check ok -) - -if "%LINK_STATIC%"=="1" ( - if not exist %INSTALL_DIR%\lib\pkgconfig\libbson-static-1.0.pc ( - echo libbson-static-1.0.pc missing! - exit /B 1 - ) else ( - echo libbson-static-1.0.pc check ok - ) -) else ( - if exist %INSTALL_DIR%\lib\pkgconfig\libbson-static-1.0.pc ( - echo libbson-static-1.0.pc should not have been installed! - exit /B 1 - ) else ( - echo libbson-static-1.0.pc missing, as expected - ) -) - -echo on diff --git a/.evergreen/scripts/check-installed-files.bat b/.evergreen/scripts/check-installed-files.bat deleted file mode 100644 index f75d365a4aa..00000000000 --- a/.evergreen/scripts/check-installed-files.bat +++ /dev/null @@ -1,66 +0,0 @@ -rem Validations shared by link-sample-program-msvc.bat and -rem link-sample-program-mingw.bat - -echo off - -rem Notice that the dll goes in "bin". -set DLL=%INSTALL_DIR%\bin\mongoc-1.0.dll -set LIB_DLL=%INSTALL_DIR%\bin\libmongoc-1.0.dll -set LIB_LIB=%INSTALL_DIR%\lib\libmongoc-1.0.lib -if "%MINGW%"=="1" ( - if not exist %LIB_DLL% ( - echo %LIB_DLL% is missing! - exit /B 1 - ) else ( - echo libmongoc-1.0.dll check ok - ) - if exist %DLL% ( - echo %DLL% is present and should not be! - exit /B 1 - ) -) else ( - if not exist %DLL% ( - echo %DLL% is missing! - exit /B 1 - ) else ( - echo mongoc-1.0.dll check ok - ) - if exist %LIB_LIB% ( - echo %LIB_LIB% is present and should not be! - exit /B 1 - ) else ( - echo libmongoc-1.0.lib check ok - ) -) -if not exist %INSTALL_DIR%\lib\pkgconfig\libmongoc-1.0.pc ( - echo libmongoc-1.0.pc missing! - exit /B 1 -) else ( - echo libmongoc-1.0.pc check ok -) -if not exist %INSTALL_DIR%\lib\cmake\mongoc-1.0\mongoc-1.0-config.cmake ( - echo mongoc-1.0-config.cmake missing! - exit /B 1 -) else ( - echo mongoc-1.0-config.cmake check ok -) -if not exist %INSTALL_DIR%\lib\cmake\mongoc-1.0\mongoc-1.0-config-version.cmake ( - echo mongoc-1.0-config-version.cmake missing! - exit /B 1 -) else ( - echo mongoc-1.0-config-version.cmake check ok -) -if not exist %INSTALL_DIR%\lib\cmake\mongoc-1.0\mongoc-targets.cmake ( - echo mongoc-targets.cmake missing! - exit /B 1 -) else ( - echo mongoc-targets.cmake check ok -) -if not exist %INSTALL_DIR%\lib\pkgconfig\libmongoc-static-1.0.pc ( - echo libmongoc-static-1.0.pc missing! - exit /B 1 -) else ( - echo libmongoc-static-1.0.pc check ok -) - -echo on diff --git a/.evergreen/scripts/install-uninstall-check-windows.cmd b/.evergreen/scripts/install-uninstall-check-windows.cmd index 332e072f958..6687a2d0177 100644 --- a/.evergreen/scripts/install-uninstall-check-windows.cmd +++ b/.evergreen/scripts/install-uninstall-check-windows.cmd @@ -15,6 +15,9 @@ set CMAKE_MAKE_PROGRAM=C:\mingw-w64\x86_64-4.9.1-posix-seh-rt_v3-rev1\mingw64\bi rem Ensure Cygwin executables like sh.exe are not in PATH set PATH=C:\cygwin\bin;C:\Windows\system32;C:\Windows;C:\mingw-w64\x86_64-4.9.1-posix-seh-rt_v3-rev1\mingw64\bin;C:\mongoc;src\libbson;src\libmongoc +set version=1.31.0 +set major=1 + if "%BSON_ONLY%"=="1" ( set BUILD_DIR=%CD%\build-dir-bson set INSTALL_DIR=%CD%\install-dir-bson @@ -120,29 +123,11 @@ echo.%CC%| findstr /I "gcc">Nul && ( ) ) -if exist %INSTALL_DIR%\lib\pkgconfig\libbson-1.0.pc ( - echo libbson-1.0.pc found! - exit /B 1 -) else ( - echo libbson-1.0.pc check ok -) -if exist %INSTALL_DIR%\lib\cmake\bson-1.0\bson-1.0-config.cmake ( - echo bson-1.0-config.cmake found! - exit /B 1 -) else ( - echo bson-1.0-config.cmake check ok -) -if exist %INSTALL_DIR%\lib\cmake\bson-1.0\bson-1.0-config-version.cmake ( - echo bson-1.0-config-version.cmake found! +if exist %INSTALL_DIR%\lib\pkgconfig\bson%major%.pc ( + echo bson%major%.pc found! exit /B 1 ) else ( - echo bson-1.0-config-version.cmake check ok -) -if exist %INSTALL_DIR%\lib\cmake\bson-1.0\bson-targets.cmake ( - echo bson-targets.cmake found! - exit /B 1 -) else ( - echo bson-targets.cmake check ok + echo bson%major%.pc check ok ) if not exist %INSTALL_DIR%\lib\canary.txt ( echo canary.txt not found! @@ -157,11 +142,11 @@ if not exist %INSTALL_DIR%\lib ( echo %INSTALL_DIR%\lib check ok ) if "%BSON_ONLY%" NEQ "1" ( - if exist %INSTALL_DIR%\lib\pkgconfig\libmongoc-1.0.pc ( - echo libmongoc-1.0.pc found! + if exist %INSTALL_DIR%\lib\pkgconfig\mongoc%major%.pc ( + echo mongoc%major%.pc found! exit /B 1 ) else ( - echo libmongoc-1.0.pc check ok + echo mongoc%major%.pc check ok ) if exist %INSTALL_DIR%\lib\cmake\mongoc-1.0\mongoc-1.0-config.cmake ( echo mongoc-1.0-config.cmake found! @@ -182,23 +167,17 @@ if "%BSON_ONLY%" NEQ "1" ( echo mongoc-targets.cmake check ok ) ) -if exist %INSTALL_DIR%\include\libbson-1.0\bson\bson.h ( +if exist %INSTALL_DIR%\include\bson-%version%\bson\bson.h ( echo bson\bson.h found! exit /B 1 ) else ( echo bson\bson.h check ok ) -if exist %INSTALL_DIR%\include\libbson-1.0\bson.h ( - echo bson.h found! - exit /B 1 -) else ( - echo bson.h check ok -) -if exist %INSTALL_DIR%\include\libbson-1.0 ( - echo $INSTALL_DIR\include\libbson-1.0 found! +if exist %INSTALL_DIR%\include\bson-%version% ( + echo $INSTALL_DIR\include\bson-%version% found! exit /B 1 ) else ( - echo $INSTALL_DIR\include\libbson-1.0 check ok + echo $INSTALL_DIR\include\bson-%version% check ok ) if "%BSON_ONLY%" NEQ "1" ( if exist %INSTALL_DIR%\include\libmongoc-1.0\mongoc\mongoc.h ( diff --git a/.evergreen/scripts/install-uninstall-check.sh b/.evergreen/scripts/install-uninstall-check.sh index 5240c1c67e9..c07680e4168 100755 --- a/.evergreen/scripts/install-uninstall-check.sh +++ b/.evergreen/scripts/install-uninstall-check.sh @@ -13,6 +13,13 @@ CMAKE=$(find_cmake_latest) . $DIR/check-symlink.sh SRCROOT=$(pwd) +# The major version of the project. Appears in certain install filenames. +_full_version=$(cat "$DIR/../../VERSION_CURRENT") +version="${_full_version%-*}" # 1.2.3-dev → 1.2.3 +major="${version%%.*}" # 1.2.3 → 1 +echo "major version: $major" +echo " full version: $version" + # Use ccache if able. . $DIR/find-ccache.sh find_ccache_and_export_vars "$(pwd)" || true @@ -20,7 +27,7 @@ find_ccache_and_export_vars "$(pwd)" || true SCRATCH_DIR=$(pwd)/.scratch rm -rf "$SCRATCH_DIR" mkdir -p "$SCRATCH_DIR" -cp -vr -- "$SRCROOT"/* "$SCRATCH_DIR" +cp -r -- "$SRCROOT"/* "$SCRATCH_DIR" if [ "$BSON_ONLY" ]; then BUILD_DIR=$SCRATCH_DIR/build-dir-bson @@ -58,8 +65,8 @@ if [[ -f $DIR/find-ccache.sh ]]; then find_ccache_and_export_vars "$SCRATCH_DIR" || true fi -$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DCMAKE_PREFIX_PATH=$INSTALL_DIR/lib/cmake $BSON_ONLY_OPTION "$SCRATCH_DIR" -$CMAKE --build . +$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DBUILD_TESTING=OFF -DCMAKE_PREFIX_PATH=$INSTALL_DIR/lib/cmake $BSON_ONLY_OPTION "$SCRATCH_DIR" +$CMAKE --build . --parallel if [ "$DESTDIR" ]; then DESTDIR=$DESTDIR $CMAKE --build . --target install else @@ -93,29 +100,23 @@ $CMAKE --build . --target uninstall set +o xtrace -if test -f $INSTALL_DIR/lib/pkgconfig/libbson-1.0.pc; then - echo "libbson-1.0.pc found!" - exit 1 -else - echo "libbson-1.0.pc check ok" -fi -if test -f $INSTALL_DIR/lib/cmake/bson-1.0/bson-1.0-config.cmake; then - echo "bson-1.0-config.cmake found!" +if test -f $INSTALL_DIR/lib/pkgconfig/bson$major.pc; then + echo "bson$major.pc found!" exit 1 else - echo "bson-1.0-config.cmake check ok" + echo "bson$major.pc check ok" fi -if test -f $INSTALL_DIR/lib/cmake/bson-1.0/bson-1.0-config-version.cmake; then - echo "bson-1.0-config-version.cmake found!" +if test -f $INSTALL_DIR/lib/cmake/bson-$version/bsonConfig.cmake; then + echo "bsonConfig.cmake found!" exit 1 else - echo "bson-1.0-config-version.cmake check ok" + echo "bsonConfig.cmake check ok" fi -if test -f $INSTALL_DIR/lib/cmake/bson-1.0/bson-targets.cmake; then - echo "bson-targets.cmake found!" +if test -f $INSTALL_DIR/lib/cmake/bson-$version/bsonConfigVersion.cmake; then + echo "bsonConfigVersion.cmake found!" exit 1 else - echo "bson-targets.cmake check ok" + echo "bsonConfigVersion.cmake check ok" fi if test ! -f $INSTALL_DIR/lib/canary.txt; then echo "canary.txt not found!" @@ -130,11 +131,11 @@ else echo "$INSTALL_DIR/lib check ok" fi if [ -z "$BSON_ONLY" ]; then - if test -f $INSTALL_DIR/lib/pkgconfig/libmongoc-1.0.pc; then - echo "libmongoc-1.0.pc found!" + if test -f $INSTALL_DIR/lib/pkgconfig/mongoc$major.pc; then + echo "mongoc$major.pc found!" exit 1 else - echo "libmongoc-1.0.pc check ok" + echo "mongoc$major.pc check ok" fi if test -f $INSTALL_DIR/lib/cmake/mongoc-1.0/mongoc-1.0-config.cmake; then echo "mongoc-1.0-config.cmake found!" @@ -155,17 +156,17 @@ if [ -z "$BSON_ONLY" ]; then echo "mongoc-targets.cmake check ok" fi fi -if test -f $INSTALL_DIR/include/libbson-1.0/bson/bson.h; then +if test -f $INSTALL_DIR/include/bson-$version/bson/bson.h; then echo "bson/bson.h found!" exit 1 else echo "bson/bson.h check ok" fi -if test -d $INSTALL_DIR/include/libbson-1.0; then - echo "$INSTALL_DIR/include/libbson-1.0 found!" +if test -d $INSTALL_DIR/include/bson-$version; then + echo "$INSTALL_DIR/include/bson-$version found!" exit 1 else - echo "$INSTALL_DIR/include/libbson-1.0 check ok" + echo "$INSTALL_DIR/include/bson-$version check ok" fi if [ -z "$BSON_ONLY" ]; then if test -f $INSTALL_DIR/include/libmongoc-1.0/mongoc/mongoc.h; then diff --git a/.evergreen/scripts/link-sample-program-bson.sh b/.evergreen/scripts/link-sample-program-bson.sh index 7ab94d76dc6..c17230c9b84 100755 --- a/.evergreen/scripts/link-sample-program-bson.sh +++ b/.evergreen/scripts/link-sample-program-bson.sh @@ -4,27 +4,29 @@ set -o errexit # Exit the script with error if any of the commands fail # Supported/used environment variables: # LINK_STATIC Whether to statically link to libbson # BUILD_SAMPLE_WITH_CMAKE Link program w/ CMake. Default: use pkg-config. -# BUILD_SAMPLE_WITH_CMAKE_DEPRECATED If BUILD_SAMPLE_WITH_CMAKE is set, then use deprecated CMake scripts instead. -echo "LINK_STATIC=$LINK_STATIC BUILD_SAMPLE_WITH_CMAKE=$BUILD_SAMPLE_WITH_CMAKE BUILD_SAMPLE_WITH_CMAKE_DEPRECATED=$BUILD_SAMPLE_WITH_CMAKE_DEPRECATED" +echo "LINK_STATIC=$LINK_STATIC BUILD_SAMPLE_WITH_CMAKE=$BUILD_SAMPLE_WITH_CMAKE" DIR=$(dirname $0) . $DIR/find-cmake-latest.sh CMAKE=$(find_cmake_latest) . $DIR/check-symlink.sh +# The major version of the project. Appears in certain install filenames. +_full_version=$(cat "$DIR/../../VERSION_CURRENT") +version="${_full_version%-*}" # 1.2.3-dev → 1.2.3 +major="${version%%.*}" # 1.2.3 → 1 +echo "major version: $major" +echo " full version: $version" + # Get the kernel name, lowercased OS=$(uname -s | tr '[:upper:]' '[:lower:]') echo "OS: $OS" if [ "$OS" = "darwin" ]; then - SO=dylib - LIB_SO=libbson-1.0.0.dylib LDD="otool -L" else - SO=so - LIB_SO=libbson-1.0.so.0.0.0 LDD=ldd fi @@ -52,29 +54,13 @@ fi if [ "$LINK_STATIC" ]; then # Our CMake system builds shared and static by default. - $CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DENABLE_TESTS=OFF "$SCRATCH_DIR" + $CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DBUILD_TESTING=OFF -DENABLE_TESTS=OFF -DENABLE_MONGOC=OFF "$SCRATCH_DIR" $CMAKE --build . --parallel $CMAKE --build . --parallel --target install else - $CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DENABLE_TESTS=OFF -DENABLE_STATIC=OFF "$SCRATCH_DIR" + $CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DBUILD_TESTING=OFF -DENABLE_TESTS=OFF -DENABLE_MONGOC=OFF -DENABLE_STATIC=OFF "$SCRATCH_DIR" $CMAKE --build . --parallel $CMAKE --build . --parallel --target install - - set +o xtrace - - if test -f $INSTALL_DIR/lib/libbson-static-1.0.a; then - echo "libbson-static-1.0.a shouldn't have been installed" - exit 1 - fi - if test -f $INSTALL_DIR/lib/libbson-1.0.a; then - echo "libbson-1.0.a shouldn't have been installed" - exit 1 - fi - if test -f $INSTALL_DIR/lib/pkgconfig/libbson-static-1.0.pc; then - echo "libbson-static-1.0.pc shouldn't have been installed" - exit 1 - fi - fi # Revert ccache options, they no longer apply. @@ -82,83 +68,10 @@ unset CCACHE_BASEDIR CCACHE_NOHASHDIR ls -l $INSTALL_DIR/lib -set +o xtrace - -# Check on Linux that libbson is installed into lib/ like: -# libbson-1.0.so -> libbson-1.0.so.0 -# libbson-1.0.so.0 -> libbson-1.0.so.0.0.0 -# libbson-1.0.so.0.0.0 -if [ "$OS" != "darwin" ]; then - # From check-symlink.sh - check_symlink libbson-1.0.so libbson-1.0.so.0 - check_symlink libbson-1.0.so.0 libbson-1.0.so.0.0.0 - SONAME=$(objdump -p $INSTALL_DIR/lib/$LIB_SO|grep SONAME|awk '{print $2}') - EXPECTED_SONAME="libbson-1.0.so.0" - if [ "$SONAME" != "$EXPECTED_SONAME" ]; then - echo "SONAME should be $EXPECTED_SONAME, not $SONAME" - exit 1 - else - echo "library name check ok, SONAME=$SONAME" - fi -else - # Just test that the shared lib was installed. - if test ! -f $INSTALL_DIR/lib/$LIB_SO; then - echo "$LIB_SO missing!" - exit 1 - else - echo "$LIB_SO check ok" - fi -fi - -if test ! -f $INSTALL_DIR/lib/pkgconfig/libbson-1.0.pc; then - echo "libbson-1.0.pc missing!" - exit 1 -else - echo "libbson-1.0.pc check ok" -fi -if test ! -f $INSTALL_DIR/lib/cmake/bson-1.0/bson-1.0-config.cmake; then - echo "bson-1.0-config.cmake missing!" - exit 1 -else - echo "bson-1.0-config.cmake check ok" -fi -if test ! -f $INSTALL_DIR/lib/cmake/bson-1.0/bson-1.0-config-version.cmake; then - echo "bson-1.0-config-version.cmake missing!" - exit 1 -else - echo "bson-1.0-config-version.cmake check ok" -fi -if test ! -f $INSTALL_DIR/lib/cmake/bson-1.0/bson-targets.cmake; then - echo "bson-targets.cmake missing!" - exit 1 -else - echo "bson-targets.cmake check ok" -fi - -if [ "$LINK_STATIC" ]; then - if test ! -f $INSTALL_DIR/lib/libbson-static-1.0.a; then - echo "libbson-static-1.0.a missing!" - exit 1 - else - echo "libbson-static-1.0.a check ok" - fi - if test ! -f $INSTALL_DIR/lib/pkgconfig/libbson-static-1.0.pc; then - echo "libbson-static-1.0.pc missing!" - exit 1 - else - echo "libbson-static-1.0.pc check ok" - fi -fi - cd $SRCROOT if [ "$BUILD_SAMPLE_WITH_CMAKE" ]; then - # Test our CMake package config file with CMake's find_package command. - if [ "$BUILD_SAMPLE_WITH_CMAKE_DEPRECATED" ]; then - EXAMPLE_DIR=$SRCROOT/src/libbson/examples/cmake-deprecated/find_package - else - EXAMPLE_DIR=$SRCROOT/src/libbson/examples/cmake/find_package - fi + EXAMPLE_DIR=$SRCROOT/src/libbson/examples/cmake/find_package if [ "$LINK_STATIC" ]; then EXAMPLE_DIR="${EXAMPLE_DIR}_static" @@ -174,12 +87,12 @@ else if [ "$LINK_STATIC" ]; then echo "pkg-config output:" - echo $(pkg-config --libs --cflags libbson-static-1.0) - ./compile-with-pkg-config-static.sh + echo $(pkg-config --libs --cflags bson$major-static) + env major=$major ./compile-with-pkg-config-static.sh else echo "pkg-config output:" - echo $(pkg-config --libs --cflags libbson-1.0) - ./compile-with-pkg-config.sh + echo $(pkg-config --libs --cflags bson$major) + env major=$major ./compile-with-pkg-config.sh fi fi diff --git a/.evergreen/scripts/link-sample-program-mingw-bson.cmd b/.evergreen/scripts/link-sample-program-mingw-bson.cmd index 3a0f0c74e85..d8a6926889b 100644 --- a/.evergreen/scripts/link-sample-program-mingw-bson.cmd +++ b/.evergreen/scripts/link-sample-program-mingw-bson.cmd @@ -19,6 +19,9 @@ mkdir %INSTALL_DIR% set PATH=%PATH%;%INSTALL_DIR%\bin +set major=1 +set version=1.31.0 + cd %BUILD_DIR% robocopy "%SRCROOT%" "%BUILD_DIR%" /E /XD ".git" "%BUILD_DIR%" "_build" "cmake-build" /NP /NFL /NDL @@ -34,22 +37,6 @@ if errorlevel 1 ( exit /B 1 ) -set MINGW=1 -call ..\.evergreen\scripts\check-installed-files-bson.bat -if errorlevel 1 ( - exit /B 1 -) -set MINGW= - -if not exist %INSTALL_DIR%\lib\libbson-static-1.0.a ( - echo libbson-static-1.0.a missing! - exit /B 1 -) else ( - echo libbson-static-1.0.a check ok -) - -cd %SRCROOT% - rem Test our pkg-config file set EXAMPLE_DIR=%SRCROOT%\src\libbson\examples\ cd %EXAMPLE_DIR% @@ -60,7 +47,7 @@ exit /B 0 set PKG_CONFIG_PATH=%INSTALL_DIR%\lib\pkgconfig rem http://stackoverflow.com/questions/2323292 -for /f %%i in ('pkg-config --libs --cflags libbson-1.0') do set PKG_CONFIG_OUT=%%i +for /f %%i in ('pkg-config --libs --cflags bson%major%') do set PKG_CONFIG_OUT=%%i echo PKG_CONFIG_OUT is %PKG_CONFIG_OUT% diff --git a/.evergreen/scripts/link-sample-program-mingw.cmd b/.evergreen/scripts/link-sample-program-mingw.cmd index a6e29cf5915..96031ea7d81 100644 --- a/.evergreen/scripts/link-sample-program-mingw.cmd +++ b/.evergreen/scripts/link-sample-program-mingw.cmd @@ -20,6 +20,8 @@ mkdir %INSTALL_DIR% set PATH=%PATH%;%INSTALL_DIR%\bin +set major=1 + cd %BUILD_DIR% robocopy "%SRCROOT%" "%BUILD_DIR%" /E /XD ".git" "%BUILD_DIR%" "_build" "cmake-build" /NP /NFL /NDL @@ -35,22 +37,6 @@ if errorlevel 1 ( exit /B 1 ) -set MINGW=1 -call ..\.evergreen\scripts\check-installed-files.bat -if errorlevel 1 ( - exit /B 1 -) -set MINGW= - -if not exist %INSTALL_DIR%\lib\libmongoc-static-1.0.a ( - echo libmongoc-static-1.0.a missing! - exit /B 1 -) else ( - echo libmongoc-static-1.0.a check ok -) - -cd %SRCROOT% - rem Test our pkg-config file set EXAMPLE_DIR=%SRCROOT%\src\libmongoc\examples\ cd %EXAMPLE_DIR% @@ -61,7 +47,7 @@ exit /B 0 set PKG_CONFIG_PATH=%INSTALL_DIR%\lib\pkgconfig rem http://stackoverflow.com/questions/2323292 -for /f %%i in ('pkg-config --libs --cflags libmongoc-1.0') do set PKG_CONFIG_OUT=%%i +for /f %%i in ('pkg-config --libs --cflags mongoc%major%') do set PKG_CONFIG_OUT=%%i echo PKG_CONFIG_OUT is %PKG_CONFIG_OUT% diff --git a/.evergreen/scripts/link-sample-program-msvc-bson.cmd b/.evergreen/scripts/link-sample-program-msvc-bson.cmd index 857a29d6e00..6ecbc2883d6 100644 --- a/.evergreen/scripts/link-sample-program-msvc-bson.cmd +++ b/.evergreen/scripts/link-sample-program-msvc-bson.cmd @@ -34,11 +34,6 @@ if "%LINK_STATIC%"=="1" ( %CMAKE% --build . --target ALL_BUILD --config "Debug" -- /m %CMAKE% --build . --target INSTALL --config "Debug" -- /m -call ..\.evergreen\scripts\check-installed-files-bson.bat -if errorlevel 1 ( - exit /B %errorlevel% -) - rem Test our CMake package config file with CMake's find_package command. set EXAMPLE_DIR=%SRCROOT%\src\libbson\examples\cmake\find_package diff --git a/.evergreen/scripts/link-sample-program-msvc.cmd b/.evergreen/scripts/link-sample-program-msvc.cmd index 96dddff2310..351649c5cad 100644 --- a/.evergreen/scripts/link-sample-program-msvc.cmd +++ b/.evergreen/scripts/link-sample-program-msvc.cmd @@ -52,29 +52,6 @@ if "%ENABLE_SSL%"=="1" ( %CMAKE% --build . --target ALL_BUILD --config "Debug" -- /m %CMAKE% --build . --target INSTALL --config "Debug" -- /m -call ..\.evergreen\scripts\check-installed-files.bat -if errorlevel 1 ( - exit /B %errorlevel% -) - -rem Shim library around the DLL. -set SHIM=%INSTALL_DIR%\lib\mongoc-1.0.lib -if not exist %SHIM% ( - echo %SHIM% is missing! - exit /B 1 -) else ( - echo %SHIM% check ok -) - -if not exist %INSTALL_DIR%\lib\mongoc-static-1.0.lib ( - echo mongoc-static-1.0.lib missing! - exit /B 1 -) else ( - echo mongoc-static-1.0.lib check ok -) - -cd %SRCROOT% - rem Test our CMake package config file with CMake's find_package command. set EXAMPLE_DIR=%SRCROOT%\src\libmongoc\examples\cmake\find_package diff --git a/.evergreen/scripts/link-sample-program.sh b/.evergreen/scripts/link-sample-program.sh index 031d5b3e361..52d4c0f1e60 100755 --- a/.evergreen/scripts/link-sample-program.sh +++ b/.evergreen/scripts/link-sample-program.sh @@ -4,30 +4,32 @@ set -o errexit # Exit the script with error if any of the commands fail # Supported/used environment variables: # LINK_STATIC Whether to statically link to libmongoc # BUILD_SAMPLE_WITH_CMAKE Link program w/ CMake. Default: use pkg-config. -# BUILD_SAMPLE_WITH_CMAKE_DEPRECATED If BUILD_SAMPLE_WITH_CMAKE is set, then use deprecated CMake scripts instead. # ENABLE_SSL Set -DENABLE_SSL # ENABLE_SNAPPY Set -DENABLE_SNAPPY # CMAKE Path to cmake executable. -echo "LINK_STATIC=$LINK_STATIC BUILD_SAMPLE_WITH_CMAKE=$BUILD_SAMPLE_WITH_CMAKE BUILD_SAMPLE_WITH_CMAKE_DEPRECATED=$BUILD_SAMPLE_WITH_CMAKE_DEPRECATED" +echo "LINK_STATIC=$LINK_STATIC BUILD_SAMPLE_WITH_CMAKE=$BUILD_SAMPLE_WITH_CMAKE" DIR=$(dirname $0) . $DIR/find-cmake-latest.sh CMAKE=$(find_cmake_latest) . $DIR/check-symlink.sh +# The major version of the project. Appears in certain install filenames. +_full_version=$(cat "$DIR/../../VERSION_CURRENT") +version="${_full_version%-*}" # 1.2.3-dev → 1.2.3 +major="${version%%.*}" # 1.2.3 → 1 +echo "major version: $major" +echo " full version: $version" + # Get the kernel name, lowercased OS=$(uname -s | tr '[:upper:]' '[:lower:]') echo "OS: $OS" if [ "$OS" = "darwin" ]; then - SO=dylib - LIB_SO=libmongoc-1.0.0.dylib LDD="otool -L" else - SO=so - LIB_SO=libmongoc-1.0.so.0 LDD=ldd fi @@ -82,7 +84,7 @@ if [[ -f $DIR/find-ccache.sh ]]; then fi fi -$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DCMAKE_PREFIX_PATH=$INSTALL_DIR/lib/cmake $SSL_CMAKE_OPTION $SNAPPY_CMAKE_OPTION $STATIC_CMAKE_OPTION -DENABLE_ZSTD=$ZSTD "$SCRATCH_DIR" +$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DCMAKE_PREFIX_PATH=$INSTALL_DIR/lib/cmake -DBUILD_TESTING=OFF $SSL_CMAKE_OPTION $SNAPPY_CMAKE_OPTION $STATIC_CMAKE_OPTION -DENABLE_ZSTD=$ZSTD "$SCRATCH_DIR" $CMAKE --build . --parallel $CMAKE --build . --parallel --target install @@ -91,100 +93,17 @@ unset CCACHE_BASEDIR CCACHE_NOHASHDIR ls -l $INSTALL_DIR/lib -set +o xtrace - -# Check on Linux that libmongoc is installed into lib/ like: -# libmongoc-1.0.so -> libmongoc-1.0.so.0 -# libmongoc-1.0.so.0 -> libmongoc-1.0.so.0.0.0 -# libmongoc-1.0.so.0.0.0 -if [ "$OS" != "darwin" ]; then - # From check-symlink.sh - check_symlink libmongoc-1.0.so libmongoc-1.0.so.0 - check_symlink libmongoc-1.0.so.0 libmongoc-1.0.so.0.0.0 - SONAME=$(objdump -p $INSTALL_DIR/lib/$LIB_SO|grep SONAME|awk '{print $2}') - EXPECTED_SONAME="libmongoc-1.0.so.0" - if [ "$SONAME" != "$EXPECTED_SONAME" ]; then - echo "SONAME should be $EXPECTED_SONAME, not $SONAME" - exit 1 - else - echo "library name check ok, SONAME=$SONAME" - fi -else - # Just test that the shared lib was installed. - if test ! -f $INSTALL_DIR/lib/$LIB_SO; then - echo "$LIB_SO missing!" - exit 1 - else - echo "$LIB_SO check ok" - fi -fi - - -if test ! -f $INSTALL_DIR/lib/pkgconfig/libmongoc-1.0.pc; then - echo "libmongoc-1.0.pc missing!" - exit 1 -else - echo "libmongoc-1.0.pc check ok" -fi -if test ! -f $INSTALL_DIR/lib/cmake/mongoc-1.0/mongoc-1.0-config.cmake; then - echo "mongoc-1.0-config.cmake missing!" - exit 1 -else - echo "mongoc-1.0-config.cmake check ok" -fi -if test ! -f $INSTALL_DIR/lib/cmake/mongoc-1.0/mongoc-1.0-config-version.cmake; then - echo "mongoc-1.0-config-version.cmake missing!" - exit 1 -else - echo "mongoc-1.0-config-version.cmake check ok" -fi -if test ! -f $INSTALL_DIR/lib/cmake/mongoc-1.0/mongoc-targets.cmake; then - echo "mongoc-targets.cmake missing!" - exit 1 -else - echo "mongoc-targets.cmake check ok" -fi - - -if [ "$LINK_STATIC" ]; then - if test ! -f $INSTALL_DIR/lib/libmongoc-static-1.0.a; then - echo "libmongoc-static-1.0.a missing!" - exit 1 - else - echo "libmongoc-static-1.0.a check ok" - fi - if test ! -f $INSTALL_DIR/lib/pkgconfig/libmongoc-static-1.0.pc; then - echo "libmongoc-static-1.0.pc missing!" - exit 1 - else - echo "libmongoc-static-1.0.pc check ok" - fi -else - if test -f $INSTALL_DIR/lib/libmongoc-static-1.0.a; then - echo "libmongoc-static-1.0.a shouldn't have been installed" - exit 1 - fi - if test -f $INSTALL_DIR/lib/libmongoc-1.0.a; then - echo "libmongoc-1.0.a shouldn't have been installed" - exit 1 - fi - if test -f $INSTALL_DIR/lib/pkgconfig/libmongoc-static-1.0.pc; then - echo "libmongoc-static-1.0.pc shouldn't have been installed" - exit 1 - fi -fi - -if [ "$OS" = "darwin" && "${HOSTTYPE:?}" != "arm64" ]; then - if test -f $INSTALL_DIR/bin/mongoc-stat; then - echo "mongoc-stat shouldn't have been installed" +if [ "$OS" = "darwin" ] && [ "${HOSTTYPE:?}" != "arm64" ]; then + if test -f $INSTALL_DIR/bin/mongoc$major-stat; then + echo "mongoc$major-stat shouldn't have been installed" exit 1 fi else - if test ! -f $INSTALL_DIR/bin/mongoc-stat; then - echo "mongoc-stat missing!" + if test ! -f $INSTALL_DIR/bin/mongoc$major-stat; then + echo "mongoc$major-stat missing!" exit 1 else - echo "mongoc-stat check ok" + echo "mongoc$major-stat check ok" fi fi @@ -210,12 +129,12 @@ else if [ "$LINK_STATIC" ]; then echo "pkg-config output:" - echo $(pkg-config --libs --cflags libmongoc-static-1.0) - ./compile-with-pkg-config-static.sh + echo $(pkg-config --libs --cflags mongoc$major-static) + env major=$major ./compile-with-pkg-config-static.sh else echo "pkg-config output:" - echo $(pkg-config --libs --cflags libmongoc-1.0) - ./compile-with-pkg-config.sh + echo $(pkg-config --libs --cflags mongoc$major) + env major=$major ./compile-with-pkg-config.sh fi fi diff --git a/CMakeLists.txt b/CMakeLists.txt index 85a219488a9..b2f926510e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -172,8 +172,6 @@ mongo_setting(ENABLE_MONGODB_AWS_AUTH "Enable support for the MONGODB-AWS authen # Optional features that are DISABLED by default: mongo_bool_setting(ENABLE_RDTSCP "Enable fast performance counters using the Intel RDTSCP instruction" DEFAULT VALUE OFF) -mongo_bool_setting(ENABLE_APPLE_FRAMEWORK "Build libraries as Apple Frameworks on Darwin platforms" - DEFAULT VALUE OFF) mongo_bool_setting( ENABLE_CRYPTO_SYSTEM_PROFILE "Use system crypto profile" DEFAULT VALUE OFF @@ -254,12 +252,12 @@ include (CMakeDependentOption) include (GNUInstallDirs) # The directory where CMake config packages will be installed, based on the libdir from GNUInstallDirs mongo_setting( - MONGOC_INSTALL_CMAKEDIR "The directory in which CMake package files will be installed" + MONGO_C_DRIVER_INSTALL_CMAKEDIR "The directory in which CMake package files will be installed" TYPE STRING DEFAULT VALUE "${CMAKE_INSTALL_LIBDIR}/cmake" VALIDATE CODE [[ - if(IS_ABSOLUTE "${MONGOC_INSTALL_CMAKEDIR}") - message(SEND_ERROR "The CMake installation directory must be a relative path (Got “${MONGOC_INSTALL_CMAKEDIR}”)") + if(IS_ABSOLUTE "${MONGO_C_DRIVER_INSTALL_CMAKEDIR}") + message(SEND_ERROR "The CMake installation directory must be a relative path (Got “${MONGO_C_DRIVER_INSTALL_CMAKEDIR}”)") endif() ]] ) @@ -308,31 +306,17 @@ mongo_pick(MONGOC_ENABLE_STATIC_INSTALL 1 0 [[ENABLE_STATIC AND NOT ENABLE_STATIC STREQUAL "BUILD_ONLY"]]) if (USE_SYSTEM_LIBBSON) - # The input variable BSON_ROOT_DIR is respected for backwards compatibility, - # but you should use the standard CMAKE_PREFIX_PATH instead. - message (STATUS "Searching for libbson CMake packages") - find_package (bson-1.0 - "${PROJECT_VERSION}" - HINTS - ${BSON_ROOT_DIR}) - - if (NOT bson-1.0_FOUND) - message (FATAL_ERROR "System libbson not found") - endif () - - message (STATUS "libbson found version \"${bson-1.0_VERSION}\"") - message (STATUS "disabling test-libmongoc since using system libbson") - SET (ENABLE_TESTS OFF) + find_package (bson "${PROJECT_VERSION}" REQUIRED) + # Disable test-libmongoc since we are using a system libbson + set (ENABLE_TESTS OFF) set (USING_SYSTEM_BSON TRUE) - if (NOT TARGET mongo::bson_shared) - message (FATAL_ERROR "System libbson built without shared library target") + if (NOT TARGET bson::shared) + message (FATAL_ERROR "System libbson built without shared library target") endif () - set (BSON_LIBRARIES mongo::bson_shared) - if (NOT TARGET mongo::bson_static) - message (FATAL_ERROR "System libbson built without static library target") + if (NOT TARGET bson::static) + message (FATAL_ERROR "System libbson built without static library target") endif () - set (BSON_STATIC_LIBRARIES mongo::bson_static) endif () set (BUILD_SOURCE_DIR ${CMAKE_BINARY_DIR}) @@ -355,9 +339,15 @@ set (CMAKE_BUILD_WITH_INSTALL_RPATH OFF) # Include any custom library paths in the final RPATH. set (CMAKE_INSTALL_RPATH_USE_LINK_PATH ON) -# Install libs with names like @rpath/libmongoc-1.0.0.dylib, not bare names. +# Install libs with names like @rpath/libfoo.dylib, not bare names. set (CMAKE_MACOSX_RPATH ON) +# Distinguish DLL import libs with a .dll.lib suffix. Also prevents filename collisions +# between static libraries and the import libraries +if(WIN32) + set (CMAKE_IMPORT_LIBRARY_SUFFIX .dll.lib) +endif() + # https://cmake.org/cmake/help/v3.11/policy/CMP0042.html # Enable a CMake 3.0+ policy that sets CMAKE_MACOSX_RPATH by default, and # silence a CMake 3.11 warning that the old behavior is deprecated. @@ -405,14 +395,7 @@ add_subdirectory (src/common) if (NOT USING_SYSTEM_BSON) message (STATUS "Using bundled libbson") - add_subdirectory (src/libbson) - # Defined in src/libbson/CMakeLists.txt - set (BSON_STATIC_LIBRARIES bson_static) - set (BSON_LIBRARIES bson_shared) - set (BSON_STATIC_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src/libbson/src" "${PROJECT_BINARY_DIR}/src/libbson/src") - set (BSON_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src/libbson/src" "${PROJECT_BINARY_DIR}/src/libbson/src") - set (BSON_STATIC_PUBLIC_DEFINITIONS "BSON_STATIC") endif () if (MSVC) @@ -482,7 +465,7 @@ if (ENABLE_MONGOC) endif () install (FILES COPYING NEWS README.rst THIRD_PARTY_NOTICES - DESTINATION ${CMAKE_INSTALL_DATADIR}/mongo-c-driver + DESTINATION ${CMAKE_INSTALL_DATADIR}/mongo-c-driver/${PROJECT_VERSION} ) if (ENABLE_UNINSTALL) @@ -494,7 +477,7 @@ if (ENABLE_UNINSTALL) # Generate a different script name for uninstalling libbson only: set (UNINSTALL_SCRIPT_NAME "uninstall-bson") endif () - set (UNINSTALL_PROG_DIR "${CMAKE_INSTALL_DATADIR}/mongo-c-driver") + set (UNINSTALL_PROG_DIR "${CMAKE_INSTALL_DATADIR}/mongo-c-driver/${PROJECT_VERSION}") include (GenerateUninstaller) endif () diff --git a/NEWS b/NEWS index 4063538fde9..b79f3ccf225 100644 --- a/NEWS +++ b/NEWS @@ -46,6 +46,27 @@ Unreleased (2.0.0) * Consistently apply `__cdecl` calling convention to function declarations in public API. Intended to support consumers building their code using a different [default calling convention](https://learn.microsoft.com/en-us/cpp/build/reference/gd-gr-gv-gz-calling-convention) with MSVC. The mongoc and bson libraries only support being built with the `__cdecl` default calling convention. * `mongoc_client_set_ssl_opts` now ignores a pooled `mongoc_client_t` and logs an error. Use `mongoc_client_pool_set_ssl_opts` to set TLS options on a `mongoc_client_pool_t` before popping any clients. * `mongoc_client_set_ssl_stream_initiator` now ignores a pooled `mongoc_client_t` and logs an error. +* The pkg-config files `libmongoc-1.0`, `libmongoc-static-1.0`, `libbson-1.0`, + and `libbson-static-1.0` have been renamed to `mongoc2`, `mongoc2-static`, + `bson2`, and `bson2-static`, respectively. + +### CMake Packages and Imported Targets + +The `mongoc-1.0` (and `bson-1.0`) CMake packages have been removed. Instead, use +`mongoc` or `bson`, and specify a version or version range to be imported: + +```cmake +find_package(mongoc 1.30...2.0) +``` + +The new packages import different target names: + +- `mongo::mongoc_static` → `mongoc::static` +- `mongo::mongoc_shared` → `mongoc::shared` +- The target `mongoc::mongoc` is a shim target that points to either the shared + library or the static library. + +The BSON library has had similar name changes. ## Removals @@ -114,6 +135,7 @@ Unreleased (2.0.0) * Deprecated write concern API is removed: * `mongoc_write_concern_get_fsync` is removed. Use `mongoc_write_concern_get_journal` instead. * `mongoc_write_concern_set_fsync` is removed. Use `mongoc_write_concern_set_journal` instead. +* The `libmongoc-ssl-1.0` pkg-config file has been removed. ### Forwarding headers (`#include ` and `#include `) diff --git a/build/cmake/GeneratePkgConfig.cmake b/build/cmake/GeneratePkgConfig.cmake index e4c1408e655..8e9d77f17c9 100644 --- a/build/cmake/GeneratePkgConfig.cmake +++ b/build/cmake/GeneratePkgConfig.cmake @@ -278,8 +278,11 @@ function(_generate_pkg_config_content out) set(libs) # Link options: set(gx_libs - "-L\${libdir}" - "-l$" + $,STATIC_LIBRARY>, + # If linking static, emit the full path to the static library file + \${libdir}/$, + # Otherwise, link to the dynamic library namelink + -L\${libdir} -l$> $> $> ) diff --git a/build/cmake/MongoPlatform.cmake b/build/cmake/MongoPlatform.cmake index d5e5d1075d5..e5dccab3add 100644 --- a/build/cmake/MongoPlatform.cmake +++ b/build/cmake/MongoPlatform.cmake @@ -8,9 +8,9 @@ Use mongo_platform_compile_options and mongo_platform_link_options to add usage requirements to this library. The mongo::detail::c_platform library is installed and exported with the -bson-targets export set as an implementation detail. It is installed with this +mongo-platform-targets export set as an implementation detail. It is installed with this export set so that it is available to both libbson and libmongoc (attempting to -install this target in both bson-targets and mongoc-targets export sets would +install this target in both mongo-platform-targets and mongoc-targets export sets would lead to duplicate definitions of mongo::detail::c_platform for downstream users). @@ -23,9 +23,9 @@ else () # The system libbson exports the `mongo::detail::c_platform` target. # Do not define the `mongo::detail::c_platform` target, to prevent an "already defined" error. endif () -set_property(TARGET _mongo-platform PROPERTY EXPORT_NAME detail::c_platform) -install(TARGETS _mongo-platform EXPORT bson-targets) - +set_property(TARGET _mongo-platform PROPERTY EXPORT_NAME mongo::detail::c_platform) +# This export set is installed as part of libbson. Search: PLATFORM-EXPORT-TARGET-INSTALL +install(TARGETS _mongo-platform EXPORT mongo-platform-targets) #[[ Define additional platform-support compile options diff --git a/build/cmake/TestProject.cmake b/build/cmake/TestProject.cmake index d8f0790810f..a89532be1e3 100644 --- a/build/cmake/TestProject.cmake +++ b/build/cmake/TestProject.cmake @@ -160,15 +160,20 @@ function(__do_test_project) set(tmp_install_prefix "${TEST_PROJECT_PARENT_BINARY_DIR}/TestProject-install/${test_name_hash}") file(REMOVE_RECURSE "${tmp_install_prefix}") list(APPEND TEST_PROJECT_SETTINGS/CMAKE_INSTALL_PREFIX "${tmp_install_prefix}") + list(APPEND TEST_PROJECT_SETTINGS/CMAKE_PREFIX_PATH "${tmp_install_prefix}") if(TEST_PROJECT_INSTALL_PARENT) cmake_path(ABSOLUTE_PATH tmp_install_prefix NORMALIZE) message(STATUS "Installing parent project into [${tmp_install_prefix}]") execute_process( - COMMAND ${CMAKE_COMMAND} - --install "${TEST_PROJECT_PARENT_BINARY_DIR}" - --prefix "${tmp_install_prefix}" - --config "${TEST_PROJECT_CONFIG}" + COMMAND + # Suppress DESTDIR + ${CMAKE_COMMAND} -E env --unset=DESTDIR + # Do the install: + ${CMAKE_COMMAND} + --install "${TEST_PROJECT_PARENT_BINARY_DIR}" + --prefix "${tmp_install_prefix}" + --config "${TEST_PROJECT_CONFIG}" COMMAND_ERROR_IS_FATAL LAST ) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7b37749a904..c491fc29b02 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,20 +13,20 @@ if (CMAKE_CXX_COMPILER) # Add a C++ source file that will #include the main C headers. This "library" # does nothing other than validate that the C headers are valid C++ headers. add_library (mongoc-cxx-check OBJECT cpp-check.cpp) - if (TARGET mongoc_static) - target_link_libraries (mongoc-cxx-check PRIVATE mongoc_static) + if (TARGET mongoc::static) + target_link_libraries (mongoc-cxx-check PRIVATE mongoc::static) else () - target_link_libraries (mongoc-cxx-check PRIVATE mongoc_shared) + target_link_libraries (mongoc-cxx-check PRIVATE mongoc::shared) endif () endif () # public-header-warnings add_executable(public-header-warnings EXCLUDE_FROM_ALL ${CMAKE_CURRENT_SOURCE_DIR}/c-check.c) -if (TARGET mongoc_static) - target_link_libraries(public-header-warnings PRIVATE mongoc_static) +if (TARGET mongoc::static) + target_link_libraries(public-header-warnings PRIVATE mongoc::static) else () - target_link_libraries(public-header-warnings PRIVATE mongoc_shared) + target_link_libraries(public-header-warnings PRIVATE mongoc::shared) endif () target_compile_options(public-header-warnings PRIVATE diff --git a/src/libbson/CMakeLists.txt b/src/libbson/CMakeLists.txt index 3c50b72a096..d1785b4e912 100644 --- a/src/libbson/CMakeLists.txt +++ b/src/libbson/CMakeLists.txt @@ -29,15 +29,10 @@ set(libbson_VERSION_FULL ${mongo-c-driver_VERSION_FULL}) set(CMAKE_C_VISIBILITY_PRESET hidden) set(CMAKE_CXX_VISIBILITY_PRESET hidden) -# A tag attached to libbson artifacts, denoting the *major* API version, used to -# potentially co-locate additional future major versions. -set (BSON_API_VERSION 1.0) - if (APPLE) cmake_policy (SET CMP0042 OLD) endif () - # .d8888b. 888 888 d8b # d88P Y88b 888 888 Y8P # Y88b. 888 888 @@ -134,13 +129,6 @@ configure_file ( "${PROJECT_BINARY_DIR}/src/bson/bson-version.h" ) -if (ENABLE_APPLE_FRAMEWORK) - configure_file ( - "${PROJECT_SOURCE_DIR}/src/bson/modules/module.modulemap.in" - "${PROJECT_BINARY_DIR}/src/bson/modules/module.modulemap" - ) -endif () - # 8888888b. .d888 d8b d8b 888 d8b # 888 "Y88b d88P" Y8P Y8P 888 Y8P # 888 888 888 888 @@ -178,13 +166,12 @@ set(bson_libs) if(ENABLE_STATIC) add_library(bson_static STATIC ${all_sources}) + add_library(bson::static ALIAS bson_static) + set_property(TARGET bson_static PROPERTY EXPORT_NAME bson::static) list(APPEND bson_libs bson_static) - # Define `BSON_STATIC` when building to suppress the annotation __declspec(dllexport). - # This prevents consumers of bson_static from exporting the symbols. - target_compile_definitions(bson_static PRIVATE BSON_STATIC) - # When consumers link against bson_static, suppress the annotation __declspec(dllimport), - # since those symbols will be available immediately at the link step: - target_compile_definitions(bson_static INTERFACE BSON_STATIC) + # Define `BSON_STATIC` to suppress __declspec(dllexport/dllimport) when compiling + # and consuming the static library + target_compile_definitions(bson_static PUBLIC BSON_STATIC) if(ENABLE_PIC) # User wants static libs to use PIC code. @@ -193,7 +180,9 @@ if(ENABLE_STATIC) endif() if(ENABLE_SHARED) - add_library(bson_shared SHARED ${all_sources}) + add_library(bson_shared SHARED ${all_sources}) + add_library(bson::shared ALIAS bson_shared) + set_property(TARGET bson_shared PROPERTY EXPORT_NAME bson::shared) if(WIN32) # Add resource-definition script for Windows shared library (.dll). configure_file(libbson.rc.in libbson.rc) @@ -235,25 +224,10 @@ mongo_target_requirements( ) set_target_properties(${bson_libs} PROPERTIES - VERSION "0.0.0" - SOVERSION "0" - OUTPUT_NAME "${BSON_OUTPUT_BASENAME}-${BSON_API_VERSION}" + VERSION "${PROJECT_VERSION}" + SOVERSION "${PROJECT_VERSION_MAJOR}" + OUTPUT_NAME "${BSON_OUTPUT_BASENAME}${PROJECT_VERSION_MAJOR}" ) -if(TARGET bson_static) - set_property(TARGET bson_static PROPERTY OUTPUT_NAME "${BSON_OUTPUT_BASENAME}-static-${BSON_API_VERSION}") -endif() - -if (ENABLE_APPLE_FRAMEWORK) - set_target_properties(bson_shared PROPERTIES - FRAMEWORK TRUE - MACOSX_FRAMEWORK_BUNDLE_VERSION ${MONGOC_VERSION} - MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${MONGOC_VERSION} - MACOSX_FRAMEWORK_IDENTIFIER org.mongodb.bson - OUTPUT_NAME "${BSON_OUTPUT_BASENAME}" - PUBLIC_HEADER "${HEADERS}" - ) -endif () - # 8888888888 888 # 888 888 @@ -310,12 +284,22 @@ endif () # ENABLE_EXAMPLES # 888 888 888 X88 Y88b. 888 888 888 888 # 8888888 888 888 88888P' "Y888 "Y888888 888 888 -set (BSON_HEADER_INSTALL_DIR - "${CMAKE_INSTALL_INCLUDEDIR}/libbson-${BSON_API_VERSION}" +# Infix directory for all libbson headers. +if(NOT DEFINED BSON_INSTALL_INCLUDEDIR) + set(BSON_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/bson-${PROJECT_VERSION}") +endif() +# Infix directory for all libbson CMake package files +if(NOT DEFINED BSON_INSTALL_CMAKEDIR) + set(BSON_INSTALL_CMAKEDIR "${MONGO_C_DRIVER_INSTALL_CMAKEDIR}/bson-${PROJECT_VERSION}") +endif() + +# pkg-config properties: +set_directory_properties(PROPERTIES + pkg_config_INCLUDE_DIRECTORIES "${BSON_INSTALL_INCLUDEDIR}" + pkg_config_NAME "bson" ) + function(install_export_target target) - # Tell pkg-config where the headers are going: - set_property(TARGET ${target} APPEND PROPERTY pkg_config_INCLUDE_DIRECTORIES "${BSON_HEADER_INSTALL_DIR}") # Install the target: install( TARGETS "${target}" @@ -324,83 +308,53 @@ function(install_export_target target) LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" - INCLUDES DESTINATION "${BSON_HEADER_INSTALL_DIR}" - FRAMEWORK DESTINATION "${CMAKE_INSTALL_BINDIR}" + INCLUDES DESTINATION "${BSON_INSTALL_INCLUDEDIR}" ) # Install the unique export set into a file that is qualified by the name of # the target itself. The main config-file package will search for the - # possibly-installed exported targets for the known targets. See: bson-config.cmake + # possibly-installed exported targets for the known targets. install( EXPORT "${target}-targets" - NAMESPACE mongo:: FILE "${target}-targets.cmake" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/bson-${BSON_API_VERSION}" + DESTINATION "${BSON_INSTALL_CMAKEDIR}" ) endfunction() if(ENABLE_STATIC_LIBBSON_INSTALL AND TARGET bson_static) install_export_target(bson_static) - mongo_generate_pkg_config(bson_static FILENAME libbson-static-1.0.pc INSTALL) + mongo_generate_pkg_config(bson_static FILENAME bson${PROJECT_VERSION_MAJOR}-static.pc INSTALL) endif() if(ENABLE_SHARED_LIBBSON_INSTALL AND TARGET bson_shared) install_export_target(bson_shared) - mongo_generate_pkg_config(bson_shared FILENAME libbson-1.0.pc INSTALL) + mongo_generate_pkg_config(bson_shared FILENAME bson${PROJECT_VERSION_MAJOR}.pc INSTALL) endif() -# Install all headers by doing a recursive directory-install. +# Install all headers by doing a recursive directory-install. In the future, this +# can be better handled by installing the headers as a file set via target_sources() install( DIRECTORY # Trailing "/" requests directory contents, not the dir itself: - src/bson/ + src/ # Also get the generated dir: - ${PROJECT_BINARY_DIR}/src/bson/ - DESTINATION "${BSON_HEADER_INSTALL_DIR}/bson" + ${PROJECT_BINARY_DIR}/src/ + DESTINATION "${BSON_INSTALL_INCLUDEDIR}" # Only grab the *public* headers. FILES_MATCHING PATTERN "*.h" PATTERN "*-private.h" EXCLUDE - # Don't generate an empty "modules" directory - PATTERN "modules" EXCLUDE + # Don't install jsonsl headers + PATTERN "jsonsl" EXCLUDE ) -if (ENABLE_APPLE_FRAMEWORK) - install ( - FILES "${PROJECT_BINARY_DIR}/src/bson/modules/module.modulemap" - DESTINATION "${CMAKE_INSTALL_BINDIR}/bson.framework/Modules/" - ) -endif () - -# Generate the config-file package -include (CMakePackageConfigHelpers) -write_basic_package_version_file ( - "${CMAKE_CURRENT_BINARY_DIR}/bson/bson-${BSON_API_VERSION}-config-version.cmake" - VERSION ${BSON_VERSION} - COMPATIBILITY AnyNewerVersion -) - -configure_file (src/bson-config.cmake - "${CMAKE_CURRENT_BINARY_DIR}/bson/bson-${BSON_API_VERSION}-config.cmake" - COPYONLY -) - -install ( - FILES - "${CMAKE_CURRENT_BINARY_DIR}/bson/bson-${BSON_API_VERSION}-config.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/bson/bson-${BSON_API_VERSION}-config-version.cmake" - DESTINATION - ${CMAKE_INSTALL_LIBDIR}/cmake/bson-${BSON_API_VERSION} - COMPONENT - Devel -) - -# Install the base targets. (Prior targets were installed above) -install (EXPORT bson-targets - NAMESPACE mongo:: - FILE bson-targets.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/bson-${BSON_API_VERSION} +# Install the platform libraries from MongoPlatform.cmake. Search: PLATFORM-EXPORT-TARGET-INSTALL +install(EXPORT mongo-platform-targets + # The "00" prefix forces the file to sort to the top during globbing, because + # we want it to be included first before the libbson targets + FILE 00-mongo-platform-targets.cmake + DESTINATION "${BSON_INSTALL_CMAKEDIR}" ) -set(bson_cmake_prefix "${MONGOC_INSTALL_CMAKEDIR}/bson-${PROJECT_VERSION}") +# Install the CMake config-mode package configure_file( ${mongo-c-driver_SOURCE_DIR}/build/cmake/packageConfigVersion.cmake.in bsonConfigVersion.cmake @@ -408,7 +362,7 @@ configure_file( ) install( FILES etc/bsonConfig.cmake "${CMAKE_CURRENT_BINARY_DIR}/bsonConfigVersion.cmake" - DESTINATION "${bson_cmake_prefix}" + DESTINATION "${BSON_INSTALL_CMAKEDIR}" ) include (CPack) @@ -432,7 +386,7 @@ if (ENABLE_MAN_PAGES OR ENABLE_HTML_DOCS) add_custom_target (bson-doc ALL DEPENDS - $<$:bson-man> - $<$:bson-html> + $ + $ ) endif () diff --git a/src/libbson/NEWS b/src/libbson/NEWS index 66c9249007b..f974b108347 100644 --- a/src/libbson/NEWS +++ b/src/libbson/NEWS @@ -24,6 +24,24 @@ libbson 2.0.0 (Unreleased) * `BSON_ERROR_BUFFER_SIZE` is reduced from `504` to `503` to reserve the final byte for internal use. * The data layout of `bson_error_t` remains otherwise unchanged: the size is still 512 bytes and the offset of the `.code`, `.domain`, and `.message` data members remain unchanged. +* The pkg-config files `libbson-1.0`, have been renamed to `bson2`, and `bson2-static`, respectively. + +### CMake Packages and Imported Targets + +The `bson-1.0` CMake package have been removed. Instead, use or `bson`, and +specify a version or version range to be imported: + +```cmake +find_package(bson 1.30...2.0) +``` + +The new package imports different target names: + +- `mongo::bson_static` → `bson::static` +- `mongo::bson_shared` → `bson::shared` +- The target `bson::bson` is a shim target that points to either the shared + library or the static library. + ## Removals diff --git a/src/libbson/etc/bsonConfig.cmake b/src/libbson/etc/bsonConfig.cmake index 7274bf39640..2655fee94e9 100644 --- a/src/libbson/etc/bsonConfig.cmake +++ b/src/libbson/etc/bsonConfig.cmake @@ -1,16 +1,15 @@ #[[ - This is a transitional CMake package config file to allow compatibility - between libbson 1.x and libbson 2.x CMake packages. + CMake package file for the BSON library. - When distributed with libbson 1.x, this file is mostly just a shim for - the `bson-1.0` CMake packages. + This file globs and includes all "*-targets.cmake" files in the containing + directory, and intends that those files define the actual libbson targets. - This file imports "bson-1.0" and generates alias targets for it: + This file also defines a `bson::bson` target, which redirects to either + `bson::static` or `bson::shared` depending on what type of library is + available and can be controlled with an import-time CMake setting. - • `bson::shared` → `mongo::bson_shared` - • `bson::static` → `mongo::bson_static` - • `bson::bson` → Points to either `bson::shared` or `bson::static`, - controlled by `BSON_DEFAULT_IMPORTED_LIBRARY_TYPE` + If the installation has a static library, it is named `bson::static`. If + the installation has a shared (dynamic) library, it is named `bson::shared`. ]] # Check for missing components before proceeding. We don't provide any, so we @@ -31,35 +30,29 @@ if(missing_required_components) endif() include(CMakeFindDependencyMacro) +find_dependency(Threads) # Required for Threads::Threads -# We are installed alongside the `bson-1.0` packages. Forcibly prevent find_package -# from considering any other `bson-1.0` package that might live elsewhere on the system -# by setting HINTS and NO_DEFAULT_PATH -get_filename_component(parent_dir "${CMAKE_CURRENT_LIST_DIR}" DIRECTORY) -find_dependency(bson-1.0 HINTS ${parent_dir} NO_DEFAULT_PATH) +# Import the target files that will be installed alongside this file. Only the +# targets of libraries that were actually installed alongside this file will be imported +file(GLOB __targets_files "${CMAKE_CURRENT_LIST_DIR}/*-targets.cmake") +foreach(__file IN LISTS __targets_files) + include("${__file}") +endforeach() # The library type that is linked with `bson::bson` -set(_default_lib_type) -# Add compat targets for the bson-1.0 package targets -if(TARGET mongo::bson_shared AND NOT TARGET bson::shared) - add_library(bson::shared IMPORTED INTERFACE) - set_property(TARGET bson::shared APPEND PROPERTY INTERFACE_LINK_LIBRARIES mongo::bson_shared) - set(_default_lib_type SHARED) -endif() -if(TARGET mongo::bson_static AND NOT TARGET bson::static) - add_library(bson::static IMPORTED INTERFACE) - set_property(TARGET bson::static APPEND PROPERTY INTERFACE_LINK_LIBRARIES mongo::bson_static) +set(__default_lib_type SHARED) +if(TARGET bson::static) # If static is available, set it as the default library type - set(_default_lib_type STATIC) + set(__default_lib_type STATIC) endif() # Allow the user to tweak what library type is linked for `bson::bson` -set(BSON_DEFAULT_IMPORTED_LIBRARY_TYPE "${_default_lib_type}" +set(BSON_DEFAULT_IMPORTED_LIBRARY_TYPE "${__default_lib_type}" CACHE STRING "The default library type that is used when linking against 'bson::bson' (either SHARED or STATIC, requires that the package was built with the appropriate library type)") set_property(CACHE BSON_DEFAULT_IMPORTED_LIBRARY_TYPE PROPERTY STRINGS SHARED STATIC) if(NOT TARGET bson::bson) # Don't redefine the target if we were already included - string(TOLOWER "${BSON_DEFAULT_IMPORTED_LIBRARY_TYPE}" _type) + string(TOLOWER "${BSON_DEFAULT_IMPORTED_LIBRARY_TYPE}" __type) add_library(bson::bson IMPORTED INTERFACE) - set_property(TARGET bson::bson APPEND PROPERTY INTERFACE_LINK_LIBRARIES bson::${_type}) + set_property(TARGET bson::bson APPEND PROPERTY INTERFACE_LINK_LIBRARIES bson::${__type}) endif() diff --git a/src/libbson/examples/compile-with-pkg-config-static.sh b/src/libbson/examples/compile-with-pkg-config-static.sh index 9a6142a5f7b..dd84504415c 100755 --- a/src/libbson/examples/compile-with-pkg-config-static.sh +++ b/src/libbson/examples/compile-with-pkg-config-static.sh @@ -3,4 +3,4 @@ set -o errexit # Exit the script with error if any of the commands fail # -- sphinx-include-start -- -gcc -o hello_bson hello_bson.c $(pkg-config --libs --cflags libbson-static-1.0) +gcc -o hello_bson hello_bson.c $(pkg-config --libs --cflags bson$major-static) diff --git a/src/libbson/examples/compile-with-pkg-config.sh b/src/libbson/examples/compile-with-pkg-config.sh index c1df9646f4b..9e4ed5239cc 100755 --- a/src/libbson/examples/compile-with-pkg-config.sh +++ b/src/libbson/examples/compile-with-pkg-config.sh @@ -3,4 +3,4 @@ set -o errexit # Exit the script with error if any of the commands fail # -- sphinx-include-start -- -gcc -o hello_bson hello_bson.c $(pkg-config --libs --cflags libbson-1.0) +gcc -o hello_bson hello_bson.c $(pkg-config --libs --cflags bson$major) diff --git a/src/libbson/libbson.rc.in b/src/libbson/libbson.rc.in index 47afe6f140b..9015243d19d 100644 --- a/src/libbson/libbson.rc.in +++ b/src/libbson/libbson.rc.in @@ -5,7 +5,6 @@ #include // Defines BSON_MAJOR_VERSION and other version macros. #define BSON_OUTPUT_BASENAME "@BSON_OUTPUT_BASENAME@" -#define BSON_API_VERSION "@BSON_API_VERSION@" VS_VERSION_INFO VERSIONINFO FILEVERSION BSON_MAJOR_VERSION,BSON_MINOR_VERSION,BSON_MICRO_VERSION,0 @@ -30,8 +29,8 @@ BEGIN VALUE "CompanyName", "MongoDB, Inc" VALUE "FileDescription", "A BSON Library for C" VALUE "FileVersion", BSON_VERSION_S - VALUE "InternalName", BSON_OUTPUT_BASENAME "-" BSON_API_VERSION - VALUE "OriginalFilename", BSON_OUTPUT_BASENAME "-" BSON_API_VERSION ".dll" + VALUE "InternalName", BSON_OUTPUT_BASENAME "@PROJECT_VERSION_MAJOR@" + VALUE "OriginalFilename", BSON_OUTPUT_BASENAME "@PROJECT_VERSION_MAJOR@.dll" VALUE "ProductName", "MongoDB C Driver" VALUE "ProductVersion", BSON_VERSION_S VALUE "LegalCopyright", "Copyright 2009-present MongoDB, Inc." diff --git a/src/libbson/src/bson-config.cmake b/src/libbson/src/bson-config.cmake deleted file mode 100644 index 388681f3002..00000000000 --- a/src/libbson/src/bson-config.cmake +++ /dev/null @@ -1,13 +0,0 @@ -include(CMakeFindDependencyMacro) -find_dependency(Threads) # Required for Threads::Threads - -# Import common targets first: -include("${CMAKE_CURRENT_LIST_DIR}/bson-targets.cmake") - -# Now import the targets of each link-kind that's available. Only the targets of -# libbson libraries that were actually installed alongside this file will be -# imported. -file(GLOB target_files "${CMAKE_CURRENT_LIST_DIR}/bson_*-targets.cmake") -foreach(inc IN LISTS target_files) - include("${inc}") -endforeach() diff --git a/src/libbson/src/bson/modules/module.modulemap.in b/src/libbson/src/bson/modules/module.modulemap.in deleted file mode 100644 index 1a8a5ebe0ce..00000000000 --- a/src/libbson/src/bson/modules/module.modulemap.in +++ /dev/null @@ -1,5 +0,0 @@ -framework module bson [system] { - umbrella header "bson/bson.h" - - export * -} \ No newline at end of file diff --git a/src/libmongoc/.gitignore b/src/libmongoc/.gitignore index 8bf24d3d513..4e6886c8f32 100644 --- a/src/libmongoc/.gitignore +++ b/src/libmongoc/.gitignore @@ -33,7 +33,7 @@ find-and-modify hello_mongoc mongoc-dump mongoc-ping -mongoc-stat +mongoc2-stat mongoc-tail # Test binaries diff --git a/src/libmongoc/CMakeLists.txt b/src/libmongoc/CMakeLists.txt index 9369c1cefe9..bfa3a205e3f 100644 --- a/src/libmongoc/CMakeLists.txt +++ b/src/libmongoc/CMakeLists.txt @@ -12,8 +12,6 @@ project (libmongoc set(libmongoc_VERSION_PRERELEASE ${mongo-c-driver_VERSION_PRERELEASE}) set(libmongoc_VERSION_FULL ${mongo-c-driver_VERSION_FULL}) -set (MONGOC_API_VERSION 1.0) - include (CheckSchedGetCPU) include (CheckStructHasMember) include (CheckSymbolExists) @@ -23,15 +21,19 @@ include (InstallRequiredSystemLibraries) message (STATUS "libmongoc version (from VERSION_CURRENT file): ${MONGOC_VERSION}") -set (MONGOC_API_VERSION 1.0) -set (MONGOC_TARGETS_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/mongoc-${MONGOC_API_VERSION}") - # Defaults. set (MONGOC_ENABLE_COMPRESSION 0) set (MONGOC_ENABLE_COMPRESSION_SNAPPY 0) set (MONGOC_ENABLE_COMPRESSION_ZLIB 0) set (MONGOC_ENABLE_COMPRESSION_ZSTD 0) +if(NOT DEFINED MONGOC_INSTALL_INCLUDEDIR) + set(MONGOC_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/mongoc-${PROJECT_VERSION}") +endif() +if(NOT DEFINED MONGOC_INSTALL_CMAKEDIR) + set(MONGOC_INSTALL_CMAKEDIR "${MONGO_C_DRIVER_INSTALL_CMAKEDIR}/mongoc-${PROJECT_VERSION}") +endif() + # Definition for mongoc-config.h: mongo_pick(MONGOC_ENABLE_SRV 1 0 ENABLE_SRV) @@ -341,7 +343,7 @@ function(_use_sasl libname) elseif(libname STREQUAL "CYRUS") find_package(SASL2 2.0 REQUIRED) target_link_libraries(_mongoc-sasl_backend INTERFACE SASL2::SASL2) - install(FILES "${mongo-c-driver_SOURCE_DIR}/build/cmake/FindSASL2.cmake" DESTINATION "${MONGOC_TARGETS_INSTALL_DIR}/3rdParty") + install(FILES "${mongo-c-driver_SOURCE_DIR}/build/cmake/FindSASL2.cmake" DESTINATION "${MONGOC_INSTALL_CMAKEDIR}/3rdParty") set(backend "Cyrus") else() message(FATAL_ERROR "Unknown SASL backend “${libname}”") @@ -752,13 +754,6 @@ configure_file ( "${PROJECT_BINARY_DIR}/src/mongoc/mongoc-version.h" ) -if (ENABLE_APPLE_FRAMEWORK) - configure_file ( - "${PROJECT_SOURCE_DIR}/src/mongoc/modules/module.modulemap.in" - "${PROJECT_BINARY_DIR}/src/mongoc/modules/module.modulemap" - ) -endif () - set (LIBRARIES ${SNAPPY_LIBRARIES} ${ZLIB_LIBRARIES} ${MONGOC_ZSTD_LIBRARIES} ${LIBMONGOCRYPT_LIBRARY} ) @@ -834,14 +829,13 @@ if (MONGOC_ENABLE_MONGODB_AWS_AUTH) endif() endif () -if (MONGOC_ENABLE_STATIC_BUILD) +if (TARGET bson::static) add_library (mcd_rpc STATIC EXCLUDE_FROM_ALL ${PROJECT_SOURCE_DIR}/src/mongoc/mcd-rpc.c) target_include_directories (mcd_rpc PUBLIC ${PROJECT_SOURCE_DIR}/src) - target_link_libraries (mcd_rpc PUBLIC ${BSON_STATIC_LIBRARIES}) + target_link_libraries (mcd_rpc PUBLIC bson::static) if (NOT WIN32 AND ENABLE_PIC) target_compile_options (mcd_rpc PUBLIC -fPIC) endif () - target_compile_definitions (mcd_rpc PUBLIC ${BSON_STATIC_PUBLIC_DEFINITIONS}) set_target_properties (mcd_rpc PROPERTIES OUTPUT_NAME "mcd-rpc") endif () @@ -852,13 +846,15 @@ set ( if (ENABLE_SHARED) add_library (mongoc_shared SHARED ${SOURCES} ${HEADERS}) + add_library(mongoc::shared ALIAS mongoc_shared) + set_property(TARGET mongoc_shared PROPERTY EXPORT_NAME mongoc::shared) if(WIN32) # Add resource-definition script for Windows shared library (.dll). configure_file(libmongoc.rc.in libmongoc.rc) target_sources(mongoc_shared PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/libmongoc.rc) endif() set_target_properties (mongoc_shared PROPERTIES CMAKE_CXX_VISIBILITY_PRESET hidden) - target_link_libraries (mongoc_shared PRIVATE ${LIBRARIES} PUBLIC ${BSON_LIBRARIES} mongo::detail::c_dependencies) + target_link_libraries (mongoc_shared PRIVATE ${LIBRARIES} PUBLIC bson::shared mongo::detail::c_dependencies) target_include_directories (mongoc_shared PRIVATE ${ZLIB_INCLUDE_DIRS}) target_include_directories (mongoc_shared PRIVATE ${UTF8PROC_INCLUDE_DIRS}) target_include_directories (mongoc_shared PRIVATE ${LIBMONGOCRYPT_INCLUDE_DIRECTORIES}) @@ -896,27 +892,17 @@ if (ENABLE_SHARED) ) set_target_properties (mongoc_shared PROPERTIES - OUTPUT_NAME "${MONGOC_OUTPUT_BASENAME}-${MONGOC_API_VERSION}" - VERSION 0.0.0 - SOVERSION 0 - pkg_config_REQUIRES "libbson-1.0" - ) - mongo_generate_pkg_config(mongoc_shared INSTALL RENAME libmongoc-${MONGOC_API_VERSION}.pc) - - if (ENABLE_APPLE_FRAMEWORK) - set_target_properties (mongoc_shared PROPERTIES - FRAMEWORK TRUE - MACOSX_FRAMEWORK_BUNDLE_VERSION ${MONGOC_VERSION} - MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${MONGOC_VERSION} - MACOSX_FRAMEWORK_IDENTIFIER org.mongodb.mongoc - OUTPUT_NAME "${MONGOC_OUTPUT_BASENAME}" - PUBLIC_HEADER "${HEADERS}" + OUTPUT_NAME "${MONGOC_OUTPUT_BASENAME}${PROJECT_VERSION_MAJOR}" + VERSION "${PROJECT_VERSION}" + SOVERSION "${PROJECT_VERSION_MAJOR}" + pkg_config_REQUIRES "bson${PROJECT_VERSION_MAJOR}" ) - endif () # ENABLE_APPLE_FRAMEWORK + mongo_generate_pkg_config(mongoc_shared INSTALL RENAME mongoc${PROJECT_VERSION_MAJOR}.pc) add_executable (mongoc-stat ${mongo-c-driver_SOURCE_DIR}/src/tools/mongoc-stat.c) target_compile_options (mongoc-stat PRIVATE ${mongoc-warning-options}) target_link_libraries (mongoc-stat mongoc_shared ${LIBRARIES}) + set_property (TARGET mongoc-stat PROPERTY OUTPUT_NAME mongoc${PROJECT_VERSION_MAJOR}-stat) # mongoc-stat works if shared memory performance counters are enabled. if (ENABLE_SHM_COUNTERS) @@ -929,7 +915,9 @@ endif () # ENABLE_SHARED if (MONGOC_ENABLE_STATIC_BUILD) add_library (mongoc_static STATIC ${SOURCES} ${HEADERS}) - target_link_libraries (mongoc_static PUBLIC ${STATIC_LIBRARIES} ${BSON_STATIC_LIBRARIES} mongo::detail::c_dependencies) + add_library(mongoc::static ALIAS mongoc_static) + set_property(TARGET mongoc_static PROPERTY EXPORT_NAME mongoc::static) + target_link_libraries (mongoc_static PUBLIC ${STATIC_LIBRARIES} bson::static mongo::detail::c_dependencies) if (NOT WIN32 AND ENABLE_PIC) target_compile_options (mongoc_static PUBLIC -fPIC) message (STATUS "Adding -fPIC to compilation of mongoc_static components") @@ -953,7 +941,6 @@ if (MONGOC_ENABLE_STATIC_BUILD) target_compile_definitions (mongoc_static PUBLIC MONGOC_STATIC - ${BSON_STATIC_PUBLIC_DEFINITIONS} PRIVATE MONGOC_COMPILATION ${KMS_MSG_DEFINITIONS} @@ -974,12 +961,12 @@ if (MONGOC_ENABLE_STATIC_BUILD) $ ) set_target_properties (mongoc_static PROPERTIES - VERSION 0.0.0 - OUTPUT_NAME "${MONGOC_OUTPUT_BASENAME}-static-${MONGOC_API_VERSION}" - pkg_config_REQUIRES "libbson-static-1.0" + VERSION "${PROJECT_VERSION}" + OUTPUT_NAME "${MONGOC_OUTPUT_BASENAME}${PROJECT_VERSION_MAJOR}" + pkg_config_REQUIRES "bson${PROJECT_VERSION_MAJOR}-static" ) if(MONGOC_ENABLE_STATIC_INSTALL) - mongo_generate_pkg_config (mongoc_static FILENAME libmongoc-static-${MONGOC_API_VERSION}.pc INSTALL) + mongo_generate_pkg_config (mongoc_static FILENAME mongoc${PROJECT_VERSION_MAJOR}-static.pc INSTALL) endif() endif () @@ -1151,7 +1138,7 @@ if (ENABLE_TESTS) # Remove once support for VS 2013 is dropped. target_compile_options(test-libmongoc-lib PRIVATE /wd4756) endif () - target_link_libraries (test-libmongoc-lib PUBLIC mongoc_static) + target_link_libraries (test-libmongoc-lib PUBLIC mongoc::static) # We have tests that test our deprecated api. target_compile_options (test-libmongoc-lib PRIVATE $<$>:-Wno-deprecated-declarations> @@ -1161,7 +1148,6 @@ if (ENABLE_TESTS) target_include_directories (test-libmongoc-lib PRIVATE ${PROJECT_SOURCE_DIR}/tests - ${BSON_STATIC_INCLUDE_DIRS} ${UTHASH_INCLUDE_DIR} ) target_compile_definitions (test-libmongoc-lib @@ -1189,7 +1175,6 @@ if (ENABLE_TESTS) target_include_directories (${test} PRIVATE ${PROJECT_SOURCE_DIR}/tests - ${BSON_STATIC_INCLUDE_DIRS} ) target_compile_definitions (${test} PUBLIC @@ -1226,9 +1211,9 @@ if (ENABLE_EXAMPLES AND ENABLE_SHARED) # Enable unconditional warnings-as-errors for our source code. target_compile_options (${example} PRIVATE ${mongoc-warning-options}) - target_link_libraries (${example} mongoc_shared ${LIBRARIES}) + target_link_libraries (${example} PRIVATE mongoc::shared ${LIBRARIES}) if (WIN32) - target_link_libraries (${example} shlwapi) + target_link_libraries (${example} PRIVATE shlwapi) endif () endfunction () @@ -1302,7 +1287,7 @@ if (ENABLE_TESTS AND ENABLE_SHARED AND MONGOC_ENABLE_SSL AND NOT WIN32) # Benchmarks require SSL, and do not build on Windows. add_executable (benchmark-tls-pooled ${PROJECT_SOURCE_DIR}/tests/benchmark-tls-pooled.c) target_compile_options (benchmark-tls-pooled PRIVATE ${mongoc-warning-options}) - target_link_libraries (benchmark-tls-pooled mongoc_shared ${LIBRARIES}) + target_link_libraries (benchmark-tls-pooled PRIVATE mongoc::shared ${LIBRARIES}) endif () file (COPY ${PROJECT_SOURCE_DIR}/tests/binary DESTINATION ${PROJECT_BINARY_DIR}/tests) @@ -1320,9 +1305,7 @@ if (ENABLE_SHARED) list (APPEND TARGETS_TO_INSTALL mongoc_shared) endif () -set (MONGOC_HEADER_INSTALL_DIR - "${CMAKE_INSTALL_INCLUDEDIR}/libmongoc-${MONGOC_API_VERSION}" -) + install ( TARGETS ${TARGETS_TO_INSTALL} @@ -1330,22 +1313,14 @@ install ( LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - INCLUDES DESTINATION ${MONGOC_HEADER_INSTALL_DIR} - FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR} + INCLUDES DESTINATION ${MONGOC_INSTALL_INCLUDEDIR} ) install ( FILES ${HEADERS} - DESTINATION "${MONGOC_HEADER_INSTALL_DIR}/mongoc" + DESTINATION "${MONGOC_INSTALL_INCLUDEDIR}/mongoc" ) -if (ENABLE_APPLE_FRAMEWORK) - install ( - FILES "${PROJECT_BINARY_DIR}/src/mongoc/modules/module.modulemap" - DESTINATION "${CMAKE_INSTALL_BINDIR}/mongoc.framework/Modules/" - ) -endif () - # Collect link items for the static library to be inserted into the pkg-config if(TARGET mongoc_static) set(link_options ${ZLIB_LIBRARIES} @@ -1363,67 +1338,36 @@ if(TARGET mongoc_static) endif() # Relative include-path will be given the install prefix: -set_property(TARGET ${TARGETS_TO_INSTALL} APPEND PROPERTY pkg_config_INCLUDE_DIRECTORIES "${MONGOC_HEADER_INSTALL_DIR}") - -# Deprecated alias for libmongoc-1.0.pc, see CDRIVER-2086. -if (MONGOC_ENABLE_SSL) - configure_file ( - ${CMAKE_CURRENT_SOURCE_DIR}/src/libmongoc-ssl-1.0.pc.in - ${CMAKE_CURRENT_BINARY_DIR}/src/libmongoc-ssl-1.0.pc - @ONLY) - install ( - FILES ${CMAKE_CURRENT_BINARY_DIR}/src/libmongoc-ssl-1.0.pc - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig - ) -endif () - -include (CMakePackageConfigHelpers) - -write_basic_package_version_file ( - "${CMAKE_CURRENT_BINARY_DIR}/mongoc/mongoc-${MONGOC_API_VERSION}-config-version.cmake" - VERSION ${MONGOC_VERSION} - COMPATIBILITY AnyNewerVersion -) - -configure_file (src/mongoc-config.cmake - "${CMAKE_CURRENT_BINARY_DIR}/mongoc/mongoc-${MONGOC_API_VERSION}-config.cmake" - @ONLY -) +set_property(TARGET ${TARGETS_TO_INSTALL} APPEND PROPERTY pkg_config_INCLUDE_DIRECTORIES "${MONGOC_INSTALL_INCLUDEDIR}") install (EXPORT mongoc-targets - NAMESPACE mongo:: FILE mongoc-targets.cmake - DESTINATION ${MONGOC_TARGETS_INSTALL_DIR} -) - -install ( - FILES - "${CMAKE_CURRENT_BINARY_DIR}/mongoc/mongoc-${MONGOC_API_VERSION}-config.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/mongoc/mongoc-${MONGOC_API_VERSION}-config-version.cmake" - DESTINATION - ${MONGOC_TARGETS_INSTALL_DIR} - COMPONENT - Devel + DESTINATION "${MONGOC_INSTALL_CMAKEDIR}" ) -set(mongoc_cmake_prefix "${MONGOC_INSTALL_CMAKEDIR}/mongoc-${PROJECT_VERSION}") configure_file( ${mongo-c-driver_SOURCE_DIR}/build/cmake/packageConfigVersion.cmake.in mongocConfigVersion.cmake @ONLY ) +configure_file( + etc/mongocConfig.cmake.in + mongocConfig.cmake + @ONLY +) install( - FILES etc/mongocConfig.cmake "${CMAKE_CURRENT_BINARY_DIR}/mongocConfigVersion.cmake" - DESTINATION "${mongoc_cmake_prefix}" + FILES "${CMAKE_CURRENT_BINARY_DIR}/mongocConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/mongocConfigVersion.cmake" + DESTINATION "${MONGOC_INSTALL_CMAKEDIR}" ) -if (ENABLE_MAN_PAGES STREQUAL ON OR ENABLE_HTML_DOCS STREQUAL ON) +if (ENABLE_MAN_PAGES OR ENABLE_HTML_DOCS) find_package (Sphinx REQUIRED) add_subdirectory (doc) add_custom_target (mongoc-doc ALL DEPENDS - $<$:mongoc-man> - $<$:mongoc-html> + $ + $ ) endif () diff --git a/src/libmongoc/etc/mongocConfig.cmake b/src/libmongoc/etc/mongocConfig.cmake deleted file mode 100644 index e3ebf1b4224..00000000000 --- a/src/libmongoc/etc/mongocConfig.cmake +++ /dev/null @@ -1,67 +0,0 @@ -#[[ - This is a transitional CMake package config file to allow compatibility - between libmongoc 1.x and libmongoc 2.x CMake packages. - - When distributed with libmongoc 1.x, this file is mostly just a shim for - the `mongoc-1.0` CMake packages. - - This file imports "mongoc-1.0" and generates alias targets for it: - - • `mongoc::shared` → `mongo::mongoc_shared` - • `mongoc::static` → `mongo::mongoc_static` - • `mongoc::mongoc` → Points to either `mongoc::shared` or `mongoc::static`, - controlled by `MONGOC_DEFAULT_IMPORTED_LIBRARY_TYPE` -]] - -# Check for missing components before proceeding. We don't provide any, so we -# should generate an error if the caller requests any *required* components. -set(missing_required_components) -foreach(comp IN LISTS mongoc_FIND_COMPONENTS) - if(mongoc_FIND_REQUIRED_${comp}) - list(APPEND missing_required_components "${comp}") - endif() -endforeach() - -if(missing_required_components) - list(JOIN missing_required_components ", " components) - set(mongoc_FOUND FALSE) - set(mongoc_NOT_FOUND_MESSAGE "The package version is compatible, but is missing required components: ${components}") - # Stop now. Don't generate any imported targets - return() -endif() - -include(CMakeFindDependencyMacro) - -# We are installed alongside the `mongoc-1.0` packages. Forcibly prevent find_package -# from considering any other `mongoc-1.0` package that might live elsewhere on the system -# by setting HINTS and NO_DEFAULT_PATH -get_filename_component(parent_dir "${CMAKE_CURRENT_LIST_DIR}" DIRECTORY) -find_dependency(mongoc-1.0 HINTS ${parent_dir} NO_DEFAULT_PATH) -# Also import the `bson` package, to ensure its targets are also available -find_dependency(bson ${mongoc_FIND_VERSION} HINTS ${parent_dir} NO_DEFAULT_PATH) - -# The library type that is linked with `mongoc::mongoc` -set(_default_lib_type) -# Add compat targets for the mongoc-1.0 package targets -if(TARGET mongo::mongoc_shared AND NOT TARGET mongoc::shared) - add_library(mongoc::shared IMPORTED INTERFACE) - set_property(TARGET mongoc::shared APPEND PROPERTY INTERFACE_LINK_LIBRARIES mongo::mongoc_shared) - set(_default_lib_type SHARED) -endif() -if(TARGET mongo::mongoc_static AND NOT TARGET mongoc::static) - add_library(mongoc::static IMPORTED INTERFACE) - set_property(TARGET mongoc::static APPEND PROPERTY INTERFACE_LINK_LIBRARIES mongo::mongoc_static) - # If static is available, set it as the default library type - set(_default_lib_type STATIC) -endif() - -# Allow the user to tweak what library type is linked for `mongoc::mongoc` -set(MONGOC_DEFAULT_IMPORTED_LIBRARY_TYPE "${_default_lib_type}" - CACHE STRING "The default library type that is used when linking against 'mongoc::mongoc' (either SHARED or STATIC, requires that the package was built with the appropriate library type)") -set_property(CACHE MONGOC_DEFAULT_IMPORTED_LIBRARY_TYPE PROPERTY STRINGS SHARED STATIC) - -if(NOT TARGET mongoc::mongoc) # Don't redefine the target if we were already included - string(TOLOWER "${MONGOC_DEFAULT_IMPORTED_LIBRARY_TYPE}" _type) - add_library(mongoc::mongoc IMPORTED INTERFACE) - set_property(TARGET mongoc::mongoc APPEND PROPERTY INTERFACE_LINK_LIBRARIES mongoc::${_type}) -endif() diff --git a/src/libmongoc/etc/mongocConfig.cmake.in b/src/libmongoc/etc/mongocConfig.cmake.in new file mode 100644 index 00000000000..14d7e4c7edc --- /dev/null +++ b/src/libmongoc/etc/mongocConfig.cmake.in @@ -0,0 +1,112 @@ +#[[ + CMake package file for the mongoc library. + + This file globs and includes all "*-targets.cmake" files in the containing + directory, and intends that those files define the actual mongoc targets. + + This file also defines a `mongoc::mongoc` target, which redirects to either + `mongoc::static` or `mongoc::shared` depending on what type of library is + available and can be controlled with an import-time CMake setting. + + If the installation has a static library, it is named `mongoc::static`. If + the installation has a shared (dynamic) library, it is named `mongoc::shared`. +]] + +# The version of the mongoc package (comes from the project() call in the orginal project) +set(__mongoc_package_version [[@PROJECT_VERSION@]]) +set(__mongoc_sasl_backend [[@SASL_BACKEND@]]) +set(__mongoc_tls_package [[@TLS_IMPORT_PACKAGE@]]) +set(__mongoc_uses_bundled_utf8proc "@USE_BUNDLED_UTF8PROC@") +# Announce this one as a public var: +set(MONGOC_TLS_BACKEND [[@TLS_BACKEND@]]) + +# Check for missing components before proceeding. We don't provide any, so we +# should generate an error if the caller requests any *required* components. +set(missing_required_components) +foreach(comp IN LISTS mongoc_FIND_COMPONENTS) + if(mongoc_FIND_REQUIRED_${comp}) + list(APPEND missing_required_components "${comp}") + endif() +endforeach() + +if(missing_required_components) + list(JOIN missing_required_components ", " components) + set(mongoc_FOUND FALSE) + set(mongoc_NOT_FOUND_MESSAGE "The package version is compatible, but is missing required components: ${components}") + # Stop now. Don't generate any imported targets + return() +endif() + +# d8888b. d88888b d8888b. d88888b d8b db d8888b. d88888b d8b db .o88b. d888888b d88888b .d8888. +# 88 `8D 88' 88 `8D 88' 888o 88 88 `8D 88' 888o 88 d8P Y8 `88' 88' 88' YP +# 88 88 88ooooo 88oodD' 88ooooo 88V8o 88 88 88 88ooooo 88V8o 88 8P 88 88ooooo `8bo. +# 88 88 88~~~~~ 88~~~ 88~~~~~ 88 V8o88 88 88 88~~~~~ 88 V8o88 8b 88 88~~~~~ `Y8b. +# 88 .8D 88. 88 88. 88 V888 88 .8D 88. 88 V888 Y8b d8 .88. 88. db 8D +# Y8888D' Y88888P 88 Y88888P VP V8P Y8888D' Y88888P VP V8P `Y88P' Y888888P Y88888P `8888Y' +# Import dependencies +include(CMakeFindDependencyMacro) +get_filename_component(__parent_dir "${CMAKE_CURRENT_LIST_DIR}" DIRECTORY) +# Also import the `bson` package, to ensure its targets are also available +find_dependency(bson "${__mongoc_package_version}" HINTS ${__parent_dir}) + +# QUIET arg for finding dependencies: +unset(__quiet) +if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) + set(__quiet QUIET) +endif() + +# Find libutf8proc (if we linked to an external library) +if(NOT __mongoc_uses_bundled_utf8proc AND NOT TARGET PkgConfig::PC_UTF8PROC) + # libmongoc was compiled against an external utf8proc and links against a + # FindPkgConfig-generated IMPORTED target. Find that package and generate that + # imported target here: + find_dependency(PkgConfig) + pkg_check_modules(PC_UTF8PROC ${__quiet} libutf8proc IMPORTED_TARGET GLOBAL) + if(NOT PC_UTF8PROC_FOUND) + # Handle if it wasn't found (find_dependency would usually do this for us, + # but pkg_check_modules() does not) + set(mongoc_FOUND FALSE) + set(mongoc_NOT_FOUND_MESSAGE "We were unable to find the required libutf8proc package with pkg-config") + return() + endif() +endif() + +# If we need to import a TLS package for our imported targets, do that now: +if(__mongoc_tls_package) + find_dependency("${__mongoc_tls_package}") +endif() + +# Find dependencies for SASL +if(__mongoc_sasl_backend STREQUAL "Cyrus") + # We need libsasl2. The find-module should be installed within this package. + # temporarily place it on the module search path: + set(__prev_path "${CMAKE_MODULE_PATH}") + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/3rdParty") + find_dependency(SASL2 2.0) + set(CMAKE_MODULE_PATH "${__prev_path}") +endif() + +# Import the target files that will be installed alongside this file. Only the +# targets of libraries that were actually installed alongside this file will be imported +file(GLOB __targets_files "${CMAKE_CURRENT_LIST_DIR}/*-targets.cmake") +foreach(__file IN LISTS __targets_files) + include("${__file}") +endforeach() + +# The library type that is linked with `mongoc::mongoc` +set(__default_lib_type SHARED) +if(TARGET mongoc::static) + # If static is available, set it as the default library type + set(__default_lib_type STATIC) +endif() + +# Allow the user to tweak what library type is linked for `mongoc::mongoc` +set(MONGOC_DEFAULT_IMPORTED_LIBRARY_TYPE "${__default_lib_type}" + CACHE STRING "The default library type that is used when linking against 'mongoc::mongoc' (either SHARED or STATIC, requires that the package was built with the appropriate library type)") +set_property(CACHE MONGOC_DEFAULT_IMPORTED_LIBRARY_TYPE PROPERTY STRINGS SHARED STATIC) + +if(NOT TARGET mongoc::mongoc) # Don't redefine the target if we were already included + string(TOLOWER "${MONGOC_DEFAULT_IMPORTED_LIBRARY_TYPE}" __type) + add_library(mongoc::mongoc IMPORTED INTERFACE) + set_property(TARGET mongoc::mongoc APPEND PROPERTY INTERFACE_LINK_LIBRARIES mongoc::${__type}) +endif() diff --git a/src/libmongoc/examples/compile-with-pkg-config-static.sh b/src/libmongoc/examples/compile-with-pkg-config-static.sh index 58d3db7a057..e8d86aa0386 100755 --- a/src/libmongoc/examples/compile-with-pkg-config-static.sh +++ b/src/libmongoc/examples/compile-with-pkg-config-static.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash # -- sphinx-include-start -- -gcc -o hello_mongoc hello_mongoc.c $(pkg-config --libs --cflags libmongoc-static-1.0) +gcc -o hello_mongoc hello_mongoc.c $(pkg-config --libs --cflags mongoc$major-static) diff --git a/src/libmongoc/examples/compile-with-pkg-config.sh b/src/libmongoc/examples/compile-with-pkg-config.sh index ba0d5a284c5..b7f55b3831e 100755 --- a/src/libmongoc/examples/compile-with-pkg-config.sh +++ b/src/libmongoc/examples/compile-with-pkg-config.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash # -- sphinx-include-start -- -gcc -o hello_mongoc hello_mongoc.c $(pkg-config --libs --cflags libmongoc-1.0) +gcc -o hello_mongoc hello_mongoc.c $(pkg-config --libs --cflags mongoc$major) diff --git a/src/libmongoc/libmongoc.rc.in b/src/libmongoc/libmongoc.rc.in index 6b9f3ea887f..eff9817b179 100644 --- a/src/libmongoc/libmongoc.rc.in +++ b/src/libmongoc/libmongoc.rc.in @@ -5,7 +5,6 @@ #include // Defines MONGOC_MAJOR_VERSION and other version macros. #define MONGOC_OUTPUT_BASENAME "@MONGOC_OUTPUT_BASENAME@" -#define MONGOC_API_VERSION "@MONGOC_API_VERSION@" VS_VERSION_INFO VERSIONINFO FILEVERSION MONGOC_MAJOR_VERSION,MONGOC_MINOR_VERSION,MONGOC_MICRO_VERSION,0 @@ -30,8 +29,8 @@ BEGIN VALUE "CompanyName", "MongoDB, Inc" VALUE "FileDescription", "MongoDB Client Library for C" VALUE "FileVersion", MONGOC_VERSION_S - VALUE "InternalName", MONGOC_OUTPUT_BASENAME "-" MONGOC_API_VERSION - VALUE "OriginalFilename", MONGOC_OUTPUT_BASENAME "-" MONGOC_API_VERSION ".dll" + VALUE "InternalName", MONGOC_OUTPUT_BASENAME "@PROJECT_VERSION_MAJOR@" + VALUE "OriginalFilename", MONGOC_OUTPUT_BASENAME "@PROJECT_VERSION_MAJOR@.dll" VALUE "ProductName", "MongoDB C Driver" VALUE "ProductVersion", MONGOC_VERSION_S VALUE "LegalCopyright", "Copyright 2009-present MongoDB, Inc." diff --git a/src/libmongoc/src/libmongoc-ssl-1.0.pc.in b/src/libmongoc/src/libmongoc-ssl-1.0.pc.in deleted file mode 100644 index d29b11014e8..00000000000 --- a/src/libmongoc/src/libmongoc-ssl-1.0.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=${prefix} -libdir=@libdir@ -includedir=${exec_prefix}/include - -Name: libmongoc-@MONGOC_API_VERSION@ -Description: SSL support for the libmongoc-@MONGOC_API_VERSION@ library. -Version: @MONGOC_VERSION@ -Requires: libmongoc-1.0 -Libs: -Cflags: diff --git a/src/libmongoc/src/mongoc-config.cmake b/src/libmongoc/src/mongoc-config.cmake deleted file mode 100644 index 8aa000ba285..00000000000 --- a/src/libmongoc/src/mongoc-config.cmake +++ /dev/null @@ -1,40 +0,0 @@ -include(CMakeFindDependencyMacro) -find_dependency(bson-1.0 @libmongoc_VERSION@) - -# If we need to import a TLS package for our imported targets, do that now: -set(MONGOC_TLS_BACKEND [[@TLS_BACKEND@]]) -set(_tls_package [[@TLS_IMPORT_PACKAGE@]]) -if(_tls_package) - find_dependency("${_tls_package}") -endif() - -include("${CMAKE_CURRENT_LIST_DIR}/mongoc-targets.cmake") - -unset(_required) -unset(_quiet) -if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED) - set(_required REQUIRED) -endif() -if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) - set(_quiet QUIET) -endif() - -set(_mongoc_built_with_bundled_utf8proc "@USE_BUNDLED_UTF8PROC@") -if(NOT _mongoc_built_with_bundled_utf8proc AND NOT TARGET PkgConfig::PC_UTF8PROC) - # libmongoc was compiled against an external utf8proc and links against a - # FindPkgConfig-generated IMPORTED target. Find that package and generate that - # imported target here: - find_dependency(PkgConfig) - pkg_check_modules(PC_UTF8PROC ${_required} ${_quiet} libutf8proc IMPORTED_TARGET GLOBAL) -endif() - -# Find dependencies for SASL -set(_sasl_backend [[@SASL_BACKEND@]]) -if(_sasl_backend STREQUAL "Cyrus") - # We need libsasl2. The find-module should be installed within this package. - # temporarily place it on the module search path: - set(_prev_path "${CMAKE_MODULE_PATH}") - list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/3rdParty") - find_dependency(SASL2 2.0) - set(CMAKE_MODULE_PATH "${_prev_path}") -endif() diff --git a/src/libmongoc/src/mongoc/modules/module.modulemap.in b/src/libmongoc/src/mongoc/modules/module.modulemap.in deleted file mode 100644 index fb2f5b619fe..00000000000 --- a/src/libmongoc/src/mongoc/modules/module.modulemap.in +++ /dev/null @@ -1,5 +0,0 @@ -framework module mongoc { - umbrella header "mongoc/mongoc.h" - - export * -} \ No newline at end of file diff --git a/src/libmongoc/tests/import-tests.cmake b/src/libmongoc/tests/import-tests.cmake index a9c7d0928e8..c46cf34bd0b 100644 --- a/src/libmongoc/tests/import-tests.cmake +++ b/src/libmongoc/tests/import-tests.cmake @@ -1,5 +1,7 @@ include(TestProject) +math(EXPR next_major_version "${PROJECT_VERSION_MAJOR}+1") + # A bare find_package will succeed add_test_cmake_project( mongoc/CMake/bare-bson-import src/libmongoc/tests/cmake-import @@ -21,31 +23,31 @@ add_test_cmake_project( ) add_test_cmake_project( - mongoc/CMake/bson-import-1.0 src/libmongoc/tests/cmake-import + mongoc/CMake/bson-import-${PROJECT_VERSION_MAJOR}.0 src/libmongoc/tests/cmake-import INSTALL_PARENT SETTINGS FIND_BSON=1 - "FIND_BSON_ARGS=1.25;REQUIRED" + "FIND_BSON_ARGS=${PROJECT_VERSION_MAJOR}.0;REQUIRED" "EXPECT_BSON_VERSION=${mongo-c-driver_VERSION_FULL}" ) -# Try to import a too-new version of 1.x that will never exist +# Try to import a too-new minor version that will never exist add_test_cmake_project( mongoc/CMake/bson-import-too-new-fails src/libmongoc/tests/cmake-import INSTALL_PARENT SETTINGS FIND_BSON=1 - "FIND_BSON_ARGS=1.9999.0" + "FIND_BSON_ARGS=${PROJECT_VERSION_MAJOR}.9999.0" EXPECT_FIND_BSON_FAILS=TRUE ) -# Try to import a 2.0 version, which is not installed in this test case +# Try to import the next major version, which is not installed in this test case add_test_cmake_project( - mongoc/CMake/bson-import-2.0-fails src/libmongoc/tests/cmake-import + mongoc/CMake/bson-import-${next_major_version}.0-fails src/libmongoc/tests/cmake-import INSTALL_PARENT SETTINGS FIND_BSON=1 - "FIND_BSON_ARGS=2.0" + "FIND_BSON_ARGS=${next_major_version}.0" EXPECT_FIND_BSON_FAILS=TRUE ) @@ -64,7 +66,7 @@ add_test_cmake_project( INSTALL_PARENT SETTINGS FIND_BSON=1 - "FIND_BSON_ARGS=${PROJECT_VERSION}...1.9999.0;REQUIRED" + "FIND_BSON_ARGS=${PROJECT_VERSION}...${PROJECT_VERSION_MAJOR}.9999.0;REQUIRED" "EXPECT_BSON_VERSION=${mongo-c-driver_VERSION_FULL}" ) @@ -82,7 +84,7 @@ add_test_cmake_project( INSTALL_PARENT SETTINGS FIND_BSON=1 - "FIND_BSON_ARGS=1.0...2.0;REQUIRED" + "FIND_BSON_ARGS=${PROJECT_VERSION_MAJOR}.0...${next_major_version}.0;REQUIRED" "EXPECT_BSON_VERSION=${mongo-c-driver_VERSION_FULL}" ) @@ -91,7 +93,7 @@ add_test_cmake_project( INSTALL_PARENT SETTINGS FIND_BSON=1 - "FIND_BSON_ARGS=2.0...<3" + "FIND_BSON_ARGS=${next_major_version}.0...<${next_major_version}.9999" EXPECT_FIND_BSON_FAILS=TRUE ) @@ -112,3 +114,38 @@ add_test_cmake_project( "FIND_BSON_ARGS=REQUIRED;OPTIONAL_COMPONENTS;foo" "EXPECT_BSON_VERSION=${mongo-c-driver_VERSION_FULL}" ) + +add_test_cmake_project( + mongoc/pkg-config/bson-import-shared src/libmongoc/tests/pkg-config-import + INSTALL_PARENT + SETTINGS + PKG_CONFIG_SEARCH=bson${PROJECT_VERSION_MAJOR} + "EXPECT_BSON_VERSION=${mongo-c-driver_VERSION_FULL}" +) + +add_test_cmake_project( + mongoc/pkg-config/bson-import-static src/libmongoc/tests/pkg-config-import + INSTALL_PARENT + SETTINGS + PKG_CONFIG_SEARCH=bson${PROJECT_VERSION_MAJOR}-static + "EXPECT_BSON_VERSION=${mongo-c-driver_VERSION_FULL}" + EXPECT_BSON_STATIC=1 +) + +add_test_cmake_project( + mongoc/pkg-config/mongoc-import-shared src/libmongoc/tests/pkg-config-import + INSTALL_PARENT + SETTINGS + PKG_CONFIG_SEARCH=mongoc${PROJECT_VERSION_MAJOR} + "EXPECT_MONGOC_VERSION=${mongo-c-driver_VERSION_FULL}" +) + +add_test_cmake_project( + mongoc/pkg-config/mongoc-import-static src/libmongoc/tests/pkg-config-import + INSTALL_PARENT + SETTINGS + PKG_CONFIG_SEARCH=mongoc${PROJECT_VERSION_MAJOR}-static + "EXPECT_MONGOC_VERSION=${mongo-c-driver_VERSION_FULL}" + EXPECT_BSON_STATIC=1 + EXPECT_MONGOC_STATIC=1 +) diff --git a/src/libmongoc/tests/pkg-config-import/CMakeLists.txt b/src/libmongoc/tests/pkg-config-import/CMakeLists.txt new file mode 100644 index 00000000000..a04abac5a56 --- /dev/null +++ b/src/libmongoc/tests/pkg-config-import/CMakeLists.txt @@ -0,0 +1,32 @@ +cmake_minimum_required(VERSION 3.15) +project(pkg-config-import-test LANGUAGES C) + +# This is a test case that tries to build against bson/mongoc using pkg-config. +# Even though this is a CMake project, we import by talking to `pkg-config` + +include(CTest) + +find_package(PkgConfig REQUIRED) +pkg_check_modules(thing REQUIRED IMPORTED_TARGET "${PKG_CONFIG_SEARCH}") + +add_compile_definitions( + "EXPECT_BSON_VERSION=\"${EXPECT_BSON_VERSION}\"" + "EXPECT_MONGOC_VERSION=\"${EXPECT_MONGOC_VERSION}\"" + EXPECT_BSON_STATIC=$ + EXPECT_MONGOC_STATIC=$ + ) + +add_executable(my-app app.c) +target_link_libraries(my-app PRIVATE PkgConfig::thing) + +if(EXPECT_BSON_VERSION) + add_executable(use-bson use-bson.c) + target_link_libraries(use-bson PRIVATE PkgConfig::thing) + add_test(use-bson use-bson) +endif() + +if(EXPECT_MONGOC_VERSION) + add_executable(use-mongoc use-mongoc.c) + target_link_libraries(use-mongoc PRIVATE PkgConfig::thing) + add_test(use-mongoc use-mongoc) +endif() diff --git a/src/libmongoc/tests/pkg-config-import/app.c b/src/libmongoc/tests/pkg-config-import/app.c new file mode 100644 index 00000000000..57d7f69ffe4 --- /dev/null +++ b/src/libmongoc/tests/pkg-config-import/app.c @@ -0,0 +1,4 @@ +int +main () +{ +} \ No newline at end of file diff --git a/src/libmongoc/tests/pkg-config-import/use-bson.c b/src/libmongoc/tests/pkg-config-import/use-bson.c new file mode 100644 index 00000000000..4c795f706cd --- /dev/null +++ b/src/libmongoc/tests/pkg-config-import/use-bson.c @@ -0,0 +1,22 @@ +#include +#include + +#ifndef EXPECT_BSON_VERSION +#error This file requires EXPECT_BSON_VERSION to be defined +#define EXPECT_BSON_VERSION "" +#endif + +#if EXPECT_BSON_STATIC != defined(BSON_STATIC) +#error Static/dynamic mismatch +#endif + +int +main (void) +{ + if (strcmp (BSON_VERSION_S, EXPECT_BSON_VERSION)) { + fprintf ( + stderr, "Wrong BSON_MAJOR_VERSION found (Expected “%s”, but got “%s”)", EXPECT_BSON_VERSION, BSON_VERSION_S); + return 2; + } + return 0; +} diff --git a/src/libmongoc/tests/pkg-config-import/use-mongoc.c b/src/libmongoc/tests/pkg-config-import/use-mongoc.c new file mode 100644 index 00000000000..3f16843c68d --- /dev/null +++ b/src/libmongoc/tests/pkg-config-import/use-mongoc.c @@ -0,0 +1,22 @@ +#include +#include + +#ifndef EXPECT_MONGOC_VERSION +#error This file requires EXPECT_MONGOC_VERSION to be defined +#define EXPECT_MONGOC_VERSION "" +#endif + +int +main (void) +{ + mongoc_client_t *const cl = mongoc_client_new ("mongodb://foo"); + mongoc_client_destroy (cl); + if (strcmp (MONGOC_VERSION_S, EXPECT_MONGOC_VERSION)) { + fprintf (stderr, + "Wrong MONGOC_MAJOR_VERSION found (Expected “%s”, but got “%s”)", + EXPECT_MONGOC_VERSION, + MONGOC_VERSION_S); + return 2; + } + return 0; +}