This repository has been archived by the owner on Sep 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
282 lines (250 loc) · 9.9 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
cmake_minimum_required(VERSION 3.4)
project(gcrypt LANGUAGES C)
include(CheckTypeSize)
include(CheckSymbolExists)
include(CheckIncludeFile)
include(CheckLibraryExists)
include(conanbuildinfo.cmake)
conan_basic_setup()
option(USE_AES "aes" ON)
option(USE_ARCFOUR "arcfour" ON)
option(USE_BLAKE2 "blake2" ON)
option(USE_BLOWFISH "blowfish" ON)
option(USE_CAMELLIA "camellia" ON)
option(USE_CAST5 "cast5" ON)
option(USE_CHACHA20 "cache20" ON)
option(USE_CRC "crc" ON)
option(USE_DES "des" ON)
option(USE_DSA "dsa" ON)
option(USE_ECC "ecc" ON)
option(USE_ELGAMAL "elgamal" ON)
option(USE_GOST28147 "gost28147" ON)
option(USE_GOST_R_3411_12 "gostr3411-12" ON)
option(USE_GOST_R_3411_94 "gostr3411-94" ON)
option(USE_IDEA "idea" ON)
option(USE_MD2 "md2" ON)
option(USE_MD4 "md4" ON)
option(USE_MD5 "md5" ON)
option(USE_RFC2268 "rfc2268" ON)
option(USE_RMD160 "rmd160" ON)
option(USE_RSA "rsa" ON)
option(USE_SALSA20 "salsa20" ON)
option(USE_SCRYPT "scrypt" ON)
option(USE_SEED "seed" ON)
option(USE_SERPENT "serpent" ON)
option(USE_SHA1 "sha1" ON)
option(USE_SHA256 "sha256" ON)
option(USE_SHA3 "sha3" ON)
option(USE_SHA512 "sha512" ON)
option(USE_TIGER "tiger" ON)
option(USE_TWOFISH "twofish" ON)
option(USE_WHIRLPOOL "whirlpool" ON)
set(PACKAGE_NAME "libgcrypt")
set(PACKAGE_TARNAME "libgcrypt")
set(PACKAGE_VERSION "1.8.4")
set(PACKAGE_STRING "libgcrypt 1.8.4")
set(PACKAGE_BUGREPORT "http://bugs.gnupg.org")
set(PACKAGE_URL "")
set(BUILD_REVISION "93775172")
set(BUILD_TIMESTAMP "<none>")
set(PACKAGE "${PACKAGE_NAME}")
set(VERSION "${PACKAGE_VERSION}")
set(VERSION_NUMBER "0x010804")
set(GCRYPT_VERSION "${VERSION}")
set(GCRYPT_VERSION_NUMBER "${VERSION_NUMBER}")
set(LIBGCRYPT_CIPHERS "arcfour blowfish cast5 des aes twofish serpent rfc2268 seed camellia idea salsa20 gost28147 chacha20")
set(LIBGCRYPT_DIGESTS "crc gostr3411-94 md2 md4 md5 rmd160 sha1 sha256 sha512 sha3 tiger whirlpool stribog blake2")
set(LIBGCRYPT_KDFS "s2k pkdf2 scrypt")
set(LIBGCRYPT_PUBKEY_CIPHERS "dsa elgamal rsa ecc")
if(WIN32)
set(USE_ONLY_8DOT3 1)
set(HAVE_DRIVE_LETTERS 1)
set(HAVE_DOSISH_SYSTEM 1)
set(HAVE_W32_SYSTEM 1)
set(USE_RNDW32 1)
else()
set(USE_ONLY_8DOT3 0)
set(HAVE_DRIVE_LETTERS 0)
set(HAVE_DOSISH_SYSTEM 0)
set(HAVE_W32_SYSTEM 0)
set(USE_RNDW32 0)
endif()
if(WINCE)
set(HAVE_W32CE_SYSTEM 1)
set(USE_RNDW32CE 1)
else()
set(HAVE_W32CE_SYSTEM 0)
set(USE_RNDW32CE 0)
endif()
if(UNIX)
set(USE_RNDEGD 1)
set(USE_RNDUNIX 1)
else()
set(USE_RNDEGD 0)
set(USE_RNDUNIX 0)
endif()
set(HAVE_CPU_ARCH_ALPHA 0)
set(HAVE_CPU_ARCH_ARM 0)
set(HAVE_CPU_ARCH_M68K 0)
set(HAVE_CPU_ARCH_MIPS 0)
set(HAVE_CPU_ARCH_PPC 0)
set(HAVE_CPU_ARCH_SPARC 0)
set(HAVE_CPU_ARCH_X86 1)
check_type_size("uint64_t" SIZEOF_UINT64_T)
check_type_size("unsigned int" SIZEOF_UNSIGNED_INT)
check_type_size("unsigned long" SIZEOF_UNSIGNED_LONG)
check_type_size("unsigned long long" SIZEOF_UNSIGNED_LONG_LONG)
check_type_size("unsigned short" SIZEOF_UNSIGNED_SHORT)
check_type_size("void*" SIZEOF_VOID_P)
check_symbol_exists(atexit stdlib.h HAVE_ATEXIT)
check_symbol_exists(__builtin_bswap32 stdlib.h HAVE_BUILTIN_BSWAP32)
check_symbol_exists(__builtin_bswap64 stdlib.h HAVE_BUILTIN_BSWAP64)
check_symbol_exists(__builtin_ctz stdlib.h HAVE_BUILTIN_CTZ)
check_symbol_exists(clock time.h HAVE_CLOCK)
check_symbol_exists(clock_gettime time.h HAVE_CLOCK_GETTIME)
check_symbol_exists(_doprnt stdio.h HAVE_DOPRNT)
check_symbol_exists(sys_siglist signal.h HAVE_DECL_SYS_SIGLIST)
check_symbol_exists(fcntl "unistd.h;fcntl.h" HAVE_FCNTL)
check_symbol_exists(flockfiles stdio.h HAVE_FLOCKFILE)
check_symbol_exists(ftruncate "unistd.h;sys/types.h" HAVE_FTRUNCATE)
check_symbol_exists(gethrtime "sys/time.h" HAVE_GETHRTIME)
check_symbol_exists(getpagesize unistd.h HAVE_GETPAGESIZE)
check_symbol_exists(getpid "sys/types.h;unistd.h" HAVE_GETPID)
check_symbol_exists(getrusage "sys/time.h;sys/resource.h" HAVE_GETRUSAGE)
check_symbol_exists(gettimeofday "sys/time.h" HAVE_GETTIMEOFDAY)
check_symbol_exists(memmove string.h HAVE_MEMMOVE)
check_symbol_exists(mlock "sys/mman.h" HAVE_MLOCK)
check_symbol_exists(mmap "sys/mman.h" HAVE_MMAP)
check_symbol_exists(pth_init pth.h HAVE_PTH)
check_symbol_exists(pthread_mutex_init pthread.h HAVE_PTHREAD)
check_symbol_exists(raise signal.h HAVE_RAISE)
check_symbol_exists(rand stdlib.h HAVE_RAND)
check_symbol_exists(stpcpy string.h HAVE_STPCPY)
check_symbol_exists(strcasecmp strings.h HAVE_STRCASECMP)
check_symbol_exists(strerror string.h HAVE_STRERROR)
check_symbol_exists(stricmp string.h HAVE_STRICMP)
check_symbol_exists(vprintf stdio.h HAVE_VPRINTF)
check_symbol_exists(wait4 "sys/types.h;sys/time.h;sys/resourse.h;sys/wait.h" HAVE_WAIT4)
check_symbol_exists(waitpid "sys/types.h;sys/wait.h" HAVE_WAITPID)
check_symbol_exists(strtoul stdlib.h HAVE_STRTOUL)
check_symbol_exists(syscall "unistd.h;sys/syscall.h" HAVE_SYSCALL)
check_symbol_exists(sysconf unistd.h HAVE_SYSCONF)
check_symbol_exists(syslog syslog.h HAVE_SYSLOG)
check_include_file(dlfcn.h HAVE_DLFCN_H)
check_include_file(inttypes.h HAVE_INTTYPES_H)
check_include_file(memory.h HAVE_MEMORY_H)
check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(stdlib.h HAVE_STDLIB_H)
check_include_file(string.h HAVE_STRING_H)
check_include_file(strings.h HAVE_STRINGS_H)
check_include_file("sys/capability.h" HAVE_SYS_CAPABILITY_H)
check_include_file("sys/mman.h" HAVE_SYS_MMAN_H)
check_include_file("sys/msg.h" HAVE_SYS_MSG_H)
check_include_file("sys/select.h" HAVE_SYS_SELECT_H)
check_include_file("sys/socket.h" HAVE_SYS_SOCKET_H)
check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
check_include_file(unistd.h HAVE_UNISTD_H)
check_include_file(winsock2.h HAVE_WINSOCK2_H)
check_include_file(ws2tcpip.h HAVE_WS2TCPIP_H)
check_include_file(stdio.h STDC_HEADERS)
if(EXISTS "/dev/random")
set(HAVE_DEV_RANDOM 1)
set(NAME_OF_DEV_RANDOM "/dev/random")
else()
set(HAVE_DEV_RANDOM 0)
set(NAME_OF_DEV_RANDOM "")
endif()
if(EXISTS "/dev/urandom")
set(NAME_OF_DEV_URANDOM "/dev/urandom")
else()
set(NAME_OF_DEV_URANDOM "")
endif()
set(USE_GNU_PTH ${HAVE_PTH})
set(USE_RANDOM_DAEMON 0)
set(USE_RNDLINUX ${HAVE_DEV_RANDOM})
if(${HAVE_SYS_CAPABILITY_H})
set(USE_CAPABILITIES 1)
else()
set(USE_CAPABILITIES 0)
endif()
file(COPY
${CMAKE_CURRENT_SOURCE_DIR}/mod-source-info.h
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/sources/mpi)
#FIXME : support other architectures
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
file(COPY
${CMAKE_CURRENT_SOURCE_DIR}/sources/mpi/generic/mpi-asm-defs.h
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/sources/mpi)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
file(COPY
${CMAKE_CURRENT_SOURCE_DIR}/sources/mpi/amd64/mpi-asm-defs.h
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/sources/mpi)
endif()
add_executable(gost-s-box ${CMAKE_CURRENT_SOURCE_DIR}/sources/cipher/gost-s-box.c)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
${CMAKE_CURRENT_SOURCE_DIR}/sources/config.h)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/gcrypt.h.in
${CMAKE_CURRENT_SOURCE_DIR}/sources/src/gcrypt.h)
file(GLOB SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/sources/cipher/*.c
${CMAKE_CURRENT_SOURCE_DIR}/sources/compat/*.c
${CMAKE_CURRENT_SOURCE_DIR}/sources/mpi/*.c
${CMAKE_CURRENT_SOURCE_DIR}/sources/mpi/generic/*.c
${CMAKE_CURRENT_SOURCE_DIR}/sources/random/*.c
${CMAKE_CURRENT_SOURCE_DIR}/sources/src/*.c)
list(REMOVE_ITEM SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sources/cipher/gost-s-box)
list(REMOVE_ITEM SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sources/src/getrandom.c)
list(REMOVE_ITEM SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sources/src/gcryptrnd.c)
list(REMOVE_ITEM SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sources/src/hwf-arm.c)
list(REMOVE_ITEM SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sources/src/mpicalc.c)
list(REMOVE_ITEM SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sources/src/dumpsexp.c)
list(REMOVE_ITEM SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sources/random/jitterentropy-base.c)
list(REMOVE_ITEM SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sources/random/random-daemon.c)
if(NOT WIN32)
list(REMOVE_ITEM SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sources/compat/clock.c)
list(REMOVE_ITEM SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sources/compat/getpid.c)
list(REMOVE_ITEM SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sources/random/rndw32.c)
endif()
if(NOT WINCE)
list(REMOVE_ITEM SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sources/random/rndw32ce.c)
endif()
if(NOT UNIX)
list(REMOVE_ITEM SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sources/random/rndunix.c)
list(REMOVE_ITEM SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sources/random/rndlinux.c)
list(REMOVE_ITEM SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sources/random/rndegd.c)
endif()
file(GLOB HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/sources/cipher/*.h
${CMAKE_CURRENT_SOURCE_DIR}/sources/compat/*.h
${CMAKE_CURRENT_SOURCE_DIR}/sources/mpi/*.h
${CMAKE_CURRENT_SOURCE_DIR}/sources/mpi/generic/*.h
${CMAKE_CURRENT_SOURCE_DIR}/sources/random/*.h
${CMAKE_CURRENT_SOURCE_DIR}/sources/src/*.h)
add_library(${PROJECT_NAME} ${SOURCES} ${HEADERS} "${CMAKE_CURRENT_SOURCE_DIR}/sources/cipher/gost-sb.h")
add_custom_command(
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/sources/cipher/gost-sb.h"
COMMAND gost-s-box gost-sb.h
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/sources/cipher")
add_dependencies(${PROJECT_NAME} gost-s-box)
target_include_directories(${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/sources
${CMAKE_CURRENT_SOURCE_DIR}/sources/cipher
${CMAKE_CURRENT_SOURCE_DIR}/sources/compat
${CMAKE_CURRENT_SOURCE_DIR}/sources/mpi
${CMAKE_CURRENT_SOURCE_DIR}/sources/random
${CMAKE_CURRENT_SOURCE_DIR}/sources/src)
target_link_libraries(${PROJECT_NAME} PRIVATE ${CONAN_LIBS_LIBGPG-ERROR})
target_include_directories(${PROJECT_NAME} PRIVATE ${CONAN_INCLUDE_DIRS_LIBGPG-ERROR})
target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_CONFIG_H)
set_target_properties(${PROJECT_NAME} PROPERTIES
PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/sources/src/gcrypt.h
WINDOWS_EXPORT_ALL_SYMBOLS ON)
install(TARGETS ${PROJECT_NAME}
PUBLIC_HEADER DESTINATION include
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)