include_guard(GLOBAL)

include(CPM)
cpm()

if(NOT DEFINED FMT_REPOSITORY)
  set(FMT_REPOSITORY "fmtlib/fmt")
endif()

if(NOT DEFINED FMT_VERSION)
  set(FMT_VERSION "7.1.3")
endif()

declare_option(REPOSITORY fmt OPTION CMAKE_CXX_STANDARD VALUE 17)
declare_option(REPOSITORY fmt OPTION CMAKE_CXX_STANDARD_REQUIRED VALUE TRUE)
declare_option(REPOSITORY fmt OPTION CMAKE_CXX_EXTENSIONS VALUE FALSE)
declare_option(REPOSITORY fmt OPTION CMAKE_INSTALL_PREFIX VALUE ${CMAKE_INSTALL_PREFIX})
declare_option(REPOSITORY fmt OPTION FMT_PEDANTIC VALUE OFF)
declare_option(REPOSITORY fmt OPTION FMT_WERROR VALUE OFF)
declare_option(REPOSITORY fmt OPTION FMT_DOC VALUE OFF)
declare_option(REPOSITORY fmt OPTION FMT_INSTALL VALUE ON)
declare_option(REPOSITORY fmt OPTION FMT_TEST VALUE OFF)
declare_option(REPOSITORY fmt OPTION FMT_FUZZ VALUE OFF)
declare_option(REPOSITORY fmt OPTION FMT_CUDA_TEST VALUE OFF)
declare_option(REPOSITORY fmt OPTION FMT_OS VALUE OFF)
print_options(REPOSITORY  fmt)

CPMFindPackage(NAME fmt
               GITHUB_REPOSITORY ${FMT_REPOSITORY}
               GIT_TAG ${FMT_VERSION}
               FETCHCONTENT_UPDATES_DISCONNECTED ${IS_OFFLINE}
               OPTIONS ${FMT_OPTIONS}
              )
