• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1include_directories(../include)
2
3if(APPLE)
4  if (${ARCH} STREQUAL "x86")
5    set(PERLASM_FLAGS "-fPIC -DOPENSSL_IA32_SSE2")
6  endif()
7  set(PERLASM_STYLE macosx)
8  set(ASM_EXT S)
9  enable_language(ASM)
10elseif(UNIX)
11  if (${ARCH} STREQUAL "aarch64")
12    # The "armx" Perl scripts look for "64" in the style argument
13    # in order to decide whether to generate 32- or 64-bit asm.
14    set(PERLASM_STYLE linux64)
15  elseif (${ARCH} STREQUAL "arm")
16    set(PERLASM_STYLE linux32)
17  elseif (${ARCH} STREQUAL "x86")
18    set(PERLASM_FLAGS "-fPIC -DOPENSSL_IA32_SSE2")
19    set(PERLASM_STYLE elf)
20  else()
21    set(PERLASM_STYLE elf)
22  endif()
23  set(ASM_EXT S)
24  enable_language(ASM)
25else()
26  if (CMAKE_CL_64)
27    message("Using nasm")
28    set(PERLASM_STYLE nasm)
29  else()
30    message("Using win32n")
31    set(PERLASM_STYLE win32n)
32    set(PERLASM_FLAGS "-DOPENSSL_IA32_SSE2")
33  endif()
34
35  # On Windows, we use the NASM output, specifically built with Yasm.
36  set(ASM_EXT asm)
37  enable_language(ASM_NASM)
38endif()
39
40function(perlasm dest src)
41  add_custom_command(
42    OUTPUT ${dest}
43    COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${src} ${PERLASM_STYLE} ${PERLASM_FLAGS} ${ARGN} > ${dest}
44    DEPENDS
45    ${src}
46    ${PROJECT_SOURCE_DIR}/crypto/perlasm/arm-xlate.pl
47    ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86_64-xlate.pl
48    ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86asm.pl
49    ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86gas.pl
50    ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86masm.pl
51    ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86nasm.pl
52    WORKING_DIRECTORY .
53  )
54endfunction()
55
56if (${ARCH} STREQUAL "x86_64")
57  set(
58    CRYPTO_ARCH_SOURCES
59
60    cpu-intel.c
61  )
62endif()
63
64if (${ARCH} STREQUAL "x86")
65  set(
66    CRYPTO_ARCH_SOURCES
67
68    cpu-intel.c
69  )
70endif()
71
72if (${ARCH} STREQUAL "arm")
73  set(
74    CRYPTO_ARCH_SOURCES
75
76    cpu-arm.c
77    cpu-arm-asm.S
78  )
79endif()
80
81if (${ARCH} STREQUAL "aarch64")
82  set(
83    CRYPTO_ARCH_SOURCES
84
85    cpu-arm.c
86  )
87endif()
88
89# Level 0.1 - depends on nothing outside this set.
90add_subdirectory(stack)
91add_subdirectory(lhash)
92add_subdirectory(err)
93add_subdirectory(buf)
94add_subdirectory(base64)
95add_subdirectory(bytestring)
96
97# Level 0.2 - depends on nothing but itself
98add_subdirectory(sha)
99add_subdirectory(md4)
100add_subdirectory(md5)
101add_subdirectory(modes)
102add_subdirectory(aes)
103add_subdirectory(des)
104add_subdirectory(rc4)
105add_subdirectory(conf)
106add_subdirectory(chacha)
107add_subdirectory(poly1305)
108add_subdirectory(curve25519)
109
110# Level 1, depends only on 0.*
111add_subdirectory(digest)
112add_subdirectory(cipher)
113add_subdirectory(rand)
114add_subdirectory(bio)
115add_subdirectory(bn)
116add_subdirectory(obj)
117add_subdirectory(asn1)
118
119# Level 2
120add_subdirectory(engine)
121add_subdirectory(dh)
122add_subdirectory(dsa)
123add_subdirectory(rsa)
124add_subdirectory(ec)
125add_subdirectory(ecdh)
126add_subdirectory(ecdsa)
127add_subdirectory(hmac)
128
129# Level 3
130add_subdirectory(cmac)
131add_subdirectory(evp)
132add_subdirectory(hkdf)
133add_subdirectory(pem)
134add_subdirectory(x509)
135add_subdirectory(x509v3)
136
137# Level 4
138add_subdirectory(pkcs8)
139
140# Test support code
141add_subdirectory(test)
142
143add_library(
144  crypto
145
146  crypto.c
147  directory_posix.c
148  directory_win.c
149  ex_data.c
150  mem.c
151  refcount_c11.c
152  refcount_lock.c
153  thread.c
154  thread_none.c
155  thread_pthread.c
156  thread_win.c
157  time_support.c
158
159  ${CRYPTO_ARCH_SOURCES}
160
161  $<TARGET_OBJECTS:stack>
162  $<TARGET_OBJECTS:lhash>
163  $<TARGET_OBJECTS:err>
164  $<TARGET_OBJECTS:base64>
165  $<TARGET_OBJECTS:bytestring>
166  $<TARGET_OBJECTS:sha>
167  $<TARGET_OBJECTS:md4>
168  $<TARGET_OBJECTS:md5>
169  $<TARGET_OBJECTS:digest>
170  $<TARGET_OBJECTS:cipher>
171  $<TARGET_OBJECTS:modes>
172  $<TARGET_OBJECTS:aes>
173  $<TARGET_OBJECTS:des>
174  $<TARGET_OBJECTS:rc4>
175  $<TARGET_OBJECTS:conf>
176  $<TARGET_OBJECTS:chacha>
177  $<TARGET_OBJECTS:poly1305>
178  $<TARGET_OBJECTS:curve25519>
179  $<TARGET_OBJECTS:buf>
180  $<TARGET_OBJECTS:bn>
181  $<TARGET_OBJECTS:bio>
182  $<TARGET_OBJECTS:rand>
183  $<TARGET_OBJECTS:obj>
184  $<TARGET_OBJECTS:asn1>
185  $<TARGET_OBJECTS:engine>
186  $<TARGET_OBJECTS:dh>
187  $<TARGET_OBJECTS:dsa>
188  $<TARGET_OBJECTS:rsa>
189  $<TARGET_OBJECTS:ec>
190  $<TARGET_OBJECTS:ecdh>
191  $<TARGET_OBJECTS:ecdsa>
192  $<TARGET_OBJECTS:hmac>
193  $<TARGET_OBJECTS:cmac>
194  $<TARGET_OBJECTS:evp>
195  $<TARGET_OBJECTS:hkdf>
196  $<TARGET_OBJECTS:pem>
197  $<TARGET_OBJECTS:x509>
198  $<TARGET_OBJECTS:x509v3>
199  $<TARGET_OBJECTS:pkcs8>
200)
201
202if(NOT MSVC AND NOT ANDROID)
203  target_link_libraries(crypto pthread)
204endif()
205
206add_executable(
207  constant_time_test
208
209  constant_time_test.c
210
211  $<TARGET_OBJECTS:test_support>
212)
213
214target_link_libraries(constant_time_test crypto)
215add_dependencies(all_tests constant_time_test)
216
217add_executable(
218  thread_test
219
220  thread_test.c
221
222  $<TARGET_OBJECTS:test_support>
223)
224
225target_link_libraries(thread_test crypto)
226add_dependencies(all_tests thread_test)
227
228add_executable(
229  refcount_test
230
231  refcount_test.c
232)
233
234target_link_libraries(refcount_test crypto)
235add_dependencies(all_tests refcount_test)
236