diff options
| author | 2017-02-13 22:03:55 +0200 | |
|---|---|---|
| committer | 2017-02-13 12:03:55 -0800 | |
| commit | dbc94efdb5e228544cad3fac5087693cd8dca2e7 (patch) | |
| tree | 147b5086ac70a29eb064396aeaa1c37f3fd4b8dc | |
| parent | Merge pull request #2561 from wwylele/fs-rom (diff) | |
| download | yuzu-dbc94efdb5e228544cad3fac5087693cd8dca2e7.tar.gz yuzu-dbc94efdb5e228544cad3fac5087693cd8dca2e7.tar.xz yuzu-dbc94efdb5e228544cad3fac5087693cd8dca2e7.zip | |
Core: add cryptopp library (#2412)
| -rw-r--r-- | .gitmodules | 3 | ||||
| -rw-r--r-- | externals/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | externals/cryptopp/CMakeLists.txt | 168 | ||||
| m--------- | externals/cryptopp/cryptopp | 0 | ||||
| -rw-r--r-- | src/core/CMakeLists.txt | 3 |
5 files changed, 176 insertions, 1 deletions
diff --git a/.gitmodules b/.gitmodules index dbb1b0dd3..f98725622 100644 --- a/.gitmodules +++ b/.gitmodules | |||
| @@ -19,3 +19,6 @@ | |||
| 19 | [submodule "xbyak"] | 19 | [submodule "xbyak"] |
| 20 | path = externals/xbyak | 20 | path = externals/xbyak |
| 21 | url = https://github.com/herumi/xbyak.git | 21 | url = https://github.com/herumi/xbyak.git |
| 22 | [submodule "cryptopp"] | ||
| 23 | path = externals/cryptopp/cryptopp | ||
| 24 | url = https://github.com/weidai11/cryptopp.git | ||
diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 7e4b05ffc..309e98464 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt | |||
| @@ -6,3 +6,6 @@ if (ARCHITECTURE_x86_64) | |||
| 6 | target_compile_options(xbyak INTERFACE -fno-operator-names) | 6 | target_compile_options(xbyak INTERFACE -fno-operator-names) |
| 7 | endif() | 7 | endif() |
| 8 | endif() | 8 | endif() |
| 9 | |||
| 10 | add_subdirectory(cryptopp) | ||
| 11 | |||
diff --git a/externals/cryptopp/CMakeLists.txt b/externals/cryptopp/CMakeLists.txt new file mode 100644 index 000000000..bbac71bb9 --- /dev/null +++ b/externals/cryptopp/CMakeLists.txt | |||
| @@ -0,0 +1,168 @@ | |||
| 1 | # The CMakeLists.txt shipped with cryptopp pollutes our option list and installation list, | ||
| 2 | # so we made our own one. This is basically a trimmed down version of the shipped CMakeLists.txt | ||
| 3 | # The differences are: | ||
| 4 | # - removed support for legacy CMake versions | ||
| 5 | # - removed support for 32-bit | ||
| 6 | # - removed rdrand module.asm as a workaround for an issue (see below) | ||
| 7 | # - added prefix "CRYPTOPP_" to all option names | ||
| 8 | # - disabled testing | ||
| 9 | # - disabled installation | ||
| 10 | # - disabled documentation | ||
| 11 | # - configured to build a static library only | ||
| 12 | |||
| 13 | include(TestBigEndian) | ||
| 14 | include(CheckCXXCompilerFlag) | ||
| 15 | |||
| 16 | #============================================================================ | ||
| 17 | # Settable options | ||
| 18 | #============================================================================ | ||
| 19 | |||
| 20 | option(CRYPTOPP_DISABLE_ASM "Disable ASM" OFF) | ||
| 21 | option(CRYPTOPP_DISABLE_SSSE3 "Disable SSSE3" OFF) | ||
| 22 | option(CRYPTOPP_DISABLE_AESNI "Disable AES-NI" OFF) | ||
| 23 | option(CRYPTOPP_DISABLE_CXXFLAGS_OPTIMIZATIONS "Disable CXXFLAGS optimizations" OFF) | ||
| 24 | |||
| 25 | #============================================================================ | ||
| 26 | # Internal compiler options | ||
| 27 | #============================================================================ | ||
| 28 | |||
| 29 | # Only set when cross-compiling, http://www.vtk.org/Wiki/CMake_Cross_Compiling | ||
| 30 | if (NOT (CMAKE_SYSTEM_VERSION AND CMAKE_SYSTEM_PROCESSOR)) | ||
| 31 | set(CRYPTOPP_CROSS_COMPILE 1) | ||
| 32 | else() | ||
| 33 | set(CRYPTOPP_CROSS_COMPILE 0) | ||
| 34 | endif() | ||
| 35 | |||
| 36 | # Don't use RPATH's. The resulting binary could fail a security audit. | ||
| 37 | if (NOT CMAKE_VERSION VERSION_LESS 2.8.12) | ||
| 38 | set(CMAKE_MACOSX_RPATH 0) | ||
| 39 | endif() | ||
| 40 | |||
| 41 | if(CMAKE_CXX_COMPILER_ID MATCHES "Intel") | ||
| 42 | add_definitions(-wd68 -wd186 -wd279 -wd327 -wd161 -wd3180) | ||
| 43 | endif() | ||
| 44 | |||
| 45 | # Endianness | ||
| 46 | TEST_BIG_ENDIAN(IS_BIG_ENDIAN) | ||
| 47 | if(IS_BIG_ENDIAN) | ||
| 48 | add_definitions(-DIS_BIG_ENDIAN) | ||
| 49 | endif() | ||
| 50 | |||
| 51 | if(CRYPTOPP_DISABLE_ASM) | ||
| 52 | add_definitions(-DCRYPTOPP_DISABLE_ASM) | ||
| 53 | endif() | ||
| 54 | if(CRYPTOPP_DISABLE_SSSE3) | ||
| 55 | add_definitions(-DCRYPTOPP_DISABLE_SSSE3) | ||
| 56 | endif() | ||
| 57 | if(CRYPTOPP_DISABLE_AESNI) | ||
| 58 | add_definitions(-DCRYPTOPP_DISABLE_AESNI) | ||
| 59 | endif() | ||
| 60 | |||
| 61 | # We need the output 'uname -s' for Unix and Linux system detection | ||
| 62 | if (NOT CRYPTOPP_CROSS_COMPILE) | ||
| 63 | set (UNAME_CMD "uname") | ||
| 64 | set (UNAME_ARG "-s") | ||
| 65 | execute_process(COMMAND ${UNAME_CMD} ${UNAME_ARG} | ||
| 66 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | ||
| 67 | RESULT_VARIABLE UNAME_RESULT | ||
| 68 | OUTPUT_VARIABLE UNAME_SYSTEM) | ||
| 69 | string(REGEX REPLACE "\n$" "" UNAME_SYSTEM "${UNAME_SYSTEM}") | ||
| 70 | endif() | ||
| 71 | |||
| 72 | # We need the output 'uname -m' for Unix and Linux platform detection | ||
| 73 | if (NOT CRYPTOPP_CROSS_COMPILE) | ||
| 74 | set (UNAME_CMD "uname") | ||
| 75 | set (UNAME_ARG "-m") | ||
| 76 | execute_process(COMMAND ${UNAME_CMD} ${UNAME_ARG} | ||
| 77 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | ||
| 78 | RESULT_VARIABLE UNAME_RESULT | ||
| 79 | OUTPUT_VARIABLE UNAME_MACHINE) | ||
| 80 | string(REGEX REPLACE "\n$" "" UNAME_MACHINE "${UNAME_MACHINE}") | ||
| 81 | endif() | ||
| 82 | |||
| 83 | if(WINDOWS_STORE OR WINDOWS_PHONE) | ||
| 84 | if("${CMAKE_SYSTEM_VERSION}" MATCHES "10\\.0.*") | ||
| 85 | SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D\"_WIN32_WINNT=0x0A00\"" ) | ||
| 86 | endif() | ||
| 87 | SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /FI\"winapifamily.h\"" ) | ||
| 88 | endif() | ||
| 89 | |||
| 90 | # Enable PIC for all targets except Windows and 32-bit x86. | ||
| 91 | # Avoid on 32-bit x86 due to register pressures. | ||
| 92 | if ((NOT CRYPTOPP_CROSS_COMPILE) AND (NOT (WINDOWS OR WINDOWS_STORE OR WINDOWS_PHONE))) | ||
| 93 | # Use Regex; match i386, i486, i586 and i686 | ||
| 94 | if (NOT (${UNAME_MACHINE} MATCHES "i.86")) | ||
| 95 | SET(CMAKE_POSITION_INDEPENDENT_CODE 1) | ||
| 96 | endif() | ||
| 97 | endif() | ||
| 98 | |||
| 99 | # -march=native for GCC, Clang and ICC in any version that does support it. | ||
| 100 | if ((NOT CRYPTOPP_DISABLE_CXXFLAGS_OPTIMIZATIONS) AND (NOT CRYPTOPP_CROSS_COMPILE) AND (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU|Intel")) | ||
| 101 | CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_OPT_ARCH_NATIVE_SUPPORTED) | ||
| 102 | if (COMPILER_OPT_ARCH_NATIVE_SUPPORTED AND NOT CMAKE_CXX_FLAGS MATCHES "-march=") | ||
| 103 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native") | ||
| 104 | endif() | ||
| 105 | endif() | ||
| 106 | |||
| 107 | # Link is driven through the compiler, but CXXFLAGS are not used. Also see | ||
| 108 | # http://public.kitware.com/pipermail/cmake/2003-June/003967.html | ||
| 109 | if (NOT (WINDOWS OR WINDOWS_STORE OR WINDOWS_PHONE)) | ||
| 110 | SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_FLAGS}") | ||
| 111 | endif() | ||
| 112 | |||
| 113 | #============================================================================ | ||
| 114 | # Sources & headers | ||
| 115 | #============================================================================ | ||
| 116 | |||
| 117 | # Library headers | ||
| 118 | file(GLOB cryptopp_HEADERS cryptopp/*.h) | ||
| 119 | |||
| 120 | # Library sources. You can use the GNUmakefile to generate the list: `make sources`. | ||
| 121 | file(GLOB cryptopp_SOURCES cryptopp/*.cpp) | ||
| 122 | list(REMOVE_ITEM cryptopp_SOURCES | ||
| 123 | # These are removed in the original CMakeLists.txt | ||
| 124 | ${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/pch.cpp | ||
| 125 | ${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/simple.cpp | ||
| 126 | ${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/winpipes.cpp | ||
| 127 | ${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/cryptlib_bds.cpp | ||
| 128 | ${cryptopp_SOURCES_TEST} | ||
| 129 | ) | ||
| 130 | |||
| 131 | if(MINGW OR WIN32) | ||
| 132 | list(APPEND cryptopp_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/winpipes.cpp) | ||
| 133 | endif() | ||
| 134 | |||
| 135 | if(MSVC AND NOT CRYPTOPP_DISABLE_ASM) | ||
| 136 | if(${CMAKE_GENERATOR} MATCHES ".*ARM") | ||
| 137 | message(STATUS "Disabling ASM because ARM is specified as target platform.") | ||
| 138 | else() | ||
| 139 | # Note that we removed rdrand.asm. This is a workaround for the issue that rdrand.asm cannnot compiled properly | ||
| 140 | # on MSVC. Because there is also a rdrand.S file in the submodule, CMake will specify the target path for | ||
| 141 | # rdrand.asm as "/crytopp.dir/{Debug|Release}/cryptopp/rdrand.asm.obj". The additional target folder "cryptopp" | ||
| 142 | # is specified because the file rdrand.asm is in the source folder "cryptopp". But MSVC assembler can't build | ||
| 143 | # target file to an non-existing folder("cryptopp"). | ||
| 144 | list(APPEND cryptopp_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/x64dll.asm) | ||
| 145 | list(APPEND cryptopp_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/x64masm.asm) | ||
| 146 | # list(APPEND cryptopp_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/rdrand.asm) | ||
| 147 | set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/x64dll.asm PROPERTIES COMPILE_FLAGS "/D_M_X64") | ||
| 148 | set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/x64masm.asm PROPERTIES COMPILE_FLAGS "/D_M_X64") | ||
| 149 | # set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/rdrand.asm PROPERTIES COMPILE_FLAGS "/D_M_X64") | ||
| 150 | enable_language(ASM_MASM) | ||
| 151 | endif() | ||
| 152 | endif() | ||
| 153 | |||
| 154 | #============================================================================ | ||
| 155 | # Compile targets | ||
| 156 | #============================================================================ | ||
| 157 | add_library(cryptopp STATIC ${cryptopp_SOURCES}) | ||
| 158 | |||
| 159 | #============================================================================ | ||
| 160 | # Third-party libraries | ||
| 161 | #============================================================================ | ||
| 162 | |||
| 163 | if(WIN32) | ||
| 164 | target_link_libraries(cryptopp ws2_32) | ||
| 165 | endif() | ||
| 166 | |||
| 167 | find_package(Threads) | ||
| 168 | target_link_libraries(cryptopp ${CMAKE_THREAD_LIBS_INIT}) | ||
diff --git a/externals/cryptopp/cryptopp b/externals/cryptopp/cryptopp new file mode 160000 | |||
| Subproject 841c37e34765487a2968357369ab74db8b10a62 | |||
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 8c2438831..1da10afab 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -360,9 +360,10 @@ set(HEADERS | |||
| 360 | ) | 360 | ) |
| 361 | 361 | ||
| 362 | include_directories(../../externals/dynarmic/include) | 362 | include_directories(../../externals/dynarmic/include) |
| 363 | include_directories(../../externals/cryptopp) | ||
| 363 | 364 | ||
| 364 | create_directory_groups(${SRCS} ${HEADERS}) | 365 | create_directory_groups(${SRCS} ${HEADERS}) |
| 365 | 366 | ||
| 366 | add_library(core STATIC ${SRCS} ${HEADERS}) | 367 | add_library(core STATIC ${SRCS} ${HEADERS}) |
| 367 | 368 | ||
| 368 | target_link_libraries(core dynarmic) | 369 | target_link_libraries(core dynarmic cryptopp) |