[CDRIVER-1058] Install CMake 'config' style files for find_package Created: 30/Dec/15 Updated: 16/Nov/21 Resolved: 24/Feb/17 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | Build |
| Affects Version/s: | None |
| Fix Version/s: | 1.7.0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Andrew Morrow (Inactive) | Assignee: | A. Jesse Jiryu Davis |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Description |
|
In order to use libbson and libmongo-c easily within CMake projects, you need to find them somehow. The easiest way to do this is to use the CMake pkg_check_modules (https://cmake.org/cmake/help/v3.1/module/FindPkgConfig.html) functionality, and that works just fine on platforms that support pkg-config. However, not all platforms commonly use pkg-config, notably windows. On Windows, it is much more likely that packages will be found via a project local 'module' for libbson and libmongoc. That module will in turn use find_package (https://cmake.org/cmake/help/v3.0/command/find_package.html) to look for an installed .cmake file for each of libbson and libmongoc. Typically, those files would be generated as part of the libbson and libmongoc build process. See https://cmake.org/cmake/help/v3.0/module/CMakePackageConfigHelpers.html for details on what is expected in those files. As noted on that page, a project built with CMake can use some helpers to generate its config-mode package definition .cmake files It is unclear whether those files need to be generated from an autoconf build of libbson and libmongoc. Any system where autoconf runs almost certainly has pkg-config. So, maybe libmongoc and libbson can simplify things and only generate and install the config-mode package definition files from the CMake build. |
| Comments |
| Comment by Olivier Bertrand [X] [ 14/May/17 ] | |||||||||||||||||||||||||||||||||||
|
Thanks. I did so yet and was able to test the driver. However, I needed an automatic way to make it with CMake for distribution. I'll wait for version 1.7.0. | |||||||||||||||||||||||||||||||||||
| Comment by A. Jesse Jiryu Davis [ 14/May/17 ] | |||||||||||||||||||||||||||||||||||
|
I'm sorry I'm doing a bad job of explaining this. Once we release 1.7.0, then mongo-c-driver-1.7.0.tar.gz will be available. Installing the C Driver from mongo-c-driver-1.7.0.tar.gz will then create libbson-1.0-config.cmake and libmongoc-1.0-config.cmake in the correct directories. We'll release version 1.7.0 within the next month or two. Meanwhile, install 1.6.2. Installing 1.6.2 does not install libbson-1.0-config.cmake and libmongoc-1.0-config.cmake, so you'll have to set your include path, library path, and add libbson-1.0.dll and libmongoc-1.0.dll to your CMake target manually. | |||||||||||||||||||||||||||||||||||
| Comment by Olivier Bertrand [X] [ 14/May/17 ] | |||||||||||||||||||||||||||||||||||
|
I don't understand. I have downloaded the files mongo-c-driver-1.6.2.tar.gz from https://github.com/mongodb/mongo-c-driver/releases both in tar.gz and zip format but after extracting them the files libbson-1.0-config.cmake.in and libmongoc-1.0-config.cmake.in do not exist in them. | |||||||||||||||||||||||||||||||||||
| Comment by A. Jesse Jiryu Davis [ 13/May/17 ] | |||||||||||||||||||||||||||||||||||
|
In the source directory we only have files named libbson-1.0-config.cmake.in and libmongoc-1.0-config.cmake.in. Those files are converted into libbson-1.0-config.cmake and libmongoc-1.0-config.cmake during installation. If you install libbson and libmongoc using the current code on master, according to the instructions for building on Windows, then files named libbson-1.0-config.cmake and libmongoc-1.0-config.cmake are generated and installed in:
There are instructions here to include and link libmongoc in your program, make sure you do find_package(libmongoc-1.0), not find_package(libmongoc). | |||||||||||||||||||||||||||||||||||
| Comment by Olivier Bertrand [X] [ 15/Apr/17 ] | |||||||||||||||||||||||||||||||||||
|
I followed your instructions and modified my CMakeLists.txt accordingly but it still fails with the same message. Indeed, looking in the C:\mongo-c-driver directory and sub-directories, there are no files such as libmongocConfig.cmake or libmongoc-config.cmake. Nor in the C:\mongo-c-driver-1.6.2 tree. Did as miss installing them? And how to do it? | |||||||||||||||||||||||||||||||||||
| Comment by A. Jesse Jiryu Davis [ 15/Apr/17 ] | |||||||||||||||||||||||||||||||||||
|
Are you using the latest driver from the "master" branch, or 1.6.2? If you're using "master", install the driver to a location like C:\mongo-c-driver, set CMAKE_PREFIX_PATH to C:\mongo-c-driver then follow these instructions: To set CMAKE_PREFIX_PATH you might run cmake like this:
| |||||||||||||||||||||||||||||||||||
| Comment by Olivier Bertrand [X] [ 12/Apr/17 ] | |||||||||||||||||||||||||||||||||||
|
Copying what is done for XML I added in my CMakeLists.txt the following to build my application with the MongoDB C driver:
However, this fails with CMake displaying the following message:
What should I do to make it work as well on Windows and on Linux? | |||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 25/Feb/17 ] | |||||||||||||||||||||||||||||||||||
|
Author: {u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}Message: | |||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 24/Feb/17 ] | |||||||||||||||||||||||||||||||||||
|
Author: {u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}Message: Also fix | |||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 24/Feb/17 ] | |||||||||||||||||||||||||||||||||||
|
Author: {u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}Message: | |||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 24/Feb/17 ] | |||||||||||||||||||||||||||||||||||
|
Author: {u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}Message: | |||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 22/Feb/17 ] | |||||||||||||||||||||||||||||||||||
|
Author: {u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}Message: | |||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 22/Feb/17 ] | |||||||||||||||||||||||||||||||||||
|
Author: {u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}Message: For consistency with libmongoc. | |||||||||||||||||||||||||||||||||||
| Comment by A. Jesse Jiryu Davis [ 22/Feb/17 ] | |||||||||||||||||||||||||||||||||||
|
Before finishing, update the build and install docs. See how the C++ driver documents this. | |||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 22/Feb/17 ] | |||||||||||||||||||||||||||||||||||
|
Author: {u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}Message: | |||||||||||||||||||||||||||||||||||
| Comment by A. Jesse Jiryu Davis [ 16/Dec/16 ] | |||||||||||||||||||||||||||||||||||
|
I'm bumping the priority, | |||||||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 27/Mar/16 ] | |||||||||||||||||||||||||||||||||||
|
Hi thawkins - I replied on the mongodb-user list with additional details. | |||||||||||||||||||||||||||||||||||
| Comment by Tim Hawkins [ 27/Mar/16 ] | |||||||||||||||||||||||||||||||||||
|
Can somebody provide an example of how to include libraries for both mongo-c and mongo-cxx (and their corresponding bson libs) in a CMake project? I can find no examples anywhere. | |||||||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 10/Jan/16 ] | |||||||||||||||||||||||||||||||||||
|
We are doing fine with what we have in the C++ driver repo. 1.4 is just fine for this. | |||||||||||||||||||||||||||||||||||
| Comment by A. Jesse Jiryu Davis [ 07/Jan/16 ] | |||||||||||||||||||||||||||||||||||
|
Is it worth delaying 1.3.1 release in order to include this, or is 1.4 (first quarter of 2016) soon enough for this improvement? |