Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@ mongo_bool_setting(ENABLE_EXAMPLES "Build MongoDB C Driver examples")
mongo_bool_setting(ENABLE_MAN_PAGES "Build the manual pages" DEFAULT VALUE OFF)
mongo_bool_setting(ENABLE_HTML_DOCS "Build the HTML documentation" DEFAULT VALUE OFF)
mongo_bool_setting(ENABLE_UNINSTALL "Generate an 'uninstall' script and an 'uninstall' build target")
mongo_bool_setting(ENABLE_SRV "Enable support for mongodb+srv URIs.")

# Optional features that are ENABLED when necessary dependencies are found:
mongo_setting(ENABLE_SRV "Enable support for mongodb+srv URIs."
OPTIONS ON OFF AUTO
DEFAULT VALUE AUTO)
mongo_setting(ENABLE_SNAPPY "Enable Snappy compression support"
OPTIONS ON OFF AUTO
DEFAULT VALUE AUTO)
Expand Down
2 changes: 1 addition & 1 deletion build/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ add_subdirectory (make_dist)

set (build_cmake_MODULES
CheckSchedGetCPU.cmake
FindResSearch.cmake
ResSearch.cmake
FindSASL2.cmake
FindSnappy.cmake
FindSphinx.cmake
Expand Down
73 changes: 0 additions & 73 deletions build/cmake/FindResSearch.cmake

This file was deleted.

57 changes: 57 additions & 0 deletions build/cmake/ResSearch.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
include(CheckSymbolExists)
include(CMakePushCheckState)

cmake_push_check_state(RESET)

# The name of the library that performs name resolution, suitable for giving to the "-l" link flag
set(RESOLVE_LIB_NAME)
# If TRUE, then the C runtime provides the name resolution that we need
set(resolve_is_libc FALSE)

if(WIN32)
set(RESOLVE_LIB_NAME Dnsapi)
set(_MONGOC_HAVE_DNSAPI 1)
else()
# Try to find the search functions for various configurations.
# Headers required by minimum on the strictest system: (Tested on FreeBSD 13)
set(resolve_headers netinet/in.h sys/types.h arpa/nameser.h resolv.h)
set(CMAKE_REQUIRED_LIBRARIES resolv)
check_symbol_exists(res_nsearch "${resolve_headers}" _MONGOC_HAVE_RES_NSEARCH_RESOLV)
check_symbol_exists(res_search "${resolve_headers}" _MONGOC_HAVE_RES_SEARCH_RESOLV)
check_symbol_exists(res_ndestroy "${resolve_headers}" _MONGOC_HAVE_RES_NDESTROY_RESOLV)
check_symbol_exists(res_nclose "${resolve_headers}" _MONGOC_HAVE_RES_NCLOSE_RESOLV)
if((_MONGOC_HAVE_RES_NSEARCH_RESOLV OR _MONGOC_HAVE_RES_SEARCH_RESOLV)
AND (_MONGOC_HAVE_RES_NDESTROY_RESOLV OR _MONGOC_HAVE_RES_NCLOSE_RESOLV))
set(RESOLVE_LIB_NAME resolv)
else()
# Can we use name resolution with just libc?
unset(CMAKE_REQUIRED_LIBRARIES)
check_symbol_exists(res_nsearch "${resolve_headers}" _MONGOC_HAVE_RES_NSEARCH_NOLINK)
check_symbol_exists(res_search "${resolve_headers}" _MONGOC_HAVE_RES_SEARCH_NOLINK)
check_symbol_exists(res_ndestroy "${resolve_headers}" _MONGOC_HAVE_RES_NDESTROY_NOLINK)
check_symbol_exists(res_nclose "${resolve_headers}" _MONGOC_HAVE_RES_NCLOSE_NOLINK)
if((_MONGOC_HAVE_RES_NSEARCH_NOLINK OR _MONGOC_HAVE_RES_SEARCH_NOLINK)
AND (_MONGOC_HAVE_RES_NDESTROY_NOLINK OR _MONGOC_HAVE_RES_NCLOSE_NOLINK))
set(resolve_is_libc TRUE)
message(VERBOSE "Name resolution is provided by the C runtime")
endif()
endif()
endif()

_mongo_pick(MONGOC_HAVE_DNSAPI 1 0 _MONGOC_HAVE_DNSAPI)
_mongo_pick(MONGOC_HAVE_RES_NSEARCH 1 0 [[_MONGOC_HAVE_RES_NSEARCH_NOLINK OR _MONGOC_HAVE_RES_NSEARCH_RESOLV]])
_mongo_pick(MONGOC_HAVE_RES_SEARCH 1 0 [[_MONGOC_HAVE_RES_SEARCH_NOLINK OR _MONGOC_HAVE_RES_SEARCH_RESOLV]])
_mongo_pick(MONGOC_HAVE_RES_NDESTROY 1 0 [[_MONGOC_HAVE_RES_NDESTROY_NOLINK OR _MONGOC_HAVE_RES_NDESTROY_RESOLV]])
_mongo_pick(MONGOC_HAVE_RES_NCLOSE 1 0 [[_MONGOC_HAVE_RES_NCLOSE_NOLINK OR _MONGOC_HAVE_RES_NCLOSE_RESOLV]])

if(RESOLVE_LIB_NAME OR resolve_is_libc)
# Define the resolver interface:
add_library(_mongoc-resolve INTERFACE)
add_library(mongo::detail::c_resolve ALIAS _mongoc-resolve)
set_target_properties(_mongoc-resolve PROPERTIES
INTERFACE_LINK_LIBRARIES "${RESOLVE_LIB_NAME}"
EXPORT_NAME detail::c_resolve)
install(TARGETS _mongoc-resolve EXPORT mongoc-targets)
endif()

cmake_pop_check_state()
Loading