# ADD_TART_DEPENDENCY() adds a dependencty to PARENT_BUILD_TARGET
#
FUNCTION(ADD_TART_DEPENDENCY PARENT_BUILD_TARGET PACKAGE_NAME)
  TART_INFO("Adding package dependency '${PACKAGE_NAME}' to target ${PARENT_BUILD_TARGET}")
  FIND_PACKAGE_TART_YAML_FILEPATH("${TART_CURRENT_WORKSPACE_DIR}" ${PACKAGE_NAME} PACKAGE_DIR)
  GET_YAML_ENTRIES_WITH_INDENDTS("${PACKAGE_DIR}/tart.yaml" ENTRIES ENTRY_INDENTS)

  SET_PACKAGE_SOURCE_FILES("${PACKAGE_DIR}" "${ENTRIES}" "${ENTRY_INDENTS}" LIB_SOURCES)
  ADD_LIBRARY(${PACKAGE_NAME} STATIC ${LIB_SOURCES})
  
  SET_PACKAGE_HEADER_FILES("${PACKAGE_NAME}" "${PACKAGE_DIR}" "${ENTRIES}" "${ENTRY_INDENTS}")

  TARGET_LINK_LIBRARIES(${PARENT_BUILD_TARGET} PRIVATE debug ${PACKAGE_NAME} optimized ${PACKAGE_NAME})
  
  PROCESS_PACKAGE_PROPERTIES(${PACKAGE_NAME} "${ENTRIES}" "${ENTRY_INDENTS}")
  PROCESS_PACKAGE_COMPILE_DEFINITIONS(${PACKAGE_NAME} "${ENTRIES}" "${ENTRY_INDENTS}")
  SET_DEFAULT_PROPERTIES(${PACKAGE_NAME})
  
  # TODO(nidegen) implement following:
  # IF(GENERATOR_IS_XCODE)
  #   INHERIT_XCODE_COMPILATION_OPTIONS(${PARENT_BUILD_TARGET} ${PACKAGE_NAME})
  # ENDIF()
    
ENDFUNCTION(ADD_TART_DEPENDENCY)
