set ( DGM_VERSION  "2.7.0" )
set ( SFML_VERSION "2.5.1" )
set ( TGUI_VERSION "0.8.6" )
set ( CATCH_VERSION "2.10.2" )

set ( DGM_URL  "https://github.com/nerudaj/DGM/releases/download/v${DGM_VERSION}/dgm-${DGM_VERSION}-windows-vc16-64-bit.zip" )
set ( SFML_URL  "https://github.com/SFML/SFML/releases/download/${SFML_VERSION}/SFML-${SFML_VERSION}-windows-vc15-64-bit.zip" )
set ( TGUI_URL "https://github.com/texus/TGUI/releases/download/v${TGUI_VERSION}/TGUI-${TGUI_VERSION}-vc15-64bit-for-SFML-${SFML_VERSION}.zip" )
set ( CATCH_URL "https://github.com/catchorg/Catch2/releases/download/v${CATCH_VERSION}/catch.hpp" )

include ( FetchContent )
FetchContent_Declare ( sfml
	URL "${SFML_URL}"
)
FetchContent_GetProperties(sfml)
if (NOT sfml_POPULATED)
	FetchContent_Populate(sfml)
endif()

FetchContent_Declare ( dgm
	URL "${DGM_URL}"
)
FetchContent_GetProperties(dgm)
if (NOT dgm_POPULATED)
	FetchContent_Populate(dgm)
endif()

FetchContent_Declare ( tgui
	URL "${TGUI_URL}"
)
FetchContent_GetProperties(tgui)
if (NOT tgui_POPULATED)
	FetchContent_Populate(tgui)
endif()

FetchContent_Declare ( catch
	URL                   "${CATCH_URL}"
	DOWNLOAD_NO_PROGRESS  TRUE
	DOWNLOAD_NO_EXTRACT   TRUE
)
FetchContent_GetProperties(catch)
if (NOT catch_POPULATED)
	FetchContent_Populate(catch)
endif()

set ( SFML_FOLDER  "${sfml_SOURCE_DIR}" )
set ( DGM_FOLDER   "${dgm_SOURCE_DIR}" )
set ( TGUI_FOLDER  "${tgui_SOURCE_DIR}" )
set ( CATCH_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/_deps/catch-subbuild/catch-populate-prefix/src" )

include_directories(
	"${SFML_FOLDER}/include"
	"${DGM_FOLDER}/include"
	"${TGUI_FOLDER}/include"
)

link_directories(
	"${SFML_FOLDER}/lib"
	"${DGM_FOLDER}/lib"
	"${TGUI_FOLDER}/lib"
)

## Find libraries
##---------------------------------------------------------
# NOTE: SFML is linked dynamically from DGM
find_library ( LIB_DGM_D dgm-d NAMES dgm-d.lib HINTS "${DGM_FOLDER}/lib" )
find_library ( LIB_DGM_R dgm   NAMES dgm.lib   HINTS "${DGM_FOLDER}/lib" )

set ( LIB_DGM optimized ${LIB_DGM_R} debug ${LIB_DGM_D} )

find_library ( LIB_TGUI_D tgui-d NAMES tgui-d.lib HINTS "${TGUI_FOLDER}/lib" )
find_library ( LIB_TGUI_R tgui   NAMES tgui.lib   HINTS "${TGUI_FOLDER}/lib" )

set ( LIB_TGUI optimized ${LIB_TGUI_R} debug ${LIB_TGUI_D} )
