# - Try to find LibFreeradius-client
# Once done this will define
#  LIBFREERADIUS_CLIENT_FOUND - System has LibFreeradius-client
#  LIBFREERADIUS_CLIENT_INCLUDE_DIRS - The LibFreeradius-client include directories
#  LIBFREERADIUS_CLIENT_LIBRARIES - The libraries needed to use LibFreeradius-client
#  LIBFREERADIUS_CLIENT_DEFINITIONS - Compiler switches required for using LibFreeradius-client
#  LIBFREERADIUS_CLIENT_VERSION - LibFreeradius-client version

find_package(PkgConfig)
pkg_check_modules(PC_LIBFREERADIUS_CLIENT QUIET freeradius-client)
set(LIBFREERADIUS_CLIENT_DEFINITIONS ${PC_LIBFREERADIUS_CLIENT_CFLAGS_OTHER})

find_path(LIBFREERADIUS_CLIENT_INCLUDE_DIR freeradius-client.h
        HINTS ${PC_LIBFREERADIUS_CLIENT_INCLUDEDIR} ${PC_LIBFREERADIUS_CLIENT_INCLUDE_DIRS}
        )

find_library(LIBFREERADIUS_CLIENT_LIBRARY NAMES freeradius-client libfreeradius-client
        HINTS ${PC_LIBFREERADIUS_CLIENT_LIBDIR} ${PC_LIBFREERADIUS_CLIENT_LIBRARY_DIRS})

if (NOT PC_LIBFREERADIUS_CLIENT_VERSION STREQUAL "")
    set(LIBFREERADIUS_CLIENT_VERSION ${PC_LIBFREERADIUS_CLIENT_VERSION})
else ()
    set(LIBFREERADIUS_CLIENT_VERSION 0.0.0)
endif ()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibFreeradius-client
        REQUIRED_VARS LIBFREERADIUS_CLIENT_LIBRARY LIBFREERADIUS_CLIENT_INCLUDE_DIR
        VERSION_VAR LIBFREERADIUS_CLIENT_VERSION
        )

MARK_AS_ADVANCED(LIBFREERADIUS_CLIENT_LIBRARY LIBFREERADIUS_CLIENT_INCLUDE_DIR)

set(LIBFREERADIUS_CLIENT_LIBRARIES ${LIBFREERADIUS_CLIENT_LIBRARY})
set(LIBFREERADIUS_CLIENT_INCLUDE_DIRS ${LIBFREERADIUS_CLIENT_INCLUDE_DIR})
