set(CODEPORTING_VERSION 22.5)
set(CODEPORTING_SHA512 "4b4b8b2fc29803d09558587a8d25793c3d78dad903e1c1deffe000487baf0125f7fd2c92b6a512e951900f3de9a7a73af4068cbdd7fa9e7c68360cbb8e393f33")
set(CODEPORTING_DOWNLOAD_URL "https://downloads.codeporting.com/native/cs2cpp/new-releases/codeporting.native-cs2cpp-22.4-api/fb27349dbf204edab1029a6aecb496d2")

vcpkg_download_distfile(ARCHIVE 
  URLS "${CODEPORTING_DOWNLOAD_URL}"
  FILENAME "codePorting.Native.Cs2Cpp_api_${CODEPORTING_VERSION}.zip"
  SHA512 "${CODEPORTING_SHA512}")

vcpkg_extract_source_archive(SOURCE_PATH ARCHIVE "${ARCHIVE}")

if (TARGET_TRIPLET STREQUAL "x64-windows")
  set(SUFFIX "_vc14x64")
elseif (TARGET_TRIPLET STREQUAL "x86-windows")
  set(SUFFIX "_vc14x86")
elseif (TARGET_TRIPLET STREQUAL "x64-osx")
  set(SUFFIX "_appleclang")
elseif (TARGET_TRIPLET STREQUAL "x64-linux")
  set(SUFFIX "_x86_64_libstdcpp_libc2.23")
endif()

file(INSTALL ${SOURCE_PATH}/include DESTINATION ${CURRENT_PACKAGES_DIR})

file(INSTALL ${SOURCE_PATH}/lib/${VCPKG_TARGET_SHARED_LIBRARY_PREFIX}aspose_cpp${SUFFIX}${VCPKG_TARGET_SHARED_LIBRARY_SUFFIX} DESTINATION ${CURRENT_PACKAGES_DIR}/bin)
if (EXISTS ${SOURCE_PATH}/lib/${VCPKG_TARGET_SHARED_LIBRARY_PREFIX}aspose_cpp${SUFFIX}d${VCPKG_TARGET_SHARED_LIBRARY_SUFFIX})
  file(INSTALL ${SOURCE_PATH}/lib/${VCPKG_TARGET_SHARED_LIBRARY_PREFIX}aspose_cpp${SUFFIX}d${VCPKG_TARGET_SHARED_LIBRARY_SUFFIX} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin)
endif()

if (EXISTS ${SOURCE_PATH}/lib/${VCPKG_TARGET_IMPORT_LIBRARY_PREFIX}aspose_cpp${SUFFIX}${VCPKG_TARGET_IMPORT_LIBRARY_SUFFIX})
  file(INSTALL ${SOURCE_PATH}/lib/${VCPKG_TARGET_IMPORT_LIBRARY_PREFIX}aspose_cpp${SUFFIX}${VCPKG_TARGET_IMPORT_LIBRARY_SUFFIX} DESTINATION ${CURRENT_PACKAGES_DIR}/lib)
endif()
if (EXISTS ${SOURCE_PATH}/lib/${VCPKG_TARGET_IMPORT_LIBRARY_PREFIX}aspose_cpp${SUFFIX}d${VCPKG_TARGET_IMPORT_LIBRARY_SUFFIX})
  file(INSTALL ${SOURCE_PATH}/lib/${VCPKG_TARGET_IMPORT_LIBRARY_PREFIX}aspose_cpp${SUFFIX}d${VCPKG_TARGET_IMPORT_LIBRARY_SUFFIX} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib)
endif()

file(INSTALL ${SOURCE_PATH}/codeporting.native.cs2cpp-config-version.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME codeporting-native-cs2cpp-api-config-version.cmake )
file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/codeporting-native-cs2cpp-api-config.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT})

file(INSTALL ${SOURCE_PATH}/licenses DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT})
file(INSTALL ${SOURCE_PATH}/misc DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT})
file(INSTALL ${SOURCE_PATH}/pch DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT})

file(INSTALL ${SOURCE_PATH}/licenses/Aspose_End-User-License-Agreement.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)