# defines
#  NOTCURSES_FOUND
#  NOTCURSES_INCLUDE_DIRS
#  NOTCURSES_LIBRARIES

find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
  pkg_check_modules(PC_NOTCURSES QUIET notcurses)
endif()

set(NOTCURSES_DEFINITIONS ${PC_NOTCURSES_CFLAGS_OTHER})

find_path(NOTCURSES_INCLUDE_DIR notcurses/notcurses.h
          PATHS ${PC_NOTCURSES_INCLUDEDIR} ${PC_NOTCURSES_INCLUDE_DIRS})

list(APPEND NOTCURSES_NAMES libnotcurses.a)
list(APPEND NOTCURSES_CORE_NAMES libnotcurses-core.a)

find_library(NOTCURSES_LIBRARY NAMES ${NOTCURSES_NAMES}
             PATHS ${PC_NOTCURSES_LIBDIR} ${PC_NOTCURSES_LIBRARY_DIRS})

find_library(NOTCURSES_CORE_LIBRARY NAMES ${NOTCURSES_CORE_NAMES}
             PATHS ${PC_NOTCURSES_LIBDIR} ${PC_NOTCURSES_LIBRARY_DIRS})

set(NOTCURSES_LIBRARIES ${NOTCURSES_LIBRARY})
set(NOTCURSES_INCLUDE_DIRS ${NOTCURSES_INCLUDE_DIR})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Notcurses DEFAULT_MSG
                                  NOTCURSES_LIBRARY NOTCURSES_INCLUDE_DIR NOTCURSES_CORE_LIBRARY)

mark_as_advanced(NOTCURSES_INCLUDE_DIR NOTCURSES_CORE_LIBRARY NOTCURSES_LIBRARY)
