blob: 89f4ce5b7e69f942f0170c68e477c68010ec7190 [file] [log] [blame]
Adam Langley73415b62015-08-24 18:03:17 -07001include_directories(../include)
Adam Langley95c29f32014-06-20 12:00:00 -07002
Adam Langley30eda1d2014-06-24 11:15:12 -07003if(APPLE)
Adam Langley4a0f0c42015-01-28 16:37:10 -08004 if (${ARCH} STREQUAL "x86")
David Benjamin4616bb12015-03-26 18:33:00 -04005 set(PERLASM_FLAGS "-fPIC -DOPENSSL_IA32_SSE2")
Adam Langley4a0f0c42015-01-28 16:37:10 -08006 endif()
7 set(PERLASM_STYLE macosx)
8 set(ASM_EXT S)
9 enable_language(ASM)
Adam Langleyded93582014-07-31 15:23:51 -070010elseif(UNIX)
Adam Langley4a0f0c42015-01-28 16:37:10 -080011 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)
David Benjamin5928c412015-04-20 17:32:28 -040015 elseif (${ARCH} STREQUAL "arm")
16 set(PERLASM_STYLE linux32)
Adam Langley4a0f0c42015-01-28 16:37:10 -080017 elseif (${ARCH} STREQUAL "x86")
David Benjamin4616bb12015-03-26 18:33:00 -040018 set(PERLASM_FLAGS "-fPIC -DOPENSSL_IA32_SSE2")
Adam Langley4a0f0c42015-01-28 16:37:10 -080019 set(PERLASM_STYLE elf)
20 else()
21 set(PERLASM_STYLE elf)
22 endif()
23 set(ASM_EXT S)
24 enable_language(ASM)
Adam Langley95c29f32014-06-20 12:00:00 -070025else()
Adam Langley4a0f0c42015-01-28 16:37:10 -080026 if (CMAKE_CL_64)
27 message("Using nasm")
28 set(PERLASM_STYLE nasm)
29 else()
30 message("Using win32n")
31 set(PERLASM_STYLE win32n)
David Benjamin4616bb12015-03-26 18:33:00 -040032 set(PERLASM_FLAGS "-DOPENSSL_IA32_SSE2")
Adam Langley4a0f0c42015-01-28 16:37:10 -080033 endif()
David Benjaminbc786a92014-10-31 17:27:40 -040034
Adam Langley4a0f0c42015-01-28 16:37:10 -080035 # On Windows, we use the NASM output, specifically built with Yasm.
36 set(ASM_EXT asm)
37 enable_language(ASM_NASM)
Adam Langley95c29f32014-06-20 12:00:00 -070038endif()
39
40function(perlasm dest src)
Adam Langley4a0f0c42015-01-28 16:37:10 -080041 add_custom_command(
42 OUTPUT ${dest}
David Benjamin3ce3c362015-02-23 13:06:19 -050043 COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${src} ${PERLASM_STYLE} ${PERLASM_FLAGS} ${ARGN} > ${dest}
Adam Langley4a0f0c42015-01-28 16:37:10 -080044 DEPENDS
45 ${src}
David Benjaminf06802f2015-04-20 13:25:46 -040046 ${PROJECT_SOURCE_DIR}/crypto/perlasm/arm-xlate.pl
Adam Langley4a0f0c42015-01-28 16:37:10 -080047 ${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 )
Adam Langley95c29f32014-06-20 12:00:00 -070054endfunction()
55
56if (${ARCH} STREQUAL "x86_64")
Adam Langley4a0f0c42015-01-28 16:37:10 -080057 set(
58 CRYPTO_ARCH_SOURCES
Adam Langley95c29f32014-06-20 12:00:00 -070059
Adam Langley4a0f0c42015-01-28 16:37:10 -080060 cpu-intel.c
61 )
Adam Langley95c29f32014-06-20 12:00:00 -070062endif()
63
64if (${ARCH} STREQUAL "x86")
Adam Langley4a0f0c42015-01-28 16:37:10 -080065 set(
66 CRYPTO_ARCH_SOURCES
Adam Langley95c29f32014-06-20 12:00:00 -070067
Adam Langley4a0f0c42015-01-28 16:37:10 -080068 cpu-intel.c
69 )
Adam Langley95c29f32014-06-20 12:00:00 -070070endif()
71
72if (${ARCH} STREQUAL "arm")
Adam Langley4a0f0c42015-01-28 16:37:10 -080073 set(
74 CRYPTO_ARCH_SOURCES
Adam Langley95c29f32014-06-20 12:00:00 -070075
Adam Langley4a0f0c42015-01-28 16:37:10 -080076 cpu-arm.c
Adam Langleyd062c8a2015-01-30 15:30:44 -080077 cpu-arm-asm.S
Adam Langley4a0f0c42015-01-28 16:37:10 -080078 )
Adam Langley3e652652015-01-09 15:44:37 -080079endif()
80
81if (${ARCH} STREQUAL "aarch64")
Adam Langley4a0f0c42015-01-28 16:37:10 -080082 set(
83 CRYPTO_ARCH_SOURCES
Adam Langley3e652652015-01-09 15:44:37 -080084
Adam Langley4a0f0c42015-01-28 16:37:10 -080085 cpu-arm.c
86 )
Adam Langley95c29f32014-06-20 12:00:00 -070087endif()
88
89# Level 0.1 - depends on nothing outside this set.
90add_subdirectory(stack)
91add_subdirectory(lhash)
92add_subdirectory(err)
93add_subdirectory(buf)
Adam Langley95c29f32014-06-20 12:00:00 -070094add_subdirectory(base64)
95add_subdirectory(bytestring)
96
97# Level 0.2 - depends on nothing but itself
98add_subdirectory(sha)
Adam Langleyc9eb7ea2014-08-22 11:06:14 -070099add_subdirectory(md4)
Adam Langley95c29f32014-06-20 12:00:00 -0700100add_subdirectory(md5)
101add_subdirectory(modes)
102add_subdirectory(aes)
103add_subdirectory(des)
104add_subdirectory(rc4)
105add_subdirectory(conf)
Adam Langleyde0b2022014-06-20 12:00:00 -0700106add_subdirectory(chacha)
107add_subdirectory(poly1305)
Adam Langley95c29f32014-06-20 12:00:00 -0700108
109# Level 1, depends only on 0.*
110add_subdirectory(digest)
111add_subdirectory(cipher)
112add_subdirectory(rand)
113add_subdirectory(bio)
114add_subdirectory(bn)
115add_subdirectory(obj)
116add_subdirectory(asn1)
117
118# Level 2
119add_subdirectory(engine)
120add_subdirectory(dh)
121add_subdirectory(dsa)
122add_subdirectory(rsa)
123add_subdirectory(ec)
124add_subdirectory(ecdh)
125add_subdirectory(ecdsa)
126add_subdirectory(hmac)
127
128# Level 3
Adam Langley0d107e12015-05-05 16:36:32 -0700129add_subdirectory(cmac)
Adam Langley95c29f32014-06-20 12:00:00 -0700130add_subdirectory(evp)
Nick Harper4685e872014-12-09 15:51:28 -0800131add_subdirectory(hkdf)
Adam Langley95c29f32014-06-20 12:00:00 -0700132add_subdirectory(pem)
133add_subdirectory(x509)
134add_subdirectory(x509v3)
135
136# Level 4
137add_subdirectory(pkcs8)
138
David Benjamin06b94de2015-05-09 22:46:47 -0400139# Test support code
140add_subdirectory(test)
141
Adam Langley95c29f32014-06-20 12:00:00 -0700142add_library(
Adam Langley4a0f0c42015-01-28 16:37:10 -0800143 crypto
Adam Langley95c29f32014-06-20 12:00:00 -0700144
Adam Langley4a0f0c42015-01-28 16:37:10 -0800145 crypto.c
Adam Langley6f2e7332015-05-15 12:01:29 -0700146 directory_posix.c
147 directory_win.c
148 ex_data.c
Adam Langley4a0f0c42015-01-28 16:37:10 -0800149 mem.c
Adam Langley6f2e7332015-05-15 12:01:29 -0700150 refcount_c11.c
151 refcount_lock.c
Adam Langley4a0f0c42015-01-28 16:37:10 -0800152 thread.c
Adam Langley65a7e942015-05-07 18:28:27 -0700153 thread_none.c
Adam Langleyd7c5dfb2015-03-16 12:48:56 -0700154 thread_pthread.c
155 thread_win.c
Adam Langley4a0f0c42015-01-28 16:37:10 -0800156 time_support.c
Adam Langley95c29f32014-06-20 12:00:00 -0700157
Adam Langley4a0f0c42015-01-28 16:37:10 -0800158 ${CRYPTO_ARCH_SOURCES}
Adam Langley95c29f32014-06-20 12:00:00 -0700159
Adam Langley4a0f0c42015-01-28 16:37:10 -0800160 $<TARGET_OBJECTS:stack>
161 $<TARGET_OBJECTS:lhash>
162 $<TARGET_OBJECTS:err>
163 $<TARGET_OBJECTS:base64>
164 $<TARGET_OBJECTS:bytestring>
165 $<TARGET_OBJECTS:sha>
166 $<TARGET_OBJECTS:md4>
167 $<TARGET_OBJECTS:md5>
168 $<TARGET_OBJECTS:digest>
169 $<TARGET_OBJECTS:cipher>
170 $<TARGET_OBJECTS:modes>
171 $<TARGET_OBJECTS:aes>
172 $<TARGET_OBJECTS:des>
173 $<TARGET_OBJECTS:rc4>
174 $<TARGET_OBJECTS:conf>
175 $<TARGET_OBJECTS:chacha>
176 $<TARGET_OBJECTS:poly1305>
177 $<TARGET_OBJECTS:buf>
178 $<TARGET_OBJECTS:bn>
179 $<TARGET_OBJECTS:bio>
180 $<TARGET_OBJECTS:rand>
181 $<TARGET_OBJECTS:obj>
182 $<TARGET_OBJECTS:asn1>
183 $<TARGET_OBJECTS:engine>
184 $<TARGET_OBJECTS:dh>
185 $<TARGET_OBJECTS:dsa>
186 $<TARGET_OBJECTS:rsa>
187 $<TARGET_OBJECTS:ec>
188 $<TARGET_OBJECTS:ecdh>
189 $<TARGET_OBJECTS:ecdsa>
190 $<TARGET_OBJECTS:hmac>
Adam Langley0d107e12015-05-05 16:36:32 -0700191 $<TARGET_OBJECTS:cmac>
Adam Langley4a0f0c42015-01-28 16:37:10 -0800192 $<TARGET_OBJECTS:evp>
193 $<TARGET_OBJECTS:hkdf>
194 $<TARGET_OBJECTS:pem>
195 $<TARGET_OBJECTS:x509>
196 $<TARGET_OBJECTS:x509v3>
197 $<TARGET_OBJECTS:pkcs8>
Adam Langley95c29f32014-06-20 12:00:00 -0700198)
199
Adam Langley843ab662015-04-28 17:46:58 -0700200if(NOT MSVC AND NOT ANDROID)
David Benjamin72f59112015-04-02 16:47:15 -0400201 target_link_libraries(crypto pthread)
202endif()
203
Adam Langleyb15d8132014-11-03 18:51:20 -0800204add_executable(
Adam Langley4a0f0c42015-01-28 16:37:10 -0800205 constant_time_test
Adam Langleyb15d8132014-11-03 18:51:20 -0800206
Adam Langley4a0f0c42015-01-28 16:37:10 -0800207 constant_time_test.c
David Benjamin0b635c52015-05-15 19:08:49 -0400208
209 $<TARGET_OBJECTS:test_support>
Adam Langleyb15d8132014-11-03 18:51:20 -0800210)
211
212target_link_libraries(constant_time_test crypto)
David Benjamin301afaf2015-10-14 21:34:40 -0400213add_dependencies(all_tests constant_time_test)
Adam Langleyb15d8132014-11-03 18:51:20 -0800214
Adam Langleyd7c5dfb2015-03-16 12:48:56 -0700215add_executable(
216 thread_test
217
218 thread_test.c
David Benjamin0b635c52015-05-15 19:08:49 -0400219
220 $<TARGET_OBJECTS:test_support>
Adam Langleyd7c5dfb2015-03-16 12:48:56 -0700221)
222
David Benjamin72f59112015-04-02 16:47:15 -0400223target_link_libraries(thread_test crypto)
David Benjamin301afaf2015-10-14 21:34:40 -0400224add_dependencies(all_tests thread_test)
Adam Langleyd7c5dfb2015-03-16 12:48:56 -0700225
Adam Langley6f2e7332015-05-15 12:01:29 -0700226add_executable(
227 refcount_test
228
229 refcount_test.c
230)
231
232target_link_libraries(refcount_test crypto)
David Benjamin301afaf2015-10-14 21:34:40 -0400233add_dependencies(all_tests refcount_test)