[CXX-1901] Building C++ driver from master fails to find cmake packages of C driver Created: 23/Dec/19  Updated: 28/Oct/23  Resolved: 27/Dec/19

Status: Closed
Project: C++ Driver
Component/s: Build
Affects Version/s: 3.4.0
Fix Version/s: 3.5.0

Type: Bug Priority: Major - P3
Reporter: Shogair Shogair Assignee: Kevin Albertson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

OS: Windows 10 Enterprise (Version 1909, OS build 18363.535)
Compiler: VS 2019 x64 (16.4.2)
CMake: 3.16.2
Git: https://github.com/mongodb/mongo-cxx-driver
Branch: master


Issue Links:
Duplicate
is duplicated by CXX-1900 C++ Driver on releases/stable fails t... Closed
Related
related to CXX-1902 Test building against the minimum sup... Backlog

 Description   

Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.

No build type selected, default is Release

bsoncxx version: 3.4.0-pre

CMake Error at src/bsoncxx/CMakeLists.txt:79 (find_package):
By not providing "Findbson-1.0.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "bson-1.0",
but CMake did not find one.

Could not find a package configuration file provided by "bson-1.0"
(requested version 1.13.0) with any of the following names:

bson-1.0Config.cmake
bson-1.0-config.cmake

Add the installation prefix of "bson-1.0" to CMAKE_PREFIX_PATH or set
"bson-1.0_DIR" to a directory containing one of the above files. If
"bson-1.0" provides a separate development package or SDK, be sure it has
been installed.

Configuring incomplete, errors occurred!

See also "D:/MongoDB/mcc2/CMakeFiles/CMakeOutput.log".



 Comments   
Comment by Githook User [ 27/Dec/19 ]

Author:

{'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}

Message: CXX-1901 check for old libbson cmake pkg name

CDRIVER-3047 added new cmake package names for the C driver
(bson-1.0/mongoc-1.0) and deprecated the old ones (libbson-1.0/
libmongoc-1.0 and libbson-static-1.0/libmongoc-static-1.0).

CXX-1707 changed the C++ driver to use the new names of the
C driver. That implicitly requires the latest C driver to build
against. So, this change fall backs to the old package names
if the new ones are not found.
Branch: master
https://github.com/mongodb/mongo-cxx-driver/commit/bd49ba3a725ce877ca9037728ba362fdfd660dd9

Comment by Shogair Shogair [ 26/Dec/19 ]

Ok now It works, Thanks very much

Comment by Kevin Albertson [ 26/Dec/19 ]

I believe this is due to the changes of CDRIVER-3047 and CXX-1707. The C++ driver on master was updated to use the new exported target names on the C driver's master branch. This means that currently building the C++ driver from master requires building the C driver from master too (i.e. not a previous release). We'll fix that, but as a temporary workaround, you can build/install the C driver on master to build the C++ driver on master. These are the commands I used to build the C++ driver for Visual Studio 2019.

First, build and install the C driver into C:\mongo-c-driver from the master branch.

git clone https://github.com/mongodb/mongo-c-driver.git
cd mongo-c-driver
mkdir cmake-build
cd cmake-build
cmake -DCMAKE_INSTALL_PREFIX="C:\mongo-c-driver" -G "Visual Studio 16 2019"  ..
cmake --build . --target install --config Debug

Next, build and install the C++ driver from the master branch.

git clone https://github.com/mongodb/mongo-cxx-driver.git
cd mongo-cxx-driver
mkdir cmake-build
cd cmake-build
cmake -G "Visual Studio 16 2019" -DCMAKE_PREFIX_PATH="C:\mongo-c-driver" -DBOOST_ROOT=C:\Boost -DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver ..
cmake --build . --target install --config Debug

The instructions above are for cmd.exe, with cmake version 3.16.2, and explicitly specify VS 2019 as the generator.

As part of this ticket, we'll fix the C++ driver to support the old C driver target names too, to support building against older C driver releases. Apologies for the disruption.

If this resolves your issue, please let us know if this resolves CXX-1900 as well.

Comment by Shogair Shogair [ 23/Dec/19 ]

Hi kevin.albertson,

I already did

cmake -DCMAKE_PREFIX_PATH=C:\mongo-c-driver

but still keep asking for the file

Comment by Kevin Albertson [ 23/Dec/19 ]

Hi note8g2018@gmail.com! The error message in the description is due to cmake unable to find libbson or libmongoc. The C driver (consisting of libmongoc and libbson) must be installed before building the C++ driver. You can tell cmake where to find libmongoc/libbson by including the path via CMAKE_PREFIX_PATH. For example, if the C driver was installed in C:\mongo-c-driver, then configure the C++ driver with:

cmake -DCMAKE_PREFIX_PATH=C:\mongo-c-driver

Also see "Step 4: Configure the driver" in the installation documentation: http://mongocxx.org/mongocxx-v3/installation/ for more information.

Generated at Wed Feb 07 22:04:16 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.