function(add_algs4_library name)
  set (options PRIVATE PUBLIC INTERFACE)
  set (one_value_args TARGETS)
  set (multi_value_args SOURCES DEPENDS)

  cmake_parse_arguments (${name} "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN})

  set (scope)
  if(${name}_PRIVATE)
    set (scope PRIVATE)
  elseif(${name}_PUBLIC)
    set (scope PUBLIC)
  else()
    set (scope INTERFACE)
  endif()

  if(${name}_INTERFACE)
    add_library (${name} INTERFACE)
  else()
    add_library (${name} ${${name}_SOURCES})
    target_link_libraries (${name} ${scope} ${${name}_DEPENDS})
    target_include_directories (${name} PUBLIC ${ALGS4_SOURCE_DIR}/include)
  endif()
endfunction()
