# INI (iniparser)
option(FUN_WITH_INI "Enable INI (iniparser) support" OFF)
set(INIPARSER_INCLUDE_DIRS "")
set(INIPARSER_LINK_LIBS "")
if(FUN_WITH_INI)
  add_definitions(-DFUN_WITH_INI)
  find_package(PkgConfig QUIET)
  if(PKG_CONFIG_FOUND)
    pkg_check_modules(INIPARSER QUIET iniparser)
  endif()
  if(INIPARSER_FOUND)
    list(APPEND INIPARSER_INCLUDE_DIRS ${INIPARSER_INCLUDE_DIRS} ${INIPARSER_INCLUDE_DIRS})
    list(APPEND INIPARSER_LINK_LIBS ${INIPARSER_LINK_LIBS} ${INIPARSER_LIBRARIES})
  else()
    find_path(INIPARSER_INCLUDE_DIR iniparser.h)
    find_library(INIPARSER_LIB NAMES iniparser)
    if(INIPARSER_INCLUDE_DIR)
      list(APPEND INIPARSER_INCLUDE_DIRS ${INIPARSER_INCLUDE_DIR})
    endif()
    if(INIPARSER_LIB)
      list(APPEND INIPARSER_LINK_LIBS ${INIPARSER_LIB})
    endif()
    if(NOT INIPARSER_INCLUDE_DIRS OR NOT INIPARSER_LINK_LIBS)
      message(FATAL_ERROR "iniparser not found. Install iniparser (>=4.2.6) or disable FUN_WITH_INI.")
    endif()
  endif()
endif()
