Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If disabled, it needs to drag in libunbound. So do all that.
- Loading branch information
Jim Hague
committed
Oct 24, 2019
1 parent
530c8c5
commit 9dcd848
Showing
3 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |