include(vcpkg_common_functions)
set(OPENSSL_VERSION 1.1.0g)
set(MASTER_COPY_SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src)

file(READ "${VCPKG_ROOT_DIR}/_env/EXTERNAL_OPENSSL_ANDROID_URLS.txt" EXTERNAL_OPENSSL_ANDROID_URLS)
file(READ "${VCPKG_ROOT_DIR}/_env/EXTERNAL_OPENSSL_ANDROID_SHA512.txt" EXTERNAL_OPENSSL_ANDROID_SHA512)

message("MASTER_COPY_SOURCE_PATH ${MASTER_COPY_SOURCE_PATH}")
vcpkg_download_distfile(
    OPENSSL_SOURCE_ARCHIVE
    URLS ${EXTERNAL_OPENSSL_ANDROID_URLS}
    SHA512 ${EXTERNAL_OPENSSL_ANDROID_SHA512}
    FILENAME openssl-1.1.0g_armv8.tgz
)

vcpkg_extract_source_archive(${OPENSSL_SOURCE_ARCHIVE})

file(COPY ${MASTER_COPY_SOURCE_PATH}/include DESTINATION ${CURRENT_PACKAGES_DIR})
file(GLOB LIBS ${MASTER_COPY_SOURCE_PATH}/lib/*.a)
file(COPY ${LIBS} DESTINATION ${CURRENT_PACKAGES_DIR}/libs)
file(COPY ${LIBS} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/libs)
file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/LICENSE.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/openssl-android RENAME copyright)





