vcpkg_from_github(
        OUT_SOURCE_PATH REPO_ROOT_PATH
        REPO {{ git.repo }}
        REF {{ git.ref }}
        SHA512 {{ git.sha }}
        HEAD_REF {{ git.head_ref }}
)

{% if git.subdirectory %}set(SOURCE_PATH "${REPO_ROOT_PATH}/{{ git.subdirectory }}"){% else %}set(SOURCE_PATH "${REPO_ROOT_PATH}"){% endif %}

vcpkg_cmake_configure(
        SOURCE_PATH "${SOURCE_PATH}"
        {% if module.options %}OPTIONS{% for option in module.options %}
        -D{{ option }}{% endfor %}{% endif %}

        MAYBE_UNUSED_VARIABLES
            PORTAL_BUILD_TESTS
)

vcpkg_cmake_install()

vcpkg_cmake_config_fixup(
        PACKAGE_NAME {{ module.name }}
        CONFIG_PATH share/{{ module.name }}
)

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share")

configure_file("${CMAKE_CURRENT_LIST_DIR}/usage" "${CURRENT_PACKAGES_DIR}/share/${PORT}/usage" COPYONLY)

vcpkg_copy_pdbs()
vcpkg_install_copyright(FILE_LIST "${REPO_ROOT_PATH}/LICENSE")