aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/cryptopp
diff options
context:
space:
mode:
authorEthan Morgan <ethan@gweithio.com>2026-02-14 16:44:06 +0000
committerEthan Morgan <ethan@gweithio.com>2026-02-14 16:44:06 +0000
commit54409423f767d8b1cf30cb7d0efca6b4ca138823 (patch)
treed915ac7828703ce4b963efdd9728a1777ba18c1e /vcpkg/ports/cryptopp
move to own git serverHEADmaster
Diffstat (limited to 'vcpkg/ports/cryptopp')
-rw-r--r--vcpkg/ports/cryptopp/cmake-support-pem-pack.patch33
-rw-r--r--vcpkg/ports/cryptopp/cryptopp.patch26
-rw-r--r--vcpkg/ports/cryptopp/patch.patch34
-rw-r--r--vcpkg/ports/cryptopp/portfile.cmake103
-rw-r--r--vcpkg/ports/cryptopp/vcpkg.json23
5 files changed, 219 insertions, 0 deletions
diff --git a/vcpkg/ports/cryptopp/cmake-support-pem-pack.patch b/vcpkg/ports/cryptopp/cmake-support-pem-pack.patch
new file mode 100644
index 0000000..4dac218
--- /dev/null
+++ b/vcpkg/ports/cryptopp/cmake-support-pem-pack.patch
@@ -0,0 +1,33 @@
+diff --git a/cryptopp/sources.cmake b/cryptopp/sources.cmake
+index 7918f03..58d74e2 100644
+--- a/cryptopp/sources.cmake
++++ b/cryptopp/sources.cmake
+@@ -182,6 +182,14 @@ set(cryptopp_SOURCES
+ zlib.cpp
+ )
+
++if (CRYPTOPP_PEM_PACK)
++ list(APPEND cryptopp_SOURCES
++ pem-com.cpp
++ pem-rd.cpp
++ pem-wr.cpp
++ )
++endif()
++
+ # ***** Library headers *****
+ set(cryptopp_HEADERS
+ 3way.h
+@@ -374,6 +382,13 @@ set(cryptopp_HEADERS
+ zlib.h
+ )
+
++if (CRYPTOPP_PEM_PACK)
++ list(APPEND cryptopp_HEADERS
++ pem-com.h
++ pem.h
++ )
++endif()
++
+ # ***** Test sources *****
+ set(cryptopp_SOURCES_TEST
+ # adhoc.cpp
diff --git a/vcpkg/ports/cryptopp/cryptopp.patch b/vcpkg/ports/cryptopp/cryptopp.patch
new file mode 100644
index 0000000..a1f66b4
--- /dev/null
+++ b/vcpkg/ports/cryptopp/cryptopp.patch
@@ -0,0 +1,26 @@
+diff --git a/secblock.h b/secblock.h
+index 5ab920f9..74d939cf 100644
+--- a/secblock.h
++++ b/secblock.h
+@@ -270,7 +270,7 @@ public:
+ /// \details VS.NET STL enforces the policy of "All STL-compliant allocators
+ /// have to provide a template class member called rebind".
+ template <class V> struct rebind { typedef AllocatorWithCleanup<V, T_Align16> other; };
+-#if (CRYPTOPP_MSC_VERSION >= 1500)
++#if (CRYPTOPP_MSC_VERSION >= 1500) || defined(__clang__)
+ AllocatorWithCleanup() {}
+ template <class V, bool A> AllocatorWithCleanup(const AllocatorWithCleanup<V, A> &) {}
+ #endif
+diff --git a/zdeflate.cpp b/zdeflate.cpp
+index b3514b55..20717c24 100644
+--- a/zdeflate.cpp
++++ b/zdeflate.cpp
+@@ -413,7 +413,7 @@ unsigned int Deflator::LongestMatch(unsigned int &bestMatch) const
+ {
+ CRYPTOPP_ASSERT(scan[2] == match[2]);
+ unsigned int len = (unsigned int)(
+-#if defined(_STDEXT_BEGIN) && !(defined(CRYPTOPP_MSC_VERSION) && (CRYPTOPP_MSC_VERSION < 1400 || CRYPTOPP_MSC_VERSION >= 1600)) && !defined(_STLPORT_VERSION)
++#if defined(_STDEXT_BEGIN) && !(defined(CRYPTOPP_MSC_VERSION) && (CRYPTOPP_MSC_VERSION < 1400 || CRYPTOPP_MSC_VERSION >= 1600)) && !defined(_STLPORT_VERSION) && !defined(__clang__)
+ stdext::unchecked_mismatch
+ #else
+ std::mismatch
diff --git a/vcpkg/ports/cryptopp/patch.patch b/vcpkg/ports/cryptopp/patch.patch
new file mode 100644
index 0000000..5e168d2
--- /dev/null
+++ b/vcpkg/ports/cryptopp/patch.patch
@@ -0,0 +1,34 @@
+diff --git a/config_cxx.h b/config_cxx.h
+index ffd57ad..353d7ce 100644
+--- a/config_cxx.h
++++ b/config_cxx.h
+@@ -217,7 +217,7 @@
+ // Also see https://github.com/weidai11/cryptopp/issues/980. I'm not sure what
+ // to do when the compiler defines __cpp_lib_uncaught_exceptions but the platform
+ // does not support std::uncaught_exceptions. What was Apple thinking???
+-#if defined(__clang__)
++#if defined(__clang__) && !defined(CRYPTOPP_MSC_VERSION)
+ # if __EXCEPTIONS && __has_feature(cxx_exceptions)
+ # if __cpp_lib_uncaught_exceptions >= 201411L
+ # define CRYPTOPP_CXX17_UNCAUGHT_EXCEPTIONS 1
+diff --git a/config_os.h b/config_os.h
+index 0994563..4546585 100644
+--- a/config_os.h
++++ b/config_os.h
+@@ -29,7 +29,7 @@
+ // https://www.cryptopp.com/wiki/Release_Process#Self_Tests
+ // The problems with Clang pretending to be other compilers is
+ // discussed at http://github.com/weidai11/cryptopp/issues/147.
+-#if (defined(_MSC_VER) && defined(__clang__))
++#if (defined(_MSC_VER) && _MSC_VER < 1930 && defined(__clang__))
+ # error: "Unsupported configuration"
+ #endif
+
+@@ -126,6 +126,7 @@
+ #endif
+
+ #ifdef CRYPTOPP_WIN32_AVAILABLE
++#include <winapifamily.h>
+ # if !defined(WINAPI_FAMILY)
+ # define THREAD_TIMER_AVAILABLE
+ # elif defined(WINAPI_FAMILY)
diff --git a/vcpkg/ports/cryptopp/portfile.cmake b/vcpkg/ports/cryptopp/portfile.cmake
new file mode 100644
index 0000000..7368f76
--- /dev/null
+++ b/vcpkg/ports/cryptopp/portfile.cmake
@@ -0,0 +1,103 @@
+vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
+string(REPLACE "." "_" CRYPTOPP_VERSION "${VERSION}")
+
+vcpkg_from_github(
+ OUT_SOURCE_PATH CMAKE_SOURCE_PATH
+ REPO abdes/cryptopp-cmake
+ REF "CRYPTOPP_${CRYPTOPP_VERSION}"
+ SHA512 3ec33b107ab627a514e1ebbc4b6522ee8552525f36730d9b5feb85e61ba7fc24fd36eb6050e328c6789ff60d47796beaa8eebf7dead787a34395294fae9bb733
+ HEAD_REF master
+ PATCHES
+ cmake-support-pem-pack.patch
+)
+
+vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO weidai11/cryptopp
+ REF "CRYPTOPP_${CRYPTOPP_VERSION}"
+ SHA512 28a67141155c9c15e3e6a2173b3a8487cc38a2a2ade73bf4a09814ca541be6b06e9a501be26f7e2f42a2f80df21b076aa5d8ad4224dc0a1f8d7f3b24deae465e
+ HEAD_REF master
+ PATCHES
+ patch.patch
+ cryptopp.patch
+)
+
+file(COPY "${CMAKE_SOURCE_PATH}/cryptopp" DESTINATION "${SOURCE_PATH}")
+file(COPY "${CMAKE_SOURCE_PATH}/cmake" DESTINATION "${SOURCE_PATH}")
+file(COPY "${CMAKE_SOURCE_PATH}/test" DESTINATION "${SOURCE_PATH}")
+file(COPY "${CMAKE_SOURCE_PATH}/cryptopp/cryptoppConfig.cmake" DESTINATION "${SOURCE_PATH}")
+file(COPY "${CMAKE_SOURCE_PATH}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
+
+vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
+ FEATURES
+ pem-pack CRYPTOPP_PEM_PACK
+)
+
+if("pem-pack" IN_LIST FEATURES)
+ vcpkg_from_github(
+ OUT_SOURCE_PATH PEM_PACK_SOURCE_PATH
+ REPO noloader/cryptopp-pem
+ REF 095f08ff2ef9bca7b81036a59f2395e4f08ce2e8
+ SHA512 49912758a635faca1f49665ac9552b20576b46e0283aaabc19bb012bdc80586106452018e5088b9b46967717982ca6022ca968edc4cac96a7506d2b1a3e4bf13
+ HEAD_REF master
+ )
+
+ file(GLOB PEM_PACK_FILES
+ ${PEM_PACK_SOURCE_PATH}/*.h
+ ${PEM_PACK_SOURCE_PATH}/*.cpp
+ )
+ file(COPY ${PEM_PACK_FILES} DESTINATION ${SOURCE_PATH})
+endif()
+
+# disable assembly on ARM Windows to fix broken build
+if (VCPKG_TARGET_IS_WINDOWS AND VCPKG_TARGET_ARCHITECTURE MATCHES "^arm")
+ set(CRYPTOPP_DISABLE_ASM "ON")
+elseif(NOT DEFINED CRYPTOPP_DISABLE_ASM) # Allow disabling using a triplet file
+ set(CRYPTOPP_DISABLE_ASM "OFF")
+endif()
+
+# Dynamic linking should be avoided for Crypto++ to reduce the attack surface,
+# so generate a static lib for both dynamic and static vcpkg targets.
+# See also:
+# https://www.cryptopp.com/wiki/Visual_Studio#Dynamic_Runtime_Linking
+# https://www.cryptopp.com/wiki/Visual_Studio#The_DLL
+
+vcpkg_cmake_configure(
+ SOURCE_PATH "${SOURCE_PATH}"
+ OPTIONS
+ -DCRYPTOPP_SOURCES=${SOURCE_PATH}
+ -DCRYPTOPP_BUILD_SHARED=OFF
+ -DBUILD_STATIC=ON
+ -DCRYPTOPP_BUILD_TESTING=OFF
+ -DCRYPTOPP_BUILD_DOCUMENTATION=OFF
+ -DDISABLE_ASM=${CRYPTOPP_DISABLE_ASM}
+ -DUSE_INTERMEDIATE_OBJECTS_TARGET=OFF # Not required when we build static only
+ -DCMAKE_POLICY_DEFAULT_CMP0063=NEW # Honor "<LANG>_VISIBILITY_PRESET" properties
+ ${FEATURE_OPTIONS}
+ MAYBE_UNUSED_VARIABLES
+ BUILD_STATIC
+ USE_INTERMEDIATE_OBJECTS_TARGET
+ CMAKE_POLICY_DEFAULT_CMP0063
+)
+
+vcpkg_cmake_install()
+vcpkg_cmake_config_fixup(CONFIG_PATH share/cmake/cryptopp)
+
+if(NOT VCPKG_BUILD_TYPE)
+ file(RENAME "${CURRENT_PACKAGES_DIR}/debug/share/pkgconfig" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig")
+endif()
+file(RENAME "${CURRENT_PACKAGES_DIR}/share/pkgconfig" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig")
+vcpkg_fixup_pkgconfig()
+
+# There is no way to suppress installation of the headers and resource files in debug build.
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
+
+
+if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
+ file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
+endif()
+
+# Handle copyright
+file(COPY "${SOURCE_PATH}/License.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
+file(RENAME "${CURRENT_PACKAGES_DIR}/share/${PORT}/License.txt" "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright")
diff --git a/vcpkg/ports/cryptopp/vcpkg.json b/vcpkg/ports/cryptopp/vcpkg.json
new file mode 100644
index 0000000..1b847b9
--- /dev/null
+++ b/vcpkg/ports/cryptopp/vcpkg.json
@@ -0,0 +1,23 @@
+{
+ "name": "cryptopp",
+ "version": "8.9.0",
+ "port-version": 2,
+ "description": "Crypto++ is a free C++ class library of cryptographic schemes.",
+ "homepage": "https://github.com/weidai11/cryptopp",
+ "license": "BSL-1.0",
+ "dependencies": [
+ {
+ "name": "vcpkg-cmake",
+ "host": true
+ },
+ {
+ "name": "vcpkg-cmake-config",
+ "host": true
+ }
+ ],
+ "features": {
+ "pem-pack": {
+ "description": "Crypto++ with PEM pack"
+ }
+ }
+}