[CDRIVER-2211] cmake requires shared and static versions of libbson Created: 14/Jul/17  Updated: 28/Oct/23  Resolved: 14/Jan/18

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

Type: Improvement Priority: Major - P3
Reporter: Hannes Magnusson Assignee: A. Jesse Jiryu Davis
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

When compiling mongoc with cmake then both the normal shared library and the static cmake config is required to be available. This is despite the fact the static config is only installed when explicitly configured to do so.

If libbson is built with CMake then it always builds and installs both static and shared libs. So I think this will be a problem only in the strange event that libbson is built with Autotools (which doesn't build and install the static libbson by default) and then libmongoc is built with CMake.

Plan:

  • DONE Add ENABLE_STATIC option to libbson's CMakeLists.txt, default ON
  • Done Add ENABLE_STATIC=(ON|OFF|AUTO) option to libmongoc's CMakeLists.txt, default AUTO
  • Done If ENABLE_STATIC is ON, require static libbson, if AUTO and static libbson not found, set OFF, if OFF, don't search for static libbson
  • Done Update libmongoc's link-sample-program.sh test, to pass -DENABLE_STATIC=OFF when compiling libbson and libmongoc if the env var LINK_STATIC is not set


 Comments   
Comment by Ramon Fernandez Marina [ 12/Sep/17 ]

Author:

{'username': u'ajdavis', 'name': u'A. Jesse Jiryu Davis', 'email': u'jesse@mongodb.com'}

Message:CDRIVER-2211 add ENABLE_STATIC cmake option
Branch:r1.7
https://github.com/mongodb/mongo-c-driver/commit/8a237901996943f0424af3db1b9b505998ef0a47

Comment by Ramon Fernandez Marina [ 12/Sep/17 ]

Author:

{'username': u'ajdavis', 'name': u'A. Jesse Jiryu Davis', 'email': u'jesse@mongodb.com'}

Message:CDRIVER-2211 add ENABLE_STATIC cmake option
Branch:r1.7
https://github.com/mongodb/mongo-c-driver/commit/3f97c69f4de8cc30de28f176b1b313c4e117eef5

Comment by Ramon Fernandez Marina [ 12/Sep/17 ]

Author:

{'username': u'ajdavis', 'name': u'A. Jesse Jiryu Davis', 'email': u'jesse@mongodb.com'}

Message:CDRIVER-2211 use .cmd files in Evergreen, not .bat

Error code reporting in .bat files is broken in Windows.
Branch:r1.7
https://github.com/mongodb/mongo-c-driver/commit/89025fe745252be70afa22158569670da32a836f

Comment by Ramon Fernandez Marina [ 12/Sep/17 ]

Author:

{'username': u'ajdavis', 'name': u'A. Jesse Jiryu Davis', 'email': u'jesse@mongodb.com'}

Message:CDRIVER-2211 use .cmd files in Evergreen, not .bat

Error code reporting in .bat files is broken in Windows.
Branch:master
https://github.com/mongodb/libbson/commit/48c11fd1a84591f2cf177ca05fca908eac8df5ef

Comment by Ramon Fernandez Marina [ 12/Sep/17 ]

Author:

{'username': u'ajdavis', 'name': u'A. Jesse Jiryu Davis', 'email': u'jesse@mongodb.com'}

Message:CDRIVER-2211 add CMake option ENABLE_STATIC

For backwards compatibility, defaults to ON. You can turn it OFF to skip
building and installing static libbson. ENABLE_TESTS must also be OFF.
Branch:master
https://github.com/mongodb/libbson/commit/04e5b27f227aaecf7ddf12a66609a8254611f3f5

Comment by Ramon Fernandez Marina [ 12/Sep/17 ]

Author:

{'username': u'ajdavis', 'name': u'A. Jesse Jiryu Davis', 'email': u'jesse@mongodb.com'}

Message:CDRIVER-2211 CMake option ENABLE_STATIC defaults to AUTO

In the future we may need to check whether static dependencies are
available. For now, AUTO means ON.
Branch:r1.7
https://github.com/mongodb/libbson/commit/4a4651c5e82aab505193d0937f883459f04ec44e

Comment by Ramon Fernandez Marina [ 12/Sep/17 ]

Author:

{'username': u'ajdavis', 'name': u'A. Jesse Jiryu Davis', 'email': u'jesse@mongodb.com'}

Message:CDRIVER-2211 use .cmd files in Evergreen, not .bat

Error code reporting in .bat files is broken in Windows.
Branch:r1.7
https://github.com/mongodb/libbson/commit/6f91fd4e706b45272cfc53fc01551f5319de111d

Comment by Ramon Fernandez Marina [ 12/Sep/17 ]

Author:

{'username': u'ajdavis', 'name': u'A. Jesse Jiryu Davis', 'email': u'jesse@mongodb.com'}

Message:CDRIVER-2211 add CMake option ENABLE_STATIC

For backwards compatibility, defaults to ON. You can turn it OFF to skip
building and installing static libbson. ENABLE_TESTS must also be OFF.
Branch:r1.7
https://github.com/mongodb/libbson/commit/3b44949de1f72116ef7525d9c7b14851961fd55a

Comment by Ramon Fernandez Marina [ 12/Sep/17 ]

Author:

{'username': u'ajdavis', 'name': u'A. Jesse Jiryu Davis', 'email': u'jesse@mongodb.com'}

Message:CDRIVER-2211 use .cmd files in Evergreen, not .bat

Error code reporting in .bat files is broken in Windows.
Branch:r1.7
https://github.com/mongodb/libbson/commit/43aa1a2e7b83e2438c1a870cf6ac2a9c52676258

Comment by Hannes Magnusson [ 07/Sep/17 ]

This isn't working for me.

In libbson I ran

$ ./autogen.sh && make -j32 && sudo make install

then in mongoc I ran:

$ cmake .
CMake Warning at CMakeLists.txt:9 (_message):
  CMake support is experimental and may not produce production quality
  artifacts
Call Stack (most recent call first):
  CMakeLists.txt:37 (message)
 
 
-- The C compiler identification is ;GNU 6.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
Current version (from VERSION_CURRENT file): 1.9.0-dev
Previous release (from VERSION_RELEASED file): 1.7.0
-- Searching for libbson CMake packages
--   libbson found version "1.9.0-dev"
--   libbson include path "/usr/local/include/libbson-1.0"
--   libbson libraries "/usr/local/lib/libbson-1.0.so"
CMake Warning at CMakeLists.txt:78 (find_package):
  Could not find a package configuration file provided by
  "libbson-static-1.0" (requested version 1.9.0) with any of the following
  names:
 
    libbson-static-1.0Config.cmake
    libbson-static-1.0-config.cmake
 
  Add the installation prefix of "libbson-static-1.0" to CMAKE_PREFIX_PATH or
  set "libbson-static-1.0_DIR" to a directory containing one of the above
  files.  If "libbson-static-1.0" provides a separate development package or
  SDK, be sure it has been installed.
 
 
--   libbson-static found version ""
--   libbson-static include path ""
--   libbson-static libraries ""
CMake Error at CMakeLists.txt:9 (_message):
  ENABLE_TESTS requires ENABLE_STATIC
Call Stack (most recent call first):
  CMakeLists.txt:97 (message)
 
 
-- Configuring incomplete, errors occurred!
See also "/home/bjori/Sources/mongoc/CMakeFiles/CMakeOutput.log".

Comment by Githook User [ 25/Jul/17 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-2211 use .cmd files in Evergreen, not .bat

Error code reporting in .bat files is broken in Windows.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/99858031e954f554b6ea47dcf5f9c2ef4ab6c09f

Comment by Githook User [ 25/Jul/17 ]

Author:

{'username': 'ajdavis', 'name': 'A. Jesse Jiryu Davis', 'email': 'jesse@mongodb.com'}

Message: CDRIVER-2211 CMake option ENABLE_STATIC defaults to AUTO

In the future we may need to check whether static dependencies are
available. For now, AUTO means ON.
Branch: master
https://github.com/mongodb/libbson/commit/878e39dd5cb4953d6c4edabcf1998a8ed5f0b01c

Comment by Githook User [ 25/Jul/17 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-2211 add ENABLE_STATIC cmake option
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/43f003e2ae293eacca2e8e54dceaf5eca569ee30

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

On r1.7: https://github.com/mongodb/mongo-c-driver/commit/8a237901996943f0424af3db1b9b505998ef0a47

Comment by Githook User [ 24/Jul/17 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-2211 add ENABLE_STATIC cmake option
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/248efaa0b6fcb4959ed1fd2f2508020900849145

Comment by A. Jesse Jiryu Davis [ 17/Jul/17 ]

libbson master:

https://github.com/mongodb/libbson/commit/04e5b27f227aaecf7ddf12a66609a8254611f3f5
https://github.com/mongodb/libbson/commit/48c11fd1a84591f2cf177ca05fca908eac8df5ef

Comment by Hannes Magnusson [ 15/Jul/17 ]

Default install of libbson must be compatible with default config of mongoc.

I pretty much never use cmake to install libbson, but every once in a while I build mongoc with cmake, in which case I should not need to add extra configure arguments.

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