[CDRIVER-2402] Allow mongoc to be added as subproject Created: 22/Nov/17  Updated: 28/Oct/23  Resolved: 07/Sep/18

Status: Closed
Project: C Driver
Component/s: cmake
Affects Version/s: None
Fix Version/s: 1.10.0

Type: New Feature Priority: Major - P3
Reporter: iulian Assignee: A. Jesse Jiryu Davis
Resolution: Fixed Votes: 0
Labels: master
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Zip Archive testing.zip    
Issue Links:
Related
is related to CDRIVER-1948 CMake build should allow using bundle... Closed

 Description   

With CMake we have the ability to add an existing project as subproject, and to be compiled during the superproject build.



 Comments   
Comment by A. Jesse Jiryu Davis [ 07/Sep/18 ]

We've merged the libbson and libmongoc repositories into one repository, and if libbson is not install on your system then building libmongoc now builds libbson by default.

Comment by Githook User [ 26/Jan/18 ]

Author:

{'name': 'Iulian Rotaru', 'username': 'tzulea', 'email': 'iulian.rotaru@gmail.com'}

Message: CDRIVER-2402 compile bundled libbson

If the current source directory is not the source directory (i.e mongoc
is a subproject), build mongoc and libbson dependency.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/6a4ba9b403f215f3b06aa04fabf24ffe5b598079

Comment by A. Jesse Jiryu Davis [ 24/Nov/17 ]

Great, thanks for the explanation. We'll do this in a future release, perhaps 1.10. This is nearly the same feature as CDRIVER-1948. If we include this patch and also execute "git submodule --init" from the CMake script, then CMake will be able to build with bundled libbson as well as the Autotools can.

When we merge this, I want to be very careful about the ENABLE_STATIC logic, it looks ok to me but requires thought.

Comment by iulian [ 23/Nov/17 ]

I have uploaded a test project.
just go to build folder.
issue the following commands:
cmake ..
make

Cheers.

Comment by iulian [ 22/Nov/17 ]

from clonning github branch of mongoc i saw that libbson is a submodule. so doing git submodule update --init --recursive will get us the libbson source code.
There are 2 scenarious:
1. using the option flag : ENABLE_BUILD_DEPENDECIES
if we go to build dir of mongoc and issue the following command:
"cmake -DENABLE_BUILD_DEPENDECIES .." this should compile libbson and mongoc and the output will be in ../mongoc-build/src/..
2. Having a project "test" with a CMakeLists.txt. the "mongoc" as a folder under "test".
Inside the test CMakeLists.txt we can have the following line:
add_subdirectory(mongoc)
target_include(test "mongoc includes ")
target_link_libraries(test "mongoc library")

There is a similar request for cxx : https://jira.mongodb.org/browse/CXX-1173

Regarding Disabling message function:
There is one already defined in mongoc cmakelists. and when i tested building mongoc with libbson
it stopped at the message function and there was an infinite loop. So the libbson messages shoudn't be disabled in this case since there is the same function in mongoc CMakeLists.txt.

question: why not use directly message function from cmake ? mesage(STATUS ..) mesage(FATAL_ERROR ..) : https://cmake.org/cmake/help/v3.0/command/message.html

Hopefully i was clear regarding testing.

Comment by A. Jesse Jiryu Davis [ 22/Nov/17 ]

Can you explain a little more how this works? How do I test this? Do I git clone libbson and mongo-c-driver as two sibling directories and compile them both from a new CMakeLists that refers to each of them?

Also, why disable messages from libbson configuration if libbson is a submodule? I think that output is still informative.

Comment by iulian [ 22/Nov/17 ]

bson pull request:
https://github.com/mongodb/libbson/pull/207
mongoc pull request:
https://github.com/mongodb/mongo-c-driver/pull/465

Generated at Wed Feb 07 21:15:07 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.