set(CEREAL_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/ext/cereal/include")

file(READ "${CEREAL_INCLUDE_DIR}/cereal/version.hpp" VERSION_HPP)

string(REGEX MATCH "CEREAL_VERSION_MAJOR ([0-9]+)" _ ${VERSION_HPP})
set(VERSION_MAJOR ${CMAKE_MATCH_1})

string(REGEX MATCH "CEREAL_VERSION_MINOR ([0-9]+)" _ ${VERSION_HPP})
set(VERSION_MINOR ${CMAKE_MATCH_1})

string(REGEX MATCH "CEREAL_VERSION_PATCH ([0-9]+)" _ ${VERSION_HPP})
set(VERSION_PATCH ${CMAKE_MATCH_1})

set(CEREAL_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(CEREAL
    REQUIRED_VARS
        CEREAL_INCLUDE_DIR
    VERSION_VAR CEREAL_VERSION)
