summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitmodules3
-rw-r--r--externals/CMakeLists.txt3
-rw-r--r--externals/cryptopp/CMakeLists.txt168
m---------externals/cryptopp/cryptopp0
-rw-r--r--src/core/CMakeLists.txt3
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()
8endif() 8endif()
9
10add_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
13include(TestBigEndian)
14include(CheckCXXCompilerFlag)
15
16#============================================================================
17# Settable options
18#============================================================================
19
20option(CRYPTOPP_DISABLE_ASM "Disable ASM" OFF)
21option(CRYPTOPP_DISABLE_SSSE3 "Disable SSSE3" OFF)
22option(CRYPTOPP_DISABLE_AESNI "Disable AES-NI" OFF)
23option(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
30if (NOT (CMAKE_SYSTEM_VERSION AND CMAKE_SYSTEM_PROCESSOR))
31 set(CRYPTOPP_CROSS_COMPILE 1)
32else()
33 set(CRYPTOPP_CROSS_COMPILE 0)
34endif()
35
36# Don't use RPATH's. The resulting binary could fail a security audit.
37if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
38 set(CMAKE_MACOSX_RPATH 0)
39endif()
40
41if(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
42 add_definitions(-wd68 -wd186 -wd279 -wd327 -wd161 -wd3180)
43endif()
44
45# Endianness
46TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
47if(IS_BIG_ENDIAN)
48 add_definitions(-DIS_BIG_ENDIAN)
49endif()
50
51if(CRYPTOPP_DISABLE_ASM)
52 add_definitions(-DCRYPTOPP_DISABLE_ASM)
53endif()
54if(CRYPTOPP_DISABLE_SSSE3)
55 add_definitions(-DCRYPTOPP_DISABLE_SSSE3)
56endif()
57if(CRYPTOPP_DISABLE_AESNI)
58 add_definitions(-DCRYPTOPP_DISABLE_AESNI)
59endif()
60
61# We need the output 'uname -s' for Unix and Linux system detection
62if (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}")
70endif()
71
72# We need the output 'uname -m' for Unix and Linux platform detection
73if (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}")
81endif()
82
83if(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\"" )
88endif()
89
90# Enable PIC for all targets except Windows and 32-bit x86.
91# Avoid on 32-bit x86 due to register pressures.
92if ((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()
97endif()
98
99# -march=native for GCC, Clang and ICC in any version that does support it.
100if ((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()
105endif()
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
109if (NOT (WINDOWS OR WINDOWS_STORE OR WINDOWS_PHONE))
110 SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_FLAGS}")
111endif()
112
113#============================================================================
114# Sources & headers
115#============================================================================
116
117# Library headers
118file(GLOB cryptopp_HEADERS cryptopp/*.h)
119
120# Library sources. You can use the GNUmakefile to generate the list: `make sources`.
121file(GLOB cryptopp_SOURCES cryptopp/*.cpp)
122list(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
131if(MINGW OR WIN32)
132 list(APPEND cryptopp_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/cryptopp/winpipes.cpp)
133endif()
134
135if(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()
152endif()
153
154#============================================================================
155# Compile targets
156#============================================================================
157add_library(cryptopp STATIC ${cryptopp_SOURCES})
158
159#============================================================================
160# Third-party libraries
161#============================================================================
162
163if(WIN32)
164 target_link_libraries(cryptopp ws2_32)
165endif()
166
167find_package(Threads)
168target_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
362include_directories(../../externals/dynarmic/include) 362include_directories(../../externals/dynarmic/include)
363include_directories(../../externals/cryptopp)
363 364
364create_directory_groups(${SRCS} ${HEADERS}) 365create_directory_groups(${SRCS} ${HEADERS})
365 366
366add_library(core STATIC ${SRCS} ${HEADERS}) 367add_library(core STATIC ${SRCS} ${HEADERS})
367 368
368target_link_libraries(core dynarmic) 369target_link_libraries(core dynarmic cryptopp)