[CXX-841] Cmake fails if libbson_dir provided but not pkg-config found Created: 11/Feb/16  Updated: 15/Mar/16  Resolved: 15/Mar/16

Status: Closed
Project: C++ Driver
Component/s: Build
Affects Version/s: 3.0.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Mario Valle Assignee: Andrew Morrow (Inactive)
Resolution: Incomplete Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File CMakeOutput.log     File FindLibBSON.cmake     File FindLibMongoC.cmake    

 Description   

If you enter LIBBSON_DIR and there is no pkg-config around, makefile fails with a FindPkgConfig.cmake error even if I entered a LIBBSON_DIR value.
The solution is to switch (in both *.cmake provided under ./cmake) the if section: if (PKG_CONFIG_FOUND) with the 2nd one elseif(LIBBSON_DIR).
Attached the two files modified.



 Comments   
Comment by Andrew Morrow (Inactive) [ 15/Mar/16 ]

Hi - I'm closing this issue as I've not heard any more information. Please feel free to re-open it if you need further help.

Comment by Andrew Morrow (Inactive) [ 26/Feb/16 ]

Sorry for the delay. Not to ask an obvious question, but do you actually have libbson 1.3.1 or newer? That error message seems to indicate that pkg-config was in fact used, but it found too old of a version of libbson.

Comment by Mario Valle [ 22/Feb/16 ]

Here is what the cmake-gui outputs after restoring the two Find*.cmake
to the original version:

Checking for module 'libbson-1.0>=1.3.1'

CMake Error at
/local/local1/cmake-3.5.0-rc2-Linux-x86_64/share/cmake-3.5/Modules/FindPkgConfig.cmake:363
(message): A required package was not found Call Stack (most recent call
first):
/local/local1/cmake-3.5.0-rc2-Linux-x86_64/share/cmake-3.5/Modules/FindPkgConfig.cmake:528
(_pkg_check_modules_internal) cmake/FindLibBSON.cmake:26
(pkg_check_modules) src/bsoncxx/CMakeLists.txt:67 (find_package)

Configuring incomplete, errors occurred!

See also
"/home/mvalle/mongodb/mongo-cxx-driver-master/build/CMakeFiles/CMakeOutput.log".

Note that the FindPkgConfig.cmake file is there and CMAKE is at its
latest version 3.5.0
Maybe the problem is with CMAKE and not with MongoDB. In this case,
sorry for the noise.
Best
mario

Comment by Andrew Morrow (Inactive) [ 19/Feb/16 ]

Hi mvalle@cscs.ch -

First, I'm happy to hear that the new driver build system is working better for you. We like it better too. Any thoughts or opinions on the new API in the C++11 driver?

I read your explanation of what is going wrong, and I'm a little puzzled that you are seeing that behavior. The search for PkgConfig is supposed to be "quiet", so that it won't break if it isn't found:

https://github.com/mongodb/mongo-cxx-driver/blob/master/cmake/FindLibBSON.cmake#L22-L25

Can you provide the console output from your CMake invocation so I can see the error that you are getting?

Comment by Mario Valle [ 19/Feb/16 ]

Dear Andrew,
thanks for looking!
Why I made this change. In my installation ccmake has not found
pkg-config (this is for now a side project, so no much time to
investigate why). The logic in the two Find*.cmake module attached say
that if pkg-config not found, then use the LIBBSON_DIR variable. That
makes much sense. Unfortunately CMAKE dies if pkg-config not found, so
the other elseif is never reached. Maybe this should be investigated
upfront. With my small change, if LIBBSON_DIR not set, nothing changes.
If set, then pkg-config not tested and the ccmake configuration succeeds.
In any case, the modifications were attached to the bug submission.

I want to add, that the new c++ driver with the cmake build environment
is a breeze to compile compared with the old (2.6) one.

Best.
mario


Ing. Mario Valle
Swiss National Supercomputing Centre (CSCS)
v. Trevano 131, 6900 Lugano, Switzerland
Tel: +41 (91) 610.82.60

Comment by Andrew Morrow (Inactive) [ 19/Feb/16 ]

Hi, thanks for the bug report.

I'm not sure I totally understand why you want to make this change. The way it is written, it should only be attempting to use the pkg-config mechanism if pkg-config is found. Or are you describing a situation where the pkg-config binary is found, but there is no .pc file available for libmongoc? I think I might see why in that latter case you would want the _DIR variables to function as overrides. Can you clarify a bit? Also, if you want to contribute your changes, a github PR is the preferred way to send us changes.

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