if(__autoutils_check_lib)
  return()
endif()
set(__autoutils_check_lib 1)

include(CheckLibraryExists)

include(AutoutilsWriteToConfigHeader)

macro(autoutils_check_lib lib func)
  string(MAKE_C_IDENTIFIER "${lib}" _var)
  string(TOUPPER "${_var}" _var)
  check_library_exists(${lib} ${func} "" _exists_${lib})
  if(_exists_${lib})
    set(HAVE_LIB${_var} ON)
    autoutils_write_to_config_header("#define HAVE_LIB${_var}")
  else()
    autoutils_write_to_config_header("/* #undef HAVE_LIB${_var} */")
  endif()
endmacro()
