diff --git a/src/libmongoc/CMakeLists.txt b/src/libmongoc/CMakeLists.txt index 9b2c2f845d..9cb6397d2e 100644 --- a/src/libmongoc/CMakeLists.txt +++ b/src/libmongoc/CMakeLists.txt @@ -52,7 +52,7 @@ endif () set (ZLIB_INCLUDE_DIRS "") if (ENABLE_ZLIB MATCHES "SYSTEM|AUTO") message (STATUS "Searching for zlib CMake packages") - include (FindZLIB) + find_package(ZLIB REQUIRED) if (ZLIB_FOUND) message (STATUS " zlib found version \"${ZLIB_VERSION_STRING}\"") message (STATUS " zlib include path \"${ZLIB_INCLUDE_DIRS}\"") @@ -460,10 +460,10 @@ else () endif () # Sets SNAPPY_LIBRARIES and SNAPPY_INCLUDE_DIRS. -include (FindSnappy) -if (SNAPPY_INCLUDE_DIRS) +if (ENABLE_SNAPPY) + find_package(Snappy CONFIG REQUIRED) + set(SNAPPY_LIBRARIES Snappy::snappy) set (MONGOC_ENABLE_COMPRESSION 1) - include_directories ("${SNAPPY_INCLUDE_DIRS}") endif () mongo_bool01 (MONGOC_ENABLE_SHM_COUNTERS ENABLE_SHM_COUNTERS) @@ -780,7 +780,7 @@ set (STATIC_LIBRARIES ) # utf8proc configuration -find_package(Utf8Proc REQUIRED) +find_package(unofficial-utf8proc CONFIG REQUIRED) set(UTF8PROC_INCLUDE_DIRS, "") if (USE_BUNDLED_UTF8PROC) set ( @@ -913,7 +913,7 @@ if (ENABLE_SHARED) OUTPUT_NAME "${MONGOC_OUTPUT_BASENAME}${PROJECT_VERSION_MAJOR}" VERSION "${PROJECT_VERSION}" SOVERSION "${PROJECT_VERSION_MAJOR}" - pkg_config_REQUIRES "bson${PROJECT_VERSION_MAJOR}" + pkg_config_REQUIRES "bson${PROJECT_VERSION_MAJOR} libutf8proc" ) mongo_generate_pkg_config(mongoc_shared INSTALL RENAME mongoc${PROJECT_VERSION_MAJOR}.pc) diff --git a/src/libmongoc/etc/mongocConfig.cmake.in b/src/libmongoc/etc/mongocConfig.cmake.in index 14d7e4c7ed..1597473cee 100644 --- a/src/libmongoc/etc/mongocConfig.cmake.in +++ b/src/libmongoc/etc/mongocConfig.cmake.in @@ -48,6 +48,9 @@ include(CMakeFindDependencyMacro) get_filename_component(__parent_dir "${CMAKE_CURRENT_LIST_DIR}" DIRECTORY) # Also import the `bson` package, to ensure its targets are also available find_dependency(bson "${__mongoc_package_version}" HINTS ${__parent_dir}) +if("@ENABLE_SNAPPY@") + find_dependency(Snappy CONFIG) +endif() # QUIET arg for finding dependencies: unset(__quiet) @@ -60,16 +63,8 @@ if(NOT __mongoc_uses_bundled_utf8proc AND NOT TARGET PkgConfig::PC_UTF8PROC) # libmongoc was compiled against an external utf8proc and links against a # FindPkgConfig-generated IMPORTED target. Find that package and generate that # imported target here: - find_dependency(PkgConfig) - pkg_check_modules(PC_UTF8PROC ${__quiet} libutf8proc IMPORTED_TARGET GLOBAL) - if(NOT PC_UTF8PROC_FOUND) - # Handle if it wasn't found (find_dependency would usually do this for us, - # but pkg_check_modules() does not) - set(mongoc_FOUND FALSE) - set(mongoc_NOT_FOUND_MESSAGE "We were unable to find the required libutf8proc package with pkg-config") - return() - endif() endif() +find_dependency(unofficial-utf8proc CONFIG) # If we need to import a TLS package for our imported targets, do that now: if(__mongoc_tls_package) @@ -110,3 +105,5 @@ if(NOT TARGET mongoc::mongoc) # Don't redefine the target if we were already in add_library(mongoc::mongoc IMPORTED INTERFACE) set_property(TARGET mongoc::mongoc APPEND PROPERTY INTERFACE_LINK_LIBRARIES mongoc::${__type}) endif() + +include("${CMAKE_CURRENT_LIST_DIR}/mongoc-targets.cmake")