# JSONC_FOUND - true if library and headers were found
# JSONC_INCLUDE_DIRS - include directories
# JSONC_LIBRARIES - library directories

IF(JSONC_USE_STATIC)
  MESSAGE(STATUS "JSONC_USE_STATIC: ON")
ELSE()
  MESSAGE(STATUS "JSONC_USE_STATIC: OFF")
ENDIF(JSONC_USE_STATIC)

FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(PC_JSONC QUIET json-c)

FIND_PATH(JSONC_INCLUDE_DIR json.h
  HINTS ${PC_JSONC_INCLUDEDIR} ${PC_JSONC_INCLUDE_DIRS} PATH_SUFFIXES json-c json)

IF(JSONC_USE_STATIC)
  FIND_LIBRARY(JSONC_LIBRARY NAMES libjson-c.a libjson-c-static.a
    HINTS ${PC_JSONC_LIBDIR} ${PC_JSON-C_LIBRARY_DIRS})
ELSE()
  FIND_LIBRARY(JSONC_LIBRARY NAMES json-c libjson-c
    HINTS ${PC_JSONC_LIBDIR} ${PC_JSONC_LIBRARY_DIRS})
ENDIF(JSONC_USE_STATIC)

SET(JSONC_LIBRARIES ${JSONC_LIBRARY})
SET(JSONC_INCLUDE_DIRS ${JSONC_INCLUDE_DIR})

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(JSONC DEFAULT_MSG JSONC_LIBRARIES JSONC_INCLUDE_DIRS)
MARK_AS_ADVANCED(JSONC_INCLUDE_DIRS JSONC_LIBRARIES)
