include_guard(GLOBAL)

include(CPM)
cpm()

include(Fmt)

if(NOT DEFINED SPDLOG_REPOSITORY)
  set(SPDLOG_REPOSITORY "https://github.com/gabime/spdlog.git")
endif()

if(NOT DEFINED SPDLOG_TAG)
  set(SPDLOG_TAG "v1.9.2")
endif()

declare_option(REPOSITORY spdlog OPTION SPDLOG_BUILD_ALL VALUE OFF)
declare_option(REPOSITORY spdlog OPTION SPDLOG_ENABLE_PCH VALUE ON)
declare_option(REPOSITORY spdlog OPTION SPDLOG_BUILD_EXAMPLE VALUE OFF)
declare_option(REPOSITORY spdlog OPTION SPDLOG_BUILD_EXAMPLE_HO VALUE OFF)
declare_option(REPOSITORY spdlog OPTION SPDLOG_BUILD_TESTS VALUE OFF)
declare_option(REPOSITORY spdlog OPTION SPDLOG_BUILD_TESTS_HO VALUE OFF)
declare_option(REPOSITORY spdlog OPTION SPDLOG_BUILD_BENCH VALUE OFF)
declare_option(REPOSITORY spdlog OPTION SPDLOG_SANITIZE_ADDRESS VALUE OFF)
declare_option(REPOSITORY spdlog OPTION SPDLOG_INSTALL VALUE OFF)
declare_option(REPOSITORY spdlog OPTION SPDLOG_FMT_EXTERNAL VALUE ON)
declare_option(REPOSITORY spdlog OPTION SPDLOG_BUILD_TESTS_HO VALUE OFF)
declare_option(REPOSITORY spdlog OPTION SPDLOG_FMT_EXTERNAL_HO VALUE OFF)
declare_option(REPOSITORY spdlog OPTION SPDLOG_NO_EXCEPTIONS VALUE OFF)
print_options(REPOSITORY  spdlog)

CPMAddPackage(NAME spdlog
              GIT_REPOSITORY ${SPDLOG_REPOSITORY}
              GIT_TAG ${SPDLOG_TAG}
              FETCHCONTENT_UPDATES_DISCONNECTED ${IS_OFFLINE}
              OPTIONS "${spdlog_OPTIONS}")
