From 60d1def6f8923cdc7ee64e087b15461f3723157f Mon Sep 17 00:00:00 2001 From: Vitor K Date: Wed, 5 Jan 2022 15:35:07 +0100 Subject: [PATCH] Update cryptopp to 8.5.0 (#5669) * Update cryptopp to 8.3.0 Modified the CMakeLists.txt based on the noloader/cryptopp-cmake 8.3.0 CMakeLists.txt. * Update cryptopp to version 8.5.0 --- externals/cryptopp/CMakeLists.txt | 454 +++++++++++++++++++++--------- externals/cryptopp/cryptopp | 2 +- 2 files changed, 325 insertions(+), 131 deletions(-) diff --git a/externals/cryptopp/CMakeLists.txt b/externals/cryptopp/CMakeLists.txt index c86bc35413..7d53518ee2 100644 --- a/externals/cryptopp/CMakeLists.txt +++ b/externals/cryptopp/CMakeLists.txt @@ -1,31 +1,46 @@ -# The CMakeLists.txt shipped with cryptopp pollutes our option list and installation list, -# so we made our own one. This is basically a trimmed down version of the shipped CMakeLists.txt +# A trimmed down version of the CMakeLists.txt from noloader/cryptopp-cmake # The differences are: # - removed support for legacy CMake versions # - removed support for 32-bit -# - removed -march=native flag -# - removed rdrand module.asm as a workaround for an issue (see below) -# - added prefix "CRYPTOPP_" to all option names +# - added prefix "CRYPTOPP_OPT_" to all option names # - disabled testing # - disabled installation # - disabled documentation # - configured to build a static library only # - adds include directories to the library target +cmake_minimum_required(VERSION 3.1) +if (POLICY CMP0048) + cmake_policy(SET CMP0048 NEW) +endif () +project(cryptopp VERSION 8.5.0) +if (POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) +endif () + +set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cryptopp) + include(TestBigEndian) +include(GNUInstallDirs) include(CheckCXXCompilerFlag) +set(TEST_PROG_DIR ${SRC_DIR}/TestPrograms) +set(TEST_CXX_FILE ${TEST_PROG_DIR}/test_cxx.cxx) + #============================================================================ # Settable options #============================================================================ -option(CRYPTOPP_DISABLE_ASM "Disable ASM" OFF) -option(CRYPTOPP_DISABLE_SSSE3 "Disable SSSE3" OFF) -option(CRYPTOPP_DISABLE_AESNI "Disable AES-NI" OFF) -option(CRYPTOPP_DISABLE_CXXFLAGS_OPTIMIZATIONS "Disable CXXFLAGS optimizations" OFF) +option(CRYPTOPP_OPT_DISABLE_ASM "Disable ASM" OFF) +option(CRYPTOPP_OPT_DISABLE_SSSE3 "Disable SSSE3" OFF) +option(CRYPTOPP_OPT_DISABLE_SSE4 "Disable SSE4" OFF) +option(CRYPTOPP_OPT_DISABLE_AESNI "Disable AES-NI" OFF) +option(CRYPTOPP_OPT_DISABLE_SHA "Disable SHA" OFF) +option(CRYPTOPP_OPT_DISABLE_AVX "Disable AVX" OFF) +option(CRYPTOPP_OPT_DISABLE_AVX2 "Disable AVX2" OFF) #============================================================================ -# Internal compiler options +# Compiler options #============================================================================ # Only set when cross-compiling, http://www.vtk.org/Wiki/CMake_Cross_Compiling @@ -35,13 +50,14 @@ else() set(CRYPTOPP_CROSS_COMPILE 0) endif() +set(CRYPTOPP_COMPILE_DEFINITIONS) +set(CRYPTOPP_COMPILE_OPTIONS) + # Don't use RPATH's. The resulting binary could fail a security audit. -if (NOT CMAKE_VERSION VERSION_LESS 2.8.12) - set(CMAKE_MACOSX_RPATH 0) -endif() +set(CMAKE_MACOSX_RPATH 0) if(CMAKE_CXX_COMPILER_ID MATCHES "Intel") - add_definitions(-wd68 -wd186 -wd279 -wd327 -wd161 -wd3180) + list(APPEND CRYPTOPP_COMPILE_OPTIONS -wd68 -wd186 -wd279 -wd327 -wd161 -wd3180) endif() if(MSVC) @@ -55,15 +71,36 @@ if(IS_BIG_ENDIAN) add_definitions(-DIS_BIG_ENDIAN) endif() -if(CRYPTOPP_DISABLE_ASM) - add_definitions(-DCRYPTOPP_DISABLE_ASM) -endif() -if(CRYPTOPP_DISABLE_SSSE3) - add_definitions(-DCRYPTOPP_DISABLE_SSSE3) -endif() -if(CRYPTOPP_DISABLE_AESNI) - add_definitions(-DCRYPTOPP_DISABLE_AESNI) -endif() +if (CRYPTOPP_OPT_DISABLE_ASM) + list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_ASM) +endif () +if (CRYPTOPP_OPT_DISABLE_SSSE3) + list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_SSSE3) +endif () +if (CRYPTOPP_OPT_DISABLE_SSE4) + list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_SSSE4) +endif () +if (CRYPTOPP_OPT_DISABLE_CLMUL) + list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_CLMUL) +endif () +if (CRYPTOPP_OPT_DISABLE_AESNI) + list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_AESNI) +endif () +if (CRYPTOPP_OPT_DISABLE_RDRAND) + list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_RDRAND) +endif () +if (CRYPTOPP_OPT_DISABLE_RDSEED) + list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_RDSEED) +endif () +if (CRYPTOPP_OPT_DISABLE_AVX) + list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_AVX) +endif () +if (CRYPTOPP_OPT_DISABLE_AVX2) + list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_AVX2) +endif () +if (CRYPTOPP_OPT_DISABLE_SHA) + list(APPEND CRYPTOPP_COMPILE_DEFINITIONS CRYPTOPP_DISABLE_SHA) +endif () # We need the output 'uname -s' for Unix and Linux system detection if (NOT CRYPTOPP_CROSS_COMPILE) @@ -87,11 +124,110 @@ if (NOT CRYPTOPP_CROSS_COMPILE) string(REGEX REPLACE "\n$" "" UNAME_MACHINE "${UNAME_MACHINE}") endif() -if(WINDOWS_STORE OR WINDOWS_PHONE) - if("${CMAKE_SYSTEM_VERSION}" MATCHES "10\\.0.*") - SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D\"_WIN32_WINNT=0x0A00\"" ) - endif() - SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /FI\"winapifamily.h\"" ) +############################################################################### + +# Try to find a Posix compatible grep and sed. Solaris, Digital Unix, +# Tru64, HP-UX and a few others need tweaking + +if (EXISTS /usr/xpg4/bin/grep) + set(GREP_CMD /usr/xpg4/bin/grep) +elseif (EXISTS /usr/gnu/bin/grep) + set(GREP_CMD /usr/gnu/bin/grep) +elseif (EXISTS /usr/linux/bin/grep) + set(GREP_CMD /usr/linux/bin/grep) +else () + set(GREP_CMD grep) +endif () + +if (EXISTS /usr/xpg4/bin/sed) + set(SED_CMD /usr/xpg4/bin/sed) +elseif (EXISTS /usr/gnu/bin/sed) + set(SED_CMD /usr/gnu/bin/sed) +elseif (EXISTS /usr/linux/bin/sed) + set(SED_CMD /usr/linux/bin/sed) +else () + set(SED_CMD sed) +endif () + +############################################################################### + +function(CheckCompileOption opt var) + CHECK_CXX_COMPILER_FLAG(${opt} ${var}) +endfunction(CheckCompileOption) + +function(CheckCompileLinkOption opt var prog) + + if (MSVC) + + # TODO: improve this... + CHECK_CXX_COMPILER_FLAG(${opt} ${var}) + + elseif (APPLE) + + message(STATUS "Performing Test ${var}") + try_compile(COMMAND_SUCCESS ${CMAKE_BINARY_DIR} ${prog} COMPILE_DEFINITIONS ${opt}) + if (COMMAND_SUCCESS) + set(${var} 1 PARENT_SCOPE) + message(STATUS "Performing Test ${var} - Success") + else () + set(${var} 0 PARENT_SCOPE) + message(STATUS "Performing Test ${var} - Failed") + endif () + + else () + + message(STATUS "Performing Test ${var}") + try_compile(COMMAND_SUCCESS ${CMAKE_BINARY_DIR} ${prog} COMPILE_DEFINITIONS ${opt}) + if (COMMAND_SUCCESS) + set(${var} 1 PARENT_SCOPE) + message(STATUS "Performing Test ${var} - Success") + else () + set(${var} 0 PARENT_SCOPE) + message(STATUS "Performing Test ${var} - Failed") + endif () + + endif () + +endfunction(CheckCompileLinkOption) + +function(AddCompileOption opt) + + if ("${COMMAND_OUTPUT}" NOT STREQUAL "") + list(APPEND CRYPTOPP_COMPILE_OPTIONS "${opt}") + endif () + +endfunction(AddCompileOption) + +############################################################################### + +function(DumpMachine output pattern) + + if (MSVC) + + # CMake does not provide a generic shell/terminal mechanism + # and Microsoft environments don't know what 'sh' is. + set(${output} 0 PARENT_SCOPE) + + else () + if(CMAKE_SYSTEM_PROCESSOR MATCHES ${pattern}) + set(${output} TRUE PARENT_SCOPE) + endif() + endif() + +endfunction(DumpMachine) + +# Thansk to Anonimal for MinGW; see http://github.com/weidai11/cryptopp/issues/466 +DumpMachine(CRYPTOPP_AMD64 "(x86_64|AMD64|amd64)") +DumpMachine(CRYPTOPP_MINGW64 "(w64-mingw32)|(mingw64)") +DumpMachine(CRYPTOPP_ARMV8 "(armv8|aarch64)") + +############################################################################### + +if(MSVC) + if(CMAKE_SYSTEM_VERSION MATCHES "10\\.0.*") + list(APPEND CRYPTOPP_COMPILE_DEFINITIONS "_WIN32_WINNT=0x0A00") + endif() + list(APPEND CRYPTOPP_COMPILE_OPTIONS /FI winapifamily.h) endif() # Enable PIC for all targets except Windows and 32-bit x86. @@ -114,7 +250,13 @@ endif() #============================================================================ # Library headers -file(GLOB cryptopp_HEADERS cryptopp/*.h) +file(GLOB cryptopp_HEADERS ${SRC_DIR}/*.h) + +# Remove headers used to build test suite +list(REMOVE_ITEM cryptopp_HEADERS + ${SRC_DIR}/bench.h + ${SRC_DIR}/validate.h + ) # Library sources. # These have been trimmed to include only things Citra uses. This speeds up @@ -124,117 +266,169 @@ set(cryptopp_SOURCES # to avoid "problems associated with C++ static initialization order", # but doesn't actually tell what could go wrong. Better safe than sorry # I guess... - cryptopp/cryptlib.cpp - cryptopp/cpu.cpp - cryptopp/integer.cpp + ${SRC_DIR}/cryptlib.cpp + ${SRC_DIR}/cpu.cpp + ${SRC_DIR}/integer.cpp - cryptopp/algparam.cpp - cryptopp/asn.cpp - cryptopp/authenc.cpp - cryptopp/base64.cpp - cryptopp/basecode.cpp - cryptopp/ccm.cpp - cryptopp/crc-simd.cpp - cryptopp/des.cpp - cryptopp/dessp.cpp - cryptopp/dll.cpp - cryptopp/ec2n.cpp - cryptopp/ecp.cpp - cryptopp/filters.cpp - cryptopp/fips140.cpp - cryptopp/gcm-simd.cpp - cryptopp/gf2n.cpp - cryptopp/gfpcrypt.cpp - cryptopp/hex.cpp - cryptopp/hmac.cpp - cryptopp/hrtimer.cpp - cryptopp/iterhash.cpp - cryptopp/md5.cpp - cryptopp/misc.cpp - cryptopp/modes.cpp - cryptopp/mqueue.cpp - cryptopp/nbtheory.cpp - cryptopp/neon-simd.cpp - cryptopp/oaep.cpp - cryptopp/osrng.cpp - cryptopp/ppc-simd.cpp - cryptopp/pubkey.cpp - cryptopp/queue.cpp - cryptopp/randpool.cpp - cryptopp/rdtables.cpp - cryptopp/rijndael-simd.cpp - cryptopp/rijndael.cpp - cryptopp/rng.cpp - cryptopp/sha-simd.cpp - cryptopp/sha.cpp - cryptopp/sse-simd.cpp + ${SRC_DIR}/algparam.cpp + ${SRC_DIR}/allocate.cpp + ${SRC_DIR}/asn.cpp + ${SRC_DIR}/authenc.cpp + ${SRC_DIR}/base64.cpp + ${SRC_DIR}/basecode.cpp + ${SRC_DIR}/ccm.cpp + ${SRC_DIR}/crc_simd.cpp + ${SRC_DIR}/des.cpp + ${SRC_DIR}/dessp.cpp + ${SRC_DIR}/dll.cpp + ${SRC_DIR}/ec2n.cpp + ${SRC_DIR}/ecp.cpp + ${SRC_DIR}/filters.cpp + ${SRC_DIR}/fips140.cpp + ${SRC_DIR}/gcm_simd.cpp + ${SRC_DIR}/gf2n_simd.cpp + ${SRC_DIR}/gf2n.cpp + ${SRC_DIR}/gfpcrypt.cpp + ${SRC_DIR}/hex.cpp + ${SRC_DIR}/hmac.cpp + ${SRC_DIR}/hrtimer.cpp + ${SRC_DIR}/iterhash.cpp + ${SRC_DIR}/md5.cpp + ${SRC_DIR}/misc.cpp + ${SRC_DIR}/modes.cpp + ${SRC_DIR}/mqueue.cpp + ${SRC_DIR}/nbtheory.cpp + ${SRC_DIR}/neon_simd.cpp + ${SRC_DIR}/oaep.cpp + ${SRC_DIR}/osrng.cpp + ${SRC_DIR}/ppc_simd.cpp + ${SRC_DIR}/pubkey.cpp + ${SRC_DIR}/queue.cpp + ${SRC_DIR}/randpool.cpp + ${SRC_DIR}/rdtables.cpp + ${SRC_DIR}/rijndael_simd.cpp + ${SRC_DIR}/rijndael.cpp + ${SRC_DIR}/rng.cpp + ${SRC_DIR}/sha_simd.cpp + ${SRC_DIR}/sha.cpp + ${SRC_DIR}/sse_simd.cpp ) -if (MINGW OR WIN32) - list(APPEND cryptopp_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/winpipes.cpp) +if(ANDROID) + include_directories(${ANDROID_NDK}/sources/android/cpufeatures) + list(APPEND cryptopp_SOURCES ${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c) +endif() + +set(cryptopp_SOURCES_ASM) + +if (MSVC AND NOT DISABLE_ASM) + if (${CMAKE_GENERATOR} MATCHES ".*ARM") + message(STATUS "Disabling ASM because ARM is specified as target platform.") + else () + enable_language(ASM_MASM) + list(APPEND cryptopp_SOURCES_ASM + ${SRC_DIR}/rdrand.asm + ${SRC_DIR}/rdseed.asm + ) + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + list(APPEND cryptopp_SOURCES_ASM + ${SRC_DIR}/x64dll.asm + ${SRC_DIR}/x64masm.asm + ) + set_source_files_properties(${cryptopp_SOURCES_ASM} PROPERTIES COMPILE_DEFINITIONS "_M_X64") + else () + set_source_files_properties(${cryptopp_SOURCES_ASM} PROPERTIES COMPILE_DEFINITIONS "_M_X86" COMPILE_FLAGS "/safeseh") + endif () + set_source_files_properties(${cryptopp_SOURCES_ASM} PROPERTIES LANGUAGE ASM_MASM) + endif () endif () -if(MSVC AND NOT CRYPTOPP_DISABLE_ASM) - if(${CMAKE_GENERATOR} MATCHES ".*ARM") - message(STATUS "Disabling ASM because ARM is specified as target platform.") - else() - # Note that we removed rdrand.asm. This is a workaround for the issue that rdrand.asm cannnot compiled properly - # on MSVC. Because there is also a rdrand.S file in the submodule, CMake will specify the target path for - # rdrand.asm as "/crytopp.dir/{Debug|Release}/cryptopp/rdrand.asm.obj". The additional target folder "cryptopp" - # is specified because the file rdrand.asm is in the source folder "cryptopp". But MSVC assembler can't build - # target file to an non-existing folder("cryptopp"). - list(APPEND cryptopp_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/x64dll.asm) - list(APPEND cryptopp_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/x64masm.asm) - # list(APPEND cryptopp_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/rdrand.asm) - set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/x64dll.asm PROPERTIES COMPILE_FLAGS "/D_M_X64") - set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/x64masm.asm PROPERTIES COMPILE_FLAGS "/D_M_X64") - # set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/rdrand.asm PROPERTIES COMPILE_FLAGS "/D_M_X64") - enable_language(ASM_MASM) - endif() -endif() +#============================================================================ +# Architecture flags +#============================================================================ -if ((CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT CRYPTOPP_DISABLE_ASM) - check_cxx_compiler_flag(-msse2 CRYPTOPP_HAS_MSSE2) - check_cxx_compiler_flag(-mssse3 CRYPTOPP_HAS_MSSSE3) - check_cxx_compiler_flag(-msse4.1 CRYPTOPP_HAS_MSSE41) - check_cxx_compiler_flag(-msse4.2 CRYPTOPP_HAS_MSSE42) - check_cxx_compiler_flag(-maes CRYPTOPP_HAS_MAES) - check_cxx_compiler_flag(-mpclmul CRYPTOPP_HAS_PCLMUL) - check_cxx_compiler_flag(-msha CRYPTOPP_HAS_MSHA) - check_cxx_compiler_flag(-march=armv8-a+crc CRYPTOPP_HAS_ARMV8_CRC32) - check_cxx_compiler_flag(-march=armv8-a+crypto CRYPTOPP_HAS_ARMV8_CRYPTO) - if (CRYPTOPP_HAS_MSSE2) - set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/sse-simd.cpp PROPERTIES COMPILE_FLAGS "-msse2") - endif() - if (CRYPTOPP_HAS_MSSSE3 AND CRYPTOPP_HAS_MAES AND CRYPTOPP_HAS_PCLMUL) - set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/gcm-simd.cpp - PROPERTIES COMPILE_FLAGS "-mssse3 -maes -mpclmul") - endif() - if (CRYPTOPP_HAS_MSSE41 AND CRYPTOPP_HAS_MAES) - set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/rijndael-simd.cpp PROPERTIES COMPILE_FLAGS "-msse4.1 -maes") - endif() - if (CRYPTOPP_HAS_MSSE42) - set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/crc-simd.cpp - PROPERTIES COMPILE_FLAGS "-msse4.2") - endif() - if (CRYPTOPP_HAS_MSSE42 AND CRYPTOPP_HAS_MSHA) - set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/sha-simd.cpp PROPERTIES COMPILE_FLAGS "-msse4.2 -msha") - endif() - if (CRYPTOPP_HAS_ARMV8_CRC32) - set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/crc-simd.cpp - PROPERTIES COMPILE_FLAGS "-march=armv8-a+crc") - endif() - if (CRYPTOPP_HAS_ARMV8_CRYPTO) - set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/rijndael-simd.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/sha-simd.cpp - PROPERTIES COMPILE_FLAGS "-march=armv8-a+crypto") - endif() -endif() +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Intel" OR CMAKE_CXX_COMPILER MATCHES "xlC") + + if (CRYPTOPP_AMD64 OR CRYPTOPP_I386) + CheckCompileLinkOption("-msse2" CRYPTOPP_IA32_SSE2 + "${TEST_PROG_DIR}/test_x86_sse2.cxx") + CheckCompileLinkOption("-mssse3" CRYPTOPP_IA32_SSSE3 + "${TEST_PROG_DIR}/test_x86_ssse3.cxx") + CheckCompileLinkOption("-msse4.1" CRYPTOPP_IA32_SSE41 + "${TEST_PROG_DIR}/test_x86_sse41.cxx") + CheckCompileLinkOption("-msse4.2" CRYPTOPP_IA32_SSE42 + "${TEST_PROG_DIR}/test_x86_sse42.cxx") + CheckCompileLinkOption("-mssse3 -mpclmul" CRYPTOPP_IA32_CLMUL + "${TEST_PROG_DIR}/test_x86_clmul.cxx") + CheckCompileLinkOption("-msse4.1 -maes" CRYPTOPP_IA32_AES + "${TEST_PROG_DIR}/test_x86_aes.cxx") + CheckCompileLinkOption("-mavx" CRYPTOPP_IA32_AVX + "${TEST_PROG_DIR}/test_x86_avx.cxx") + CheckCompileLinkOption("-mavx2" CRYPTOPP_IA32_AVX2 + "${TEST_PROG_DIR}/test_x86_avx2.cxx") + CheckCompileLinkOption("-msse4.2 -msha" CRYPTOPP_IA32_SHA + "${TEST_PROG_DIR}/test_x86_sha.cxx") + if (EXISTS "${TEST_PROG_DIR}/test_asm_mixed.cxx") + CheckCompileLinkOption("" CRYPTOPP_MIXED_ASM + "${TEST_PROG_DIR}/test_asm_mixed.cxx") + else () + CheckCompileLinkOption("" CRYPTOPP_MIXED_ASM + "${TEST_PROG_DIR}/test_mixed_asm.cxx") + endif () + + if (NOT CRYPTOPP_MIXED_ASM) + list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_MIXED_ASM") + endif () + + if (NOT CRYPTOPP_IA32_SSE2 AND NOT CRYPTOPP_DISABLE_ASM) + list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_ASM") + elseif (CRYPTOPP_IA32_SSE2 AND NOT CRYPTOPP_DISABLE_ASM) + set_source_files_properties(${SRC_DIR}/sse_simd.cpp PROPERTIES COMPILE_FLAGS "-msse2") + endif () + if (NOT CRYPTOPP_IA32_SSSE3 AND NOT CRYPTOPP_DISABLE_SSSE3) + list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_SSSE3") + elseif (CRYPTOPP_IA32_SSSE3 AND NOT CRYPTOPP_DISABLE_SSSE3) + if (NOT CRYPTOPP_IA32_SSE41 AND NOT CRYPTOPP_DISABLE_SSE4) + list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_SSE4") + endif () + if (NOT CRYPTOPP_IA32_SSE42 AND NOT CRYPTOPP_DISABLE_SSE4) + list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_SSE4") + elseif (CRYPTOPP_IA32_SSE42 AND NOT CRYPTOPP_DISABLE_SSE4) + set_source_files_properties(${SRC_DIR}/crc_simd.cpp PROPERTIES COMPILE_FLAGS "-msse4.2") + if (NOT CRYPTOPP_IA32_CLMUL AND NOT CRYPTOPP_DISABLE_CLMUL) + list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_CLMUL") + elseif (CRYPTOPP_IA32_CLMUL AND NOT CRYPTOPP_DISABLE_CLMUL) + set_source_files_properties(${SRC_DIR}/gcm_simd.cpp PROPERTIES COMPILE_FLAGS "-mssse3 -mpclmul") + set_source_files_properties(${SRC_DIR}/gf2n_simd.cpp PROPERTIES COMPILE_FLAGS "-mpclmul") + endif () + if (NOT CRYPTOPP_IA32_AES AND NOT CRYPTOPP_DISABLE_AES) + list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_AESNI") + elseif (CRYPTOPP_IA32_AES AND NOT CRYPTOPP_DISABLE_AES) + set_source_files_properties(${SRC_DIR}/rijndael_simd.cpp PROPERTIES COMPILE_FLAGS "-msse4.1 -maes") + endif () + if (NOT CRYPTOPP_IA32_AVX2 AND NOT CRYPTOPP_DISABLE_AVX2) + list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_AVX2") + endif () + if (NOT CRYPTOPP_IA32_SHA AND NOT CRYPTOPP_DISABLE_SHA) + list(APPEND CRYPTOPP_COMPILE_OPTIONS "-DCRYPTOPP_DISABLE_SHANI") + elseif (CRYPTOPP_IA32_SHA AND NOT CRYPTOPP_DISABLE_SHA) + set_source_files_properties(${SRC_DIR}/sha_simd.cpp PROPERTIES COMPILE_FLAGS "-msse4.2 -msha") + endif () + endif () + endif () + endif () +endif () #============================================================================ # Compile targets #============================================================================ -add_library(cryptopp STATIC ${cryptopp_SOURCES}) + +set(cryptopp_LIBRARY_SOURCES ${cryptopp_SOURCES_ASM}) +list(APPEND cryptopp_LIBRARY_SOURCES ${cryptopp_SOURCES}) + +add_library(cryptopp STATIC ${cryptopp_LIBRARY_SOURCES}) +target_compile_definitions(cryptopp PUBLIC ${CRYPTOPP_COMPILE_DEFINITIONS}) +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}") target_include_directories(cryptopp INTERFACE .) #============================================================================ diff --git a/externals/cryptopp/cryptopp b/externals/cryptopp/cryptopp index f320e7d92a..f2102243e6 160000 --- a/externals/cryptopp/cryptopp +++ b/externals/cryptopp/cryptopp @@ -1 +1 @@ -Subproject commit f320e7d92a33ee80ae42deef79da78cfc30868af +Subproject commit f2102243e6fdd48c0b2a393a0993cca228f20573