include(vcpkg_common_functions)

vcpkg_check_linkage(ONLY_STATIC_LIBRARY)

vcpkg_from_github(
    OUT_SOURCE_PATH SOURCE_PATH
    REPO bkaradzic/bx
    REF 267727d31899996c0c0dd1613fc30b9751d71314
    SHA512 32a08d66b4d04b7b9cf3787e68fc11262c5213cc0fc865d2ae0a664f918ec77f8f4285bd4d41959b12d45ccf6fbea21ee5bd18f80acb330069c7267949f0ed47
    HEAD_REF master
    PATCHES
        0001-no-include-alloca.patch
)

file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})

vcpkg_configure_cmake(
    SOURCE_PATH ${SOURCE_PATH}
    PREFER_NINJA
    OPTIONS_DEBUG
        -DSKIP_INSTALL_HEADERS=ON
)

vcpkg_install_cmake()

vcpkg_fixup_cmake_targets()

vcpkg_copy_pdbs()

file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)

