ldns[1] is a lightweight DNS library written in C, supporting recent RFCs such as DNSSEC. I noticed there was no FindLDNS module yet and wrote one based upon FindEXPAT's module.
It should conform to CMake's style guidelines and other criteria. Permission is hereby granted to licence this in any way desired by the CMake developers. If a developer could review this and commit it into the source tree I would be grateful. I've subscribed to the mailing list in case there is feedback. [1]: https://www.nlnetlabs.nl/projects/ldns/ -- Melvin Vermeeren Software Engineer | C / Unixes 79DC 0FAF 18C3 1807 E82E 1A6B 9EF1 DC92 B5F3 01BD
# LDNS_INCLUDE_DIRS - where to find ldns.h
# LDNS_LIBRARIES - list of libraries
# LDNS_FOUND - true if found
# query pkg-config for hints
find_package(PkgConfig QUIET)
pkg_check_modules(PC_LDNS QUIET ldns)
# find headers
find_path (LDNS_INCLUDE_DIR NAMES ldns/ldns.h HINTS ${PC_LDNS_INCLUDE_DIRS})
# find library
find_library(LDNS_LIBRARY NAMES ldns libldns HINTS ${PC_LDNS_LIBRARY_DIRS})
# parse version
if (LDNS_INCLUDE_DIR AND EXISTS "${LDNS_INCLUDE_DIR}/ldns/ldns.h")
file(STRINGS "${LDNS_INCLUDE_DIR}/ldns/util.h" ldns_version_str
REGEX "^#[\t ]*define[\t ]+LDNS_VERSION[\t ]+\"[0-9]+\\.[0-9]+\\.[0-9]\"$")
unset(LDNS_VERSION_STRING)
if("${ldns_version_str}" MATCHES "^#[\t ]*define[\t ]+LDNS_VERSION[\t ]+\"([0-9]+\\.[0-9]+\\.[0-9])\"$")
set(LDNS_VERSION_STRING "${CMAKE_MATCH_1}")
endif()
endif()
# handle arguments and set LDNS_FOUND to true if all variables are true
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LDNS
REQUIRED_VARS LDNS_LIBRARY LDNS_INCLUDE_DIR
VERSION_VAR LDNS_VERSION_STRING)
# set output variables
if(LDNS_FOUND)
set(LDNS_LIBRARIES ${LDNS_LIBRARY})
set(LDNS_INCLUDE_DIRS ${LDNS_INCLUDE_DIR})
endif()
# mark internals as advanced
mark_as_advanced(LDNS_INCLUDE_DIR LDNS_LIBRARY)
signature.asc
Description: This is a digitally signed message part.
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers
