package("sonic-cpp")
    set_kind("library", {headeronly = true})
    set_homepage("https://github.com/bytedance/sonic-cpp")
    set_description("A fast JSON serializing & deserializing library, accelerated by SIMD.")
    set_license("Apache-2.0")

    add_urls("https://github.com/bytedance/sonic-cpp/archive/refs/tags/v$(version).zip")
    add_versions("1.0.2", "81888c0d82489288c0482d9437206bda546716eccaefaabcc01a41f5a95c73ee")
    add_versions("1.0.1", "4c892a72970df301b39416ee1f038d0573507f374391053ecd6e9a9c686c3d11")
    add_versions("1.0.0", "409441bfc8b8b9fea8641dc0a0cdfaeed784246066a5c49fc7d6e74c39999f7b")

    add_cxxflags("-march=haswell")

    on_install("linux", function (package)
        os.cp("include", package:installdir())
    end)

    on_test(function (package)
        assert(package:check_cxxsnippets({test = [[
            #include "sonic/sonic.h"
            #include <string>

            void test()
            {
                std::string json = R"(
                    {
                    "a": 1,
                    "b": 2
                    }
                )";

                sonic_json::Document doc;
                doc.Parse(json);
            }
        ]]}, {configs = {languages = "c++11"}}))
    end)
