compile bundled libbson
If the current source directory is not the source directory (i.e mongoc
is a subproject), build mongoc and libbson dependency.
@@ -30,6 +30,7 @@ option(ENABLE_MAINTAINER_FLAGS "Use strict compiler checks" OFF)
option(ENABLE_AUTOMATIC_INIT_AND_CLEANUP "Enable automatic init and cleanup (GCC only)" ON)
option(ENABLE_CRYPTO_SYSTEM_PROFILE "Use system crypto profile (OpenSSL only)" OFF)
option(ENABLE_TRACING "Turn on verbose debug output" OFF)
+option(ENABLE_BUILD_DEPENDECIES "ENable to build subproject dependecies" OFF)
set(ENABLE_SNAPPY AUTO CACHE STRING "Enable snappy support")
set(ENABLE_ZLIB BUNDLED CACHE STRING "Enable zlib support")
@@ -51,6 +52,11 @@ endif()
include(MaintainerFlags)
+if((ENABLE_BUILD_DEPENDECIES STREQUAL OFF) AND (NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR))
+ set(ENABLE_BUILD_DEPENDECIES ON)
+endif()
+
+if(NOT ENABLE_BUILD_DEPENDECIES)
# The input variable BSON_ROOT_DIR is respected for backwards compatibility,
# but you should use the standard CMAKE_PREFIX_PATH instead.
message (STATUS "Searching for libbson CMake packages")
@@ -82,6 +88,16 @@ if (ENABLE_STATIC STREQUAL ON OR ENABLE_STATIC STREQUAL AUTO)
message ("-- libbson-static include path \"${BSON_STATIC_INCLUDE_DIRS}\"")
message ("-- libbson-static libraries \"${BSON_STATIC_LIBRARIES}\"")
endif ()
+else()
+ if (ENABLE_STATIC STREQUAL ON OR ENABLE_STATIC STREQUAL AUTO)
+ set (MONGOC_ENABLE_STATIC ON)
+ endif()
+ add_subdirectory(src/libbson)
+ set(BSON_STATIC_LIBRARIES bson_static)
+ set(BSON_LIBRARIES bson_shared)
+ set(BSON_STATIC_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src/libbson/src/bson" "${PROJECT_BINARY_DIR}/src/libbson/src/bson")
+ set(BSON_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src/libbson/src/bson" "${PROJECT_BINARY_DIR}/src/libbson/src/bson")
+endif()
if (ENABLE_TESTS AND NOT MONGOC_ENABLE_STATIC)
message (FATAL_ERROR "ENABLE_TESTS requires ENABLE_STATIC")
