| 1 |
vcpkg_check_linkage(ONLY_STATIC_LIBRARY) |
| 2 |
string(REPLACE "." "_" CRYPTOPP_VERSION "${VERSION}") |
| 3 |
|
| 4 |
vcpkg_from_github( |
| 5 |
OUT_SOURCE_PATH CMAKE_SOURCE_PATH |
| 6 |
REPO abdes/cryptopp-cmake |
| 7 |
REF "CRYPTOPP_${CRYPTOPP_VERSION}" |
| 8 |
SHA512 3ec33b107ab627a514e1ebbc4b6522ee8552525f36730d9b5feb85e61ba7fc24fd36eb6050e328c6789ff60d47796beaa8eebf7dead787a34395294fae9bb733 |
| 9 |
HEAD_REF master |
| 10 |
) |
| 11 |
|
| 12 |
vcpkg_from_github( |
| 13 |
OUT_SOURCE_PATH SOURCE_PATH |
| 14 |
REPO weidai11/cryptopp |
| 15 |
REF "CRYPTOPP_${CRYPTOPP_VERSION}" |
| 16 |
SHA512 28a67141155c9c15e3e6a2173b3a8487cc38a2a2ade73bf4a09814ca541be6b06e9a501be26f7e2f42a2f80df21b076aa5d8ad4224dc0a1f8d7f3b24deae465e |
| 17 |
HEAD_REF master |
| 18 |
PATCHES |
| 19 |
patch.patch |
| 20 |
cryptopp.patch |
| 21 |
) |
| 22 |
|
| 23 |
file(COPY "${CMAKE_SOURCE_PATH}/cryptopp" DESTINATION "${SOURCE_PATH}") |
| 24 |
file(COPY "${CMAKE_SOURCE_PATH}/cmake" DESTINATION "${SOURCE_PATH}") |
| 25 |
file(COPY "${CMAKE_SOURCE_PATH}/test" DESTINATION "${SOURCE_PATH}") |
| 26 |
file(COPY "${CMAKE_SOURCE_PATH}/cryptopp/cryptoppConfig.cmake" DESTINATION "${SOURCE_PATH}") |
| 27 |
file(COPY "${CMAKE_SOURCE_PATH}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}") |
| 28 |
|
| 29 |
if("pem-pack" IN_LIST FEATURES) |
| 30 |
vcpkg_from_github( |
| 31 |
OUT_SOURCE_PATH PEM_PACK_SOURCE_PATH |
| 32 |
REPO noloader/cryptopp-pem |
| 33 |
REF 095f08ff2ef9bca7b81036a59f2395e4f08ce2e8 |
| 34 |
SHA512 49912758a635faca1f49665ac9552b20576b46e0283aaabc19bb012bdc80586106452018e5088b9b46967717982ca6022ca968edc4cac96a7506d2b1a3e4bf13 |
| 35 |
HEAD_REF master |
| 36 |
) |
| 37 |
|
| 38 |
file(GLOB PEM_PACK_FILES |
| 39 |
${PEM_PACK_SOURCE_PATH}/*.h |
| 40 |
${PEM_PACK_SOURCE_PATH}/*.cpp |
| 41 |
) |
| 42 |
file(INSTALL ${PEM_PACK_FILES} DESTINATION "${CURRENT_PACKAGES_DIR}/include/${PORT}") |
| 43 |
endif() |
| 44 |
|
| 45 |
# disable assembly on ARM Windows to fix broken build |
| 46 |
if (VCPKG_TARGET_IS_WINDOWS AND VCPKG_TARGET_ARCHITECTURE MATCHES "^arm") |
| 47 |
set(CRYPTOPP_DISABLE_ASM "ON") |
| 48 |
elseif(NOT DEFINED CRYPTOPP_DISABLE_ASM) # Allow disabling using a triplet file |
| 49 |
set(CRYPTOPP_DISABLE_ASM "OFF") |
| 50 |
endif() |
| 51 |
|
| 52 |
# Dynamic linking should be avoided for Crypto++ to reduce the attack surface, |
| 53 |
# so generate a static lib for both dynamic and static vcpkg targets. |
| 54 |
# See also: |
| 55 |
# https://www.cryptopp.com/wiki/Visual_Studio#Dynamic_Runtime_Linking |
| 56 |
# https://www.cryptopp.com/wiki/Visual_Studio#The_DLL |
| 57 |
|
| 58 |
vcpkg_cmake_configure( |
| 59 |
SOURCE_PATH "${SOURCE_PATH}" |
| 60 |
OPTIONS |
| 61 |
-DCRYPTOPP_SOURCES=${SOURCE_PATH} |
| 62 |
-DCRYPTOPP_BUILD_SHARED=OFF |
| 63 |
-DBUILD_STATIC=ON |
| 64 |
-DCRYPTOPP_BUILD_TESTING=OFF |
| 65 |
-DCRYPTOPP_BUILD_DOCUMENTATION=OFF |
| 66 |
-DDISABLE_ASM=${CRYPTOPP_DISABLE_ASM} |
| 67 |
-DUSE_INTERMEDIATE_OBJECTS_TARGET=OFF # Not required when we build static only |
| 68 |
-DCMAKE_POLICY_DEFAULT_CMP0063=NEW # Honor "<LANG>_VISIBILITY_PRESET" properties |
| 69 |
-DCMAKE_CXX_VISIBILITY_PRESET=default |
| 70 |
-DCMAKE_VISIBILITY_INLINES_HIDDEN=OFF |
| 71 |
MAYBE_UNUSED_VARIABLES |
| 72 |
BUILD_STATIC |
| 73 |
USE_INTERMEDIATE_OBJECTS_TARGET |
| 74 |
CMAKE_POLICY_DEFAULT_CMP0063 |
| 75 |
) |
| 76 |
|
| 77 |
vcpkg_cmake_install() |
| 78 |
vcpkg_cmake_config_fixup(CONFIG_PATH share/cmake/cryptopp) |
| 79 |
|
| 80 |
if(NOT VCPKG_BUILD_TYPE) |
| 81 |
file(RENAME "${CURRENT_PACKAGES_DIR}/debug/share/pkgconfig" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig") |
| 82 |
endif() |
| 83 |
file(RENAME "${CURRENT_PACKAGES_DIR}/share/pkgconfig" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig") |
| 84 |
vcpkg_fixup_pkgconfig() |
| 85 |
|
| 86 |
# There is no way to suppress installation of the headers and resource files in debug build. |
| 87 |
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") |
| 88 |
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") |
| 89 |
|
| 90 |
|
| 91 |
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") |
| 92 |
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") |
| 93 |
endif() |
| 94 |
|
| 95 |
# Handle copyright |
| 96 |
file(COPY "${SOURCE_PATH}/License.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") |
| 97 |
file(RENAME "${CURRENT_PACKAGES_DIR}/share/${PORT}/License.txt" "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright") |