include_guard(GLOBAL)

include(CPM)
cpm()

if(NOT DEFINED SIO_REPOSITORY)
  set(SIO_REPOSITORY "iLCSoft/SIO")
endif()

if(NOT DEFINED SIO_VERSION)
  set(SIO_VERSION "master")
endif()

declare_option(REPOSITORY SIO OPTION CMAKE_CXX_STANDARD VALUE "11")
declare_option(REPOSITORY SIO OPTION CMAKE_CXX_STANDARD_REQUIRED VALUE TRUE)
declare_option(REPOSITORY SIO OPTION CMAKE_CXX_EXTENSIONS VALUE FALSE)
declare_option(REPOSITORY SIO OPTION CMAKE_INSTALL_PREFIX VALUE "${CMAKE_INSTALL_PREFIX}")
declare_option(REPOSITORY SIO OPTION SIO_EXAMPLES VALUE OFF)
declare_option(REPOSITORY SIO OPTION INSTALL_DOC VALUE OFF)
declare_option(REPOSITORY SIO OPTION SIO_RELEASE_OFAST VALUE OFF)
declare_option(REPOSITORY SIO OPTION SIO_PROFILING VALUE OFF)
declare_option(REPOSITORY SIO OPTION SIO_BUILTIN_ZLIB VALUE ON)
declare_option(REPOSITORY SIO OPTION SIO_MACROS_WITH_EXCEPTION VALUE OFF)
declare_option(REPOSITORY SIO OPTION SIO_SET_RPATH VALUE ON)
declare_option(REPOSITORY SIO OPTION BUILD_TESTING VALUE OFF)
print_options(REPOSITORY  SIO)

CPMFindPackage(NAME sio
               GITHUB_REPOSITORY ${SIO_REPOSITORY}
               GIT_TAG ${SIO_VERSION}
               FETCHCONTENT_UPDATES_DISCONNECTED ${IS_OFFLINE}
               OPTIONS "${SIO_OPTIONS}"
              )


if(sio_ADDED)
  set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  target_include_directories(sio INTERFACE "${sio_SOURCE_DIR}/source/include/")
  target_link_directories(sio INTERFACE "${CMAKE_INSTALL_PREFIX}/lib")
  set_target_properties(sio PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
endif()
