mirror of https://github.com/getdnsapi/getdns.git
Detect and use libidn and libidn2 if present.
This commit is contained in:
parent
164b089011
commit
1da968a35f
|
@ -318,6 +318,18 @@ else ()
|
|||
message(WARNING "Neither pthreads nor Windows threading available.")
|
||||
endif ()
|
||||
|
||||
# Libidn
|
||||
find_package(Libidn)
|
||||
if (Libidn_FOUND)
|
||||
set(HAVE_LIBIDN 1)
|
||||
endif()
|
||||
|
||||
# Libidn2
|
||||
find_package(Libidn2 "2.0.0")
|
||||
if (Libidn2_FOUND)
|
||||
set(HAVE_LIBIDN2 1)
|
||||
endif()
|
||||
|
||||
# Stuff that might be in a BSD library
|
||||
check_symbol_exists(strlcpy string.h HAVE_DECL_STRLCPY)
|
||||
check_symbol_exists(arc4random stdlib.h HAVE_DECL_ARC4RANDOM)
|
||||
|
@ -499,6 +511,8 @@ target_include_directories(getdns_objects
|
|||
src/yxml
|
||||
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${LIBIDN_INCLUDE_DIR}
|
||||
${LIBIDN2_INCLUDE_DIR}
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
)
|
||||
if (NOT HAVE_SSL_DANE_ENABLE)
|
||||
|
@ -526,6 +540,12 @@ if (ENABLE_STATIC)
|
|||
Threads::Threads
|
||||
${getdns_system_libs}
|
||||
)
|
||||
if (Libidn_FOUND)
|
||||
target_link_libraries(getdns INTERFACE Libidn::Libidn)
|
||||
endif ()
|
||||
if (Libidn2_FOUND)
|
||||
target_link_libraries(getdns INTERFACE Libidn2::Libidn2)
|
||||
endif ()
|
||||
set_target_properties(getdns PROPERTIES OUTPUT_NAME getdns${static_lib_suffix})
|
||||
endif ()
|
||||
|
||||
|
@ -542,6 +562,12 @@ if (ENABLE_SHARED)
|
|||
Threads::Threads
|
||||
${getdns_system_libs}
|
||||
)
|
||||
if (Libidn_FOUND)
|
||||
target_link_libraries(getdns INTERFACE Libidn::Libidn)
|
||||
endif ()
|
||||
if (Libidn2_FOUND)
|
||||
target_link_libraries(getdns INTERFACE Libidn2::Libidn2)
|
||||
endif ()
|
||||
set_target_properties(getdns_shared PROPERTIES OUTPUT_NAME getdns)
|
||||
|
||||
if (NOT ENABLE_STATIC)
|
||||
|
|
|
@ -165,6 +165,9 @@
|
|||
#cmakedefine HAVE_UNBOUND_EVENT_API 1
|
||||
#cmakedefine HAVE_UB_CTX_SET_STUB 1
|
||||
|
||||
#cmakedefine HAVE_LIBIDN 1
|
||||
#cmakedefine HAVE_LIBIDN2 1
|
||||
|
||||
#cmakedefine DEFAULT_EVENTLOOP "@DEFAULT_EVENTLOOP@"
|
||||
#cmakedefine USE_POLL_DEFAULT_EVENTLOOP 1
|
||||
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
#[=======================================================================[.rst:
|
||||
FindLibidn
|
||||
----------
|
||||
|
||||
Find the Libidn library
|
||||
|
||||
Imported targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module defines the following :prop_tgt:`IMPORTED` targets:
|
||||
|
||||
``Libidn::Libidn``
|
||||
The Libidn library, if found.
|
||||
|
||||
Result variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module will set the following variables in your project:
|
||||
|
||||
``Libidn_FOUND``
|
||||
If false, do not try to use Libidn.
|
||||
``LIBIDN_INCLUDE_DIR``
|
||||
where to find check.h, etc.
|
||||
``LIBIDN_LIBRARIES``
|
||||
the libraries needed to use Libidn.
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
find_path(LIBIDN_INCLUDE_DIR idna.h
|
||||
HINTS
|
||||
"${LIBIDN_DIR}"
|
||||
"${LIBIDN_DIR}/include"
|
||||
)
|
||||
|
||||
find_library(LIBIDN_LIBRARY NAMES idn
|
||||
HINTS
|
||||
"${LIBIDN_DIR}"
|
||||
"${LIBIDN_DIR}/lib"
|
||||
)
|
||||
|
||||
set(LIBIDN_LIBRARIES "")
|
||||
|
||||
if (LIBIDN_INCLUDE_DIR AND LIBIDN_LIBRARY)
|
||||
if (NOT TARGET Libidn::Libidn)
|
||||
add_library(Libidn::Libidn UNKNOWN IMPORTED)
|
||||
set_target_properties(Libidn::Libidn PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${LIBIDN_INCLUDE_DIR}"
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "${LIBIDN_LIBRARY}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
list(APPEND LIBIDN_LIBRARIES "${LIBIDN_LIBRARY}")
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Libidn
|
||||
REQUIRED_VARS LIBIDN_LIBRARIES LIBIDN_INCLUDE_DIR
|
||||
)
|
||||
|
||||
mark_as_advanced(LIBIDN_INCLUDE_DIR LIBIDN_LIBRARIES LIBIDN_LIBRARY)
|
|
@ -0,0 +1,69 @@
|
|||
#[=======================================================================[.rst:
|
||||
FindLibidn2
|
||||
-----------
|
||||
|
||||
Find the Libidn2 library
|
||||
|
||||
Imported targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module defines the following :prop_tgt:`IMPORTED` targets:
|
||||
|
||||
``Libidn2::Libidn2``
|
||||
The Libidn2 library, if found.
|
||||
|
||||
Result variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module will set the following variables in your project:
|
||||
|
||||
``Libidn2_FOUND``
|
||||
If false, do not try to use Libidn2.
|
||||
``LIBIDN2_INCLUDE_DIR``
|
||||
where to find check.h, etc.
|
||||
``LIBIDN2_LIBRARIES``
|
||||
the libraries needed to use Libidn2.
|
||||
``LIBIDN2_VERSION``
|
||||
the version of the Libidn2 library found
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
find_path(LIBIDN2_INCLUDE_DIR idn2.h
|
||||
HINTS
|
||||
"${LIBIDN2_DIR}"
|
||||
"${LIBIDN2_DIR}/include"
|
||||
)
|
||||
|
||||
find_library(LIBIDN2_LIBRARY NAMES idn2
|
||||
HINTS
|
||||
"${LIBIDN2_DIR}"
|
||||
"${LIBIDN2_DIR}/lib"
|
||||
)
|
||||
|
||||
set(LIBIDN2_LIBRARIES "")
|
||||
|
||||
if (LIBIDN2_INCLUDE_DIR AND LIBIDN2_LIBRARY)
|
||||
if (NOT TARGET Libidn2::Libidn2)
|
||||
add_library(Libidn2::Libidn2 UNKNOWN IMPORTED)
|
||||
set_target_properties(Libidn2::Libidn2 PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${LIBIDN2_INCLUDE_DIR}"
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "${LIBIDN2_LIBRARY}"
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (NOT LIBIDN2_VERSION AND LIBIDN2_INCLUDE_DIR AND EXISTS "${LIBIDN2_INCLUDE_DIR}/unbound.h")
|
||||
file(STRINGS "${LIBIDN2_INCLUDE_DIR}/idn2.h" LIBIDN2_H REGEX "^#define IDN2_VERSION ")
|
||||
string(REGEX REPLACE "^.*IDN2_VERSION \"([0-9.]+)\".*$" "\\1" LIBIDN2_VERSION "${LIBIDN2_H}")
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
list(APPEND LIBIDN2_LIBRARIES "${LIBIDN2_LIBRARY}")
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Libidn2
|
||||
REQUIRED_VARS LIBIDN2_LIBRARIES LIBIDN2_INCLUDE_DIR
|
||||
VERSION_VAR LIBIDN2_VERSION
|
||||
)
|
||||
|
||||
mark_as_advanced(LIBIDN2_INCLUDE_DIR LIBIDN2_LIBRARIES LIBIDN2_LIBRARY)
|
Loading…
Reference in New Issue