
include(vcpkg_common_functions)

vcpkg_from_github(
    OUT_SOURCE_PATH SOURCE_PATH
    REPO bkaradzic/bgfx
    REF 2edbd06ef6f1834a6aed5a75d7fa07f7ac9f4067
    SHA512 7ae977de244382b47de9de5b7152688b5581dfbc17373938edfe800d4570a52b3e4d439865f7b8c92f15e5bfa6a7859ef066c095a3ff581a3cdb34614201a4e6
    HEAD_REF master
    PATCHES
        0001-fix-shaderc-glslang-headers.patch
        0002-fix-shaderc-tinystl.patch
        0003-fix-shaderc-glslopt-shader-compute.patch
)

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

vcpkg_check_features(
    OUT_FEATURE_OPTIONS FEATURE_OPTIONS
    "tools"   BUILD_TOOLS
)

vcpkg_configure_cmake(
    SOURCE_PATH ${SOURCE_PATH}
    PREFER_NINJA
    OPTIONS ${FEATURE_OPTIONS}
    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)

