message(STATUS "Extern: fmt 6.2.0")

set(fmt_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/local")
set(fmt_INCLUDE_DIR "${fmt_INSTALL_DIR}/include")
set(fmt_LIBRARY_DIR "${fmt_INSTALL_DIR}/lib")

ExternalProject_add(extern-fmt
	PREFIX "${CMAKE_CURRENT_BINARY_DIR}/fmt"
	SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/extern/fmt"
	CMAKE_ARGS
		-DCMAKE_BUILD_TYPE=Release
		-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
		-DCMAKE_INSTALL_PREFIX=${fmt_INSTALL_DIR}
		-DBUILD_SHARED_LIBS=FALSE
		-DFMT_DOC=NO
		-DFMT_INSTALL=YES
		-DFMT_TEST=NO
	INSTALL_DIR ${fmt_INSTALL_DIR}
	)

add_library(fmt::fmt STATIC IMPORTED)
set_target_properties(fmt::fmt
	PROPERTIES
		IMPORTED_LOCATION
			${fmt_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}fmt${CMAKE_STATIC_LIBRARY_SUFFIX}
		INTERFACE_INCLUDE_DIRECTORIES
			${fmt_INCLUDE_DIR}
	)
add_dependencies(fmt::fmt extern-fmt)

