mirror of https://github.com/getdnsapi/getdns.git
Add stub only mode, on by default.
If disabled, it needs to drag in libunbound. So do all that.
This commit is contained in:
parent
530c8c5e8e
commit
9dcd8482f5
|
@ -123,6 +123,8 @@ option(ENABLE_ED25519 "Enable ED25519 support." ON)
|
|||
option(ENABLE_ED448 "Enable ED448 support." ON)
|
||||
|
||||
option(ENABLE_NATIVE_STUB_DNSSEC "Enable/disable native stub DNSSEC support." ON)
|
||||
option(ENABLE_STUB_ONLY "Restricts resolution modes to STUB." ON)
|
||||
option(ENABLE_UNBOUND_EVENT_API "Enable usage of libunbound's event API." ON)
|
||||
|
||||
# Above names chosen for user consistency. Now define substituted names.
|
||||
set(REQ_DEBUG ${ENABLE_DEBUG_REQ})
|
||||
|
@ -386,6 +388,19 @@ if (NOT
|
|||
endif ()
|
||||
mark_as_advanced(BSD_LIBRARY)
|
||||
|
||||
# If we're not stub only, we need libunbound.
|
||||
if (NOT ENABLE_STUB_ONLY)
|
||||
find_package(Libunbound REQUIRED)
|
||||
set(HAVE_LIBUNBOUND 1)
|
||||
list(APPEND getdns_system_libs Libunbound::Libunbound)
|
||||
|
||||
set(CMAKE_REQUIRED_INCLUDES ${LIBUNBOUND_INCLUDE_DIR})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${LIBUNBOUND_LIBRARIES})
|
||||
check_include_file(unbound-event.h HAVE_UNBOUND_EVENT_H)
|
||||
check_symbol_exists(ub_ctx_create_ub_event "unbound-event.h" HAVE_UNBOUND_EVENT_API)
|
||||
check_symbol_exists(ub_ctx_set_stub "unbound-event.h" HAVE_UB_CTX_SET_STUB)
|
||||
endif ()
|
||||
|
||||
# Event loop extension
|
||||
# TODO: other event loops
|
||||
set(DEFAULT_EVENTLOOP "select_eventloop")
|
||||
|
|
|
@ -159,6 +159,11 @@
|
|||
#cmakedefine HAVE_ARC4RANDOM 1
|
||||
#cmakedefine HAVE_ARC4RANDOM_UNIFORM 1
|
||||
|
||||
#cmakedefine HAVE_LIBUNBOUND 1
|
||||
#cmakedefine HAVE_UNBOUND_EVENT_H 1
|
||||
#cmakedefine HAVE_UNBOUND_EVENT_API 1
|
||||
#cmakedefine HAVE_UB_CTX_SET_STUB 1
|
||||
|
||||
#cmakedefine DEFAULT_EVENTLOOP "@DEFAULT_EVENTLOOP@"
|
||||
#cmakedefine USE_POLL_DEFAULT_EVENTLOOP 1
|
||||
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
FindLibunbound
|
||||
--------
|
||||
|
||||
Find the Libunbound library
|
||||
|
||||
Imported targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module defines the following :prop_tgt:`IMPORTED` targets:
|
||||
|
||||
``Libunbound::Libunbound``
|
||||
The Libunbound library, if found.
|
||||
|
||||
Result variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module will set the following variables in your project:
|
||||
|
||||
``Libunbound_FOUND``
|
||||
If false, do not try to use Libunbound.
|
||||
``LIBUNBOUND_INCLUDE_DIR``
|
||||
where to find check.h, etc.
|
||||
``LIBUNBOUND_LIBRARIES``
|
||||
the libraries needed to use Libunbound.
|
||||
``LIBUNBOUND_VERSION``
|
||||
the version of the Libunbound library found
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
find_path(LIBUNBOUND_INCLUDE_DIR unbound.h
|
||||
HINTS
|
||||
"${LIBUNBOUND_DIR}"
|
||||
"${LIBUNBOUND_DIR}/include"
|
||||
)
|
||||
|
||||
find_library(LIBUNBOUND_LIBRARY NAMES unbound
|
||||
HINTS
|
||||
"${LIBUNBOUND_DIR}"
|
||||
"${LIBUNBOUND_DIR}/lib"
|
||||
)
|
||||
|
||||
set(LIBUNBOUND_LIBRARIES "")
|
||||
|
||||
if (UNIX)
|
||||
find_package(Threads REQUIRED)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
|
||||
list(APPEND LIBUNBOUND_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}")
|
||||
list(APPEND LIBUNBOUND_LIBRARIES "${OPENSSL_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
if (LIBUNBOUND_INCLUDE_DIR AND LIBUNBOUND_LIBRARY)
|
||||
if (NOT TARGET Libunbound::Libunbound)
|
||||
add_library(Libunbound::Libunbound UNKNOWN IMPORTED)
|
||||
set_target_properties(Libunbound::Libunbound PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${LIBUNBOUND_INCLUDE_DIR}"
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "${LIBUNBOUND_LIBRARY}"
|
||||
)
|
||||
|
||||
if(UNIX AND TARGET Threads::Threads)
|
||||
set_property(TARGET Libunbound::Libunbound APPEND PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES Threads::Threads)
|
||||
endif ()
|
||||
if(UNIX AND TARGET OpenSSL::SSL)
|
||||
set_property(TARGET Libunbound::Libunbound APPEND PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES OpenSSL::SSL)
|
||||
endif ()
|
||||
if(UNIX AND TARGET OpenSSL::Crypto)
|
||||
set_property(TARGET Libunbound::Libunbound APPEND PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES OpenSSL::Crypto)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (NOT LIBUNBOUND_VERSION AND LIBUNBOUND_INCLUDE_DIR AND EXISTS "${LIBUNBOUND_INCLUDE_DIR}/unbound.h")
|
||||
file(STRINGS "${LIBUNBOUND_INCLUDE_DIR}/unbound.h" LIBUNBOUND_H REGEX "^#define UNBOUND_VERSION_M[A-Z]+")
|
||||
string(REGEX REPLACE "^.*MAJOR ([0-9]+).*MINOR ([0-9]+).*MICRO ([0-9]+).*$" "\\1.\\2.\\3" LIBUNBOUND_VERSION "${LIBUNBOUND_H}")
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
list(APPEND LIBUNBOUND_LIBRARIES "${LIBUNBOUND_LIBRARY}")
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Libunbound
|
||||
REQUIRED_VARS LIBUNBOUND_LIBRARIES LIBUNBOUND_INCLUDE_DIR
|
||||
VERSION_VAR LIBUNBOUND_VERSION
|
||||
)
|
||||
|
||||
mark_as_advanced(LIBUNBOUND_INCLUDE_DIR LIBUNBOUND_LIBRARIES LIBUNBOUND_LIBRARY)
|
Loading…
Reference in New Issue