blob: ad2cdd7f853ec382684197d2f2d575e844e2574c [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)
David Benjamin3dbecdf2016-02-23 17:44:12 -050025 set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wa,--noexecstack")
Adam Langley95c29f32014-06-20 12:00:00 -070026else()
Adam Langley4a0f0c42015-01-28 16:37:10 -080027 if (CMAKE_CL_64)
28 message("Using nasm")
29 set(PERLASM_STYLE nasm)
30 else()
31 message("Using win32n")
32 set(PERLASM_STYLE win32n)
David Benjamin4616bb12015-03-26 18:33:00 -040033 set(PERLASM_FLAGS "-DOPENSSL_IA32_SSE2")
Adam Langley4a0f0c42015-01-28 16:37:10 -080034 endif()
David Benjaminbc786a92014-10-31 17:27:40 -040035
Adam Langley4a0f0c42015-01-28 16:37:10 -080036 # On Windows, we use the NASM output, specifically built with Yasm.
37 set(ASM_EXT asm)
38 enable_language(ASM_NASM)
Adam Langley95c29f32014-06-20 12:00:00 -070039endif()
40
41function(perlasm dest src)
Adam Langley4a0f0c42015-01-28 16:37:10 -080042 add_custom_command(
43 OUTPUT ${dest}
David Benjamin3ce3c362015-02-23 13:06:19 -050044 COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${src} ${PERLASM_STYLE} ${PERLASM_FLAGS} ${ARGN} > ${dest}
Adam Langley4a0f0c42015-01-28 16:37:10 -080045 DEPENDS
46 ${src}
David Benjaminf06802f2015-04-20 13:25:46 -040047 ${PROJECT_SOURCE_DIR}/crypto/perlasm/arm-xlate.pl
Adam Langley4a0f0c42015-01-28 16:37:10 -080048 ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86_64-xlate.pl
49 ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86asm.pl
50 ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86gas.pl
51 ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86masm.pl
52 ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86nasm.pl
53 WORKING_DIRECTORY .
54 )
Adam Langley95c29f32014-06-20 12:00:00 -070055endfunction()
56
57if (${ARCH} STREQUAL "x86_64")
Adam Langley4a0f0c42015-01-28 16:37:10 -080058 set(
59 CRYPTO_ARCH_SOURCES
Adam Langley95c29f32014-06-20 12:00:00 -070060
Adam Langley4a0f0c42015-01-28 16:37:10 -080061 cpu-intel.c
62 )
Adam Langley95c29f32014-06-20 12:00:00 -070063endif()
64
65if (${ARCH} STREQUAL "x86")
Adam Langley4a0f0c42015-01-28 16:37:10 -080066 set(
67 CRYPTO_ARCH_SOURCES
Adam Langley95c29f32014-06-20 12:00:00 -070068
Adam Langley4a0f0c42015-01-28 16:37:10 -080069 cpu-intel.c
70 )
Adam Langley95c29f32014-06-20 12:00:00 -070071endif()
72
73if (${ARCH} STREQUAL "arm")
Adam Langley4a0f0c42015-01-28 16:37:10 -080074 set(
75 CRYPTO_ARCH_SOURCES
Adam Langley95c29f32014-06-20 12:00:00 -070076
Adam Langley4a0f0c42015-01-28 16:37:10 -080077 cpu-arm.c
Adam Langleyd062c8a2015-01-30 15:30:44 -080078 cpu-arm-asm.S
Adam Langley4a0f0c42015-01-28 16:37:10 -080079 )
Adam Langley3e652652015-01-09 15:44:37 -080080endif()
81
82if (${ARCH} STREQUAL "aarch64")
Adam Langley4a0f0c42015-01-28 16:37:10 -080083 set(
84 CRYPTO_ARCH_SOURCES
Adam Langley3e652652015-01-09 15:44:37 -080085
Adam Langley4a0f0c42015-01-28 16:37:10 -080086 cpu-arm.c
87 )
Adam Langley95c29f32014-06-20 12:00:00 -070088endif()
89
90# Level 0.1 - depends on nothing outside this set.
91add_subdirectory(stack)
92add_subdirectory(lhash)
93add_subdirectory(err)
94add_subdirectory(buf)
Adam Langley95c29f32014-06-20 12:00:00 -070095add_subdirectory(base64)
96add_subdirectory(bytestring)
97
98# Level 0.2 - depends on nothing but itself
99add_subdirectory(sha)
Adam Langleyc9eb7ea2014-08-22 11:06:14 -0700100add_subdirectory(md4)
Adam Langley95c29f32014-06-20 12:00:00 -0700101add_subdirectory(md5)
102add_subdirectory(modes)
103add_subdirectory(aes)
104add_subdirectory(des)
105add_subdirectory(rc4)
106add_subdirectory(conf)
Adam Langleyde0b2022014-06-20 12:00:00 -0700107add_subdirectory(chacha)
108add_subdirectory(poly1305)
Adam Langley4fb0dc42015-11-13 13:09:47 -0800109add_subdirectory(curve25519)
Adam Langley95c29f32014-06-20 12:00:00 -0700110
111# Level 1, depends only on 0.*
112add_subdirectory(digest)
113add_subdirectory(cipher)
114add_subdirectory(rand)
115add_subdirectory(bio)
116add_subdirectory(bn)
117add_subdirectory(obj)
118add_subdirectory(asn1)
119
120# Level 2
121add_subdirectory(engine)
122add_subdirectory(dh)
123add_subdirectory(dsa)
124add_subdirectory(rsa)
125add_subdirectory(ec)
126add_subdirectory(ecdh)
127add_subdirectory(ecdsa)
128add_subdirectory(hmac)
129
130# Level 3
Adam Langley0d107e12015-05-05 16:36:32 -0700131add_subdirectory(cmac)
Adam Langley95c29f32014-06-20 12:00:00 -0700132add_subdirectory(evp)
Nick Harper4685e872014-12-09 15:51:28 -0800133add_subdirectory(hkdf)
Adam Langley95c29f32014-06-20 12:00:00 -0700134add_subdirectory(pem)
135add_subdirectory(x509)
136add_subdirectory(x509v3)
137
138# Level 4
139add_subdirectory(pkcs8)
140
David Benjamin06b94de2015-05-09 22:46:47 -0400141# Test support code
142add_subdirectory(test)
143
Adam Langley95c29f32014-06-20 12:00:00 -0700144add_library(
Adam Langley4a0f0c42015-01-28 16:37:10 -0800145 crypto
Adam Langley95c29f32014-06-20 12:00:00 -0700146
Adam Langley4a0f0c42015-01-28 16:37:10 -0800147 crypto.c
Adam Langley6f2e7332015-05-15 12:01:29 -0700148 directory_posix.c
149 directory_win.c
150 ex_data.c
Adam Langley4a0f0c42015-01-28 16:37:10 -0800151 mem.c
Adam Langley6f2e7332015-05-15 12:01:29 -0700152 refcount_c11.c
153 refcount_lock.c
Adam Langley4a0f0c42015-01-28 16:37:10 -0800154 thread.c
Adam Langley65a7e942015-05-07 18:28:27 -0700155 thread_none.c
Adam Langleyd7c5dfb2015-03-16 12:48:56 -0700156 thread_pthread.c
157 thread_win.c
Adam Langley4a0f0c42015-01-28 16:37:10 -0800158 time_support.c
Adam Langley95c29f32014-06-20 12:00:00 -0700159
Adam Langley4a0f0c42015-01-28 16:37:10 -0800160 ${CRYPTO_ARCH_SOURCES}
Adam Langley95c29f32014-06-20 12:00:00 -0700161
Adam Langley4a0f0c42015-01-28 16:37:10 -0800162 $<TARGET_OBJECTS:stack>
163 $<TARGET_OBJECTS:lhash>
164 $<TARGET_OBJECTS:err>
165 $<TARGET_OBJECTS:base64>
166 $<TARGET_OBJECTS:bytestring>
167 $<TARGET_OBJECTS:sha>
168 $<TARGET_OBJECTS:md4>
169 $<TARGET_OBJECTS:md5>
170 $<TARGET_OBJECTS:digest>
171 $<TARGET_OBJECTS:cipher>
172 $<TARGET_OBJECTS:modes>
173 $<TARGET_OBJECTS:aes>
174 $<TARGET_OBJECTS:des>
175 $<TARGET_OBJECTS:rc4>
176 $<TARGET_OBJECTS:conf>
177 $<TARGET_OBJECTS:chacha>
178 $<TARGET_OBJECTS:poly1305>
Adam Langley4fb0dc42015-11-13 13:09:47 -0800179 $<TARGET_OBJECTS:curve25519>
Adam Langley4a0f0c42015-01-28 16:37:10 -0800180 $<TARGET_OBJECTS:buf>
181 $<TARGET_OBJECTS:bn>
182 $<TARGET_OBJECTS:bio>
183 $<TARGET_OBJECTS:rand>
184 $<TARGET_OBJECTS:obj>
185 $<TARGET_OBJECTS:asn1>
186 $<TARGET_OBJECTS:engine>
187 $<TARGET_OBJECTS:dh>
188 $<TARGET_OBJECTS:dsa>
189 $<TARGET_OBJECTS:rsa>
190 $<TARGET_OBJECTS:ec>
191 $<TARGET_OBJECTS:ecdh>
192 $<TARGET_OBJECTS:ecdsa>
193 $<TARGET_OBJECTS:hmac>
Adam Langley0d107e12015-05-05 16:36:32 -0700194 $<TARGET_OBJECTS:cmac>
Adam Langley4a0f0c42015-01-28 16:37:10 -0800195 $<TARGET_OBJECTS:evp>
196 $<TARGET_OBJECTS:hkdf>
197 $<TARGET_OBJECTS:pem>
198 $<TARGET_OBJECTS:x509>
199 $<TARGET_OBJECTS:x509v3>
200 $<TARGET_OBJECTS:pkcs8>
Adam Langley95c29f32014-06-20 12:00:00 -0700201)
202
Adam Langley843ab662015-04-28 17:46:58 -0700203if(NOT MSVC AND NOT ANDROID)
David Benjamin72f59112015-04-02 16:47:15 -0400204 target_link_libraries(crypto pthread)
205endif()
206
Adam Langleyb15d8132014-11-03 18:51:20 -0800207add_executable(
Adam Langley4a0f0c42015-01-28 16:37:10 -0800208 constant_time_test
Adam Langleyb15d8132014-11-03 18:51:20 -0800209
Adam Langley4a0f0c42015-01-28 16:37:10 -0800210 constant_time_test.c
David Benjamin0b635c52015-05-15 19:08:49 -0400211
212 $<TARGET_OBJECTS:test_support>
Adam Langleyb15d8132014-11-03 18:51:20 -0800213)
214
215target_link_libraries(constant_time_test crypto)
David Benjamin301afaf2015-10-14 21:34:40 -0400216add_dependencies(all_tests constant_time_test)
Adam Langleyb15d8132014-11-03 18:51:20 -0800217
Adam Langleyd7c5dfb2015-03-16 12:48:56 -0700218add_executable(
219 thread_test
220
221 thread_test.c
David Benjamin0b635c52015-05-15 19:08:49 -0400222
223 $<TARGET_OBJECTS:test_support>
Adam Langleyd7c5dfb2015-03-16 12:48:56 -0700224)
225
David Benjamin72f59112015-04-02 16:47:15 -0400226target_link_libraries(thread_test crypto)
David Benjamin301afaf2015-10-14 21:34:40 -0400227add_dependencies(all_tests thread_test)
Adam Langleyd7c5dfb2015-03-16 12:48:56 -0700228
Adam Langley6f2e7332015-05-15 12:01:29 -0700229add_executable(
230 refcount_test
231
232 refcount_test.c
233)
234
235target_link_libraries(refcount_test crypto)
David Benjamin301afaf2015-10-14 21:34:40 -0400236add_dependencies(all_tests refcount_test)