comparison Resources/CMake/OpenSslConfigurationStatic-1.1.1.cmake @ 3786:3801435e34a1 SylvainRouquette/fix-issue169-95b752c

integration Orthanc-1.6.0->SylvainRouquette
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 19 Mar 2020 11:48:30 +0100
parents 7b7ca203f1a3
children 6462ecaa045b
comparison
equal deleted inserted replaced
3785:763533d6dd67 3786:3801435e34a1
1 SET(OPENSSL_SOURCES_DIR ${CMAKE_BINARY_DIR}/openssl-1.1.1d)
2 SET(OPENSSL_URL "http://orthanc.osimis.io/ThirdPartyDownloads/openssl-1.1.1d.tar.gz")
3 SET(OPENSSL_MD5 "3be209000dbc7e1b95bcdf47980a3baa")
4
5 if (IS_DIRECTORY "${OPENSSL_SOURCES_DIR}")
6 set(FirstRun OFF)
7 else()
8 set(FirstRun ON)
9 endif()
10
11 DownloadPackage(${OPENSSL_MD5} ${OPENSSL_URL} "${OPENSSL_SOURCES_DIR}")
12
13 if (FirstRun)
14 file(WRITE ${OPENSSL_SOURCES_DIR}/crypto/buildinf.h "
15 #define DATE \"\"
16 #define PLATFORM \"\"
17 #define compiler_flags \"\"
18 ")
19 file(WRITE ${OPENSSL_SOURCES_DIR}/crypto/include/internal/bn_conf.h "")
20 file(WRITE ${OPENSSL_SOURCES_DIR}/crypto/include/internal/dso_conf.h "")
21
22 configure_file(
23 ${ORTHANC_ROOT}/Resources/Patches/openssl-1.1.1d-conf.h.in
24 ${OPENSSL_SOURCES_DIR}/include/openssl/opensslconf.h
25 )
26
27 # Apply the patches
28 execute_process(
29 COMMAND ${PATCH_EXECUTABLE} -p0 -N -i
30 ${ORTHANC_ROOT}/Resources/Patches/openssl-1.1.1d.patch
31 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
32 RESULT_VARIABLE Failure
33 )
34
35 if (Failure)
36 message(FATAL_ERROR "Error while patching a file")
37 endif()
38 else()
39 message("The patches for OpenSSL have already been applied")
40 endif()
41
42 add_definitions(
43 -DOPENSSL_THREADS
44 -DOPENSSL_IA32_SSE2
45 -DOPENSSL_NO_ASM
46 -DOPENSSL_NO_DYNAMIC_ENGINE
47 -DOPENSSL_NO_DEVCRYPTOENG
48
49 -DOPENSSL_NO_BF
50 -DOPENSSL_NO_CAMELLIA
51 -DOPENSSL_NO_CAST
52 -DOPENSSL_NO_EC_NISTP_64_GCC_128
53 -DOPENSSL_NO_GMP
54 -DOPENSSL_NO_GOST
55 -DOPENSSL_NO_HW
56 -DOPENSSL_NO_JPAKE
57 -DOPENSSL_NO_IDEA
58 -DOPENSSL_NO_KRB5
59 -DOPENSSL_NO_MD2
60 -DOPENSSL_NO_MDC2
61 #-DOPENSSL_NO_MD4 # MD4 is necessary for MariaDB/MySQL client
62 -DOPENSSL_NO_RC2
63 -DOPENSSL_NO_RC4
64 -DOPENSSL_NO_RC5
65 -DOPENSSL_NO_RFC3779
66 -DOPENSSL_NO_SCTP
67 -DOPENSSL_NO_STORE
68 -DOPENSSL_NO_SEED
69 -DOPENSSL_NO_WHIRLPOOL
70 -DOPENSSL_NO_RIPEMD
71 -DOPENSSL_NO_AFALGENG
72
73 -DOPENSSLDIR="/usr/local/ssl"
74 )
75
76
77 include_directories(
78 ${OPENSSL_SOURCES_DIR}
79 ${OPENSSL_SOURCES_DIR}/crypto
80 ${OPENSSL_SOURCES_DIR}/crypto/asn1
81 ${OPENSSL_SOURCES_DIR}/crypto/ec/curve448
82 ${OPENSSL_SOURCES_DIR}/crypto/ec/curve448/arch_32
83 ${OPENSSL_SOURCES_DIR}/crypto/evp
84 ${OPENSSL_SOURCES_DIR}/crypto/include
85 ${OPENSSL_SOURCES_DIR}/crypto/modes
86 ${OPENSSL_SOURCES_DIR}/include
87 )
88
89
90 set(OPENSSL_SOURCES_SUBDIRS
91 ${OPENSSL_SOURCES_DIR}/crypto
92 ${OPENSSL_SOURCES_DIR}/crypto/aes
93 ${OPENSSL_SOURCES_DIR}/crypto/aria
94 ${OPENSSL_SOURCES_DIR}/crypto/asn1
95 ${OPENSSL_SOURCES_DIR}/crypto/async
96 ${OPENSSL_SOURCES_DIR}/crypto/async/arch
97 ${OPENSSL_SOURCES_DIR}/crypto/bio
98 ${OPENSSL_SOURCES_DIR}/crypto/blake2
99 ${OPENSSL_SOURCES_DIR}/crypto/bn
100 ${OPENSSL_SOURCES_DIR}/crypto/buffer
101 ${OPENSSL_SOURCES_DIR}/crypto/chacha
102 ${OPENSSL_SOURCES_DIR}/crypto/cmac
103 ${OPENSSL_SOURCES_DIR}/crypto/cms
104 ${OPENSSL_SOURCES_DIR}/crypto/comp
105 ${OPENSSL_SOURCES_DIR}/crypto/conf
106 ${OPENSSL_SOURCES_DIR}/crypto/ct
107 ${OPENSSL_SOURCES_DIR}/crypto/des
108 ${OPENSSL_SOURCES_DIR}/crypto/dh
109 ${OPENSSL_SOURCES_DIR}/crypto/dsa
110 ${OPENSSL_SOURCES_DIR}/crypto/dso
111 ${OPENSSL_SOURCES_DIR}/crypto/ec
112 ${OPENSSL_SOURCES_DIR}/crypto/ec/curve448
113 ${OPENSSL_SOURCES_DIR}/crypto/ec/curve448/arch_32
114 ${OPENSSL_SOURCES_DIR}/crypto/err
115 ${OPENSSL_SOURCES_DIR}/crypto/evp
116 ${OPENSSL_SOURCES_DIR}/crypto/hmac
117 ${OPENSSL_SOURCES_DIR}/crypto/kdf
118 ${OPENSSL_SOURCES_DIR}/crypto/lhash
119 ${OPENSSL_SOURCES_DIR}/crypto/md4
120 ${OPENSSL_SOURCES_DIR}/crypto/md5
121 ${OPENSSL_SOURCES_DIR}/crypto/modes
122 ${OPENSSL_SOURCES_DIR}/crypto/objects
123 ${OPENSSL_SOURCES_DIR}/crypto/ocsp
124 ${OPENSSL_SOURCES_DIR}/crypto/pem
125 ${OPENSSL_SOURCES_DIR}/crypto/pkcs12
126 ${OPENSSL_SOURCES_DIR}/crypto/pkcs7
127 ${OPENSSL_SOURCES_DIR}/crypto/poly1305
128 ${OPENSSL_SOURCES_DIR}/crypto/pqueue
129 ${OPENSSL_SOURCES_DIR}/crypto/rand
130 ${OPENSSL_SOURCES_DIR}/crypto/ripemd
131 ${OPENSSL_SOURCES_DIR}/crypto/rsa
132 ${OPENSSL_SOURCES_DIR}/crypto/sha
133 ${OPENSSL_SOURCES_DIR}/crypto/siphash
134 ${OPENSSL_SOURCES_DIR}/crypto/sm2
135 ${OPENSSL_SOURCES_DIR}/crypto/sm3
136 ${OPENSSL_SOURCES_DIR}/crypto/sm4
137 ${OPENSSL_SOURCES_DIR}/crypto/srp
138 ${OPENSSL_SOURCES_DIR}/crypto/stack
139 ${OPENSSL_SOURCES_DIR}/crypto/store
140 ${OPENSSL_SOURCES_DIR}/crypto/ts
141 ${OPENSSL_SOURCES_DIR}/crypto/txt_db
142 ${OPENSSL_SOURCES_DIR}/crypto/ui
143 ${OPENSSL_SOURCES_DIR}/crypto/x509
144 ${OPENSSL_SOURCES_DIR}/crypto/x509v3
145 ${OPENSSL_SOURCES_DIR}/ssl
146 ${OPENSSL_SOURCES_DIR}/ssl/record
147 ${OPENSSL_SOURCES_DIR}/ssl/statem
148 )
149
150 if (ENABLE_OPENSSL_ENGINES)
151 add_definitions(
152 #-DENGINESDIR="/usr/local/lib/engines-1.1" # On GNU/Linux
153 -DENGINESDIR="."
154 )
155
156 list(APPEND OPENSSL_SOURCES_SUBDIRS
157 ${OPENSSL_SOURCES_DIR}/engines
158 ${OPENSSL_SOURCES_DIR}/crypto/engine
159 )
160 else()
161 add_definitions(-DOPENSSL_NO_ENGINE)
162 endif()
163
164 list(APPEND OPENSSL_SOURCES_SUBDIRS
165 # EC, ECDH and ECDSA are necessary for PKCS11, and for contacting
166 # HTTPS servers that use TLS certificate encrypted with ECDSA
167 # (check the output of a recent version of the "sslscan"
168 # command). Until Orthanc <= 1.4.1, these features were only
169 # enabled if ENABLE_PKCS11 support was set to "ON".
170 # https://groups.google.com/d/msg/orthanc-users/2l-bhYIMEWg/oMmK33bYBgAJ
171 ${OPENSSL_SOURCES_DIR}/crypto/ec
172 ${OPENSSL_SOURCES_DIR}/crypto/ecdh
173 ${OPENSSL_SOURCES_DIR}/crypto/ecdsa
174 )
175
176 foreach(d ${OPENSSL_SOURCES_SUBDIRS})
177 AUX_SOURCE_DIRECTORY(${d} OPENSSL_SOURCES)
178 endforeach()
179
180 list(REMOVE_ITEM OPENSSL_SOURCES
181 ${OPENSSL_SOURCES_DIR}/crypto/LPdir_nyi.c
182 ${OPENSSL_SOURCES_DIR}/crypto/LPdir_unix.c
183 ${OPENSSL_SOURCES_DIR}/crypto/LPdir_vms.c
184 ${OPENSSL_SOURCES_DIR}/crypto/LPdir_win.c
185 ${OPENSSL_SOURCES_DIR}/crypto/LPdir_win32.c
186 ${OPENSSL_SOURCES_DIR}/crypto/LPdir_wince.c
187 ${OPENSSL_SOURCES_DIR}/crypto/aes/aes_x86core.c
188 ${OPENSSL_SOURCES_DIR}/crypto/armcap.c
189 ${OPENSSL_SOURCES_DIR}/crypto/bio/bss_dgram.c
190 ${OPENSSL_SOURCES_DIR}/crypto/des/ncbc_enc.c
191 ${OPENSSL_SOURCES_DIR}/crypto/ec/ecp_nistz256.c
192 ${OPENSSL_SOURCES_DIR}/crypto/ec/ecp_nistz256_table.c
193 ${OPENSSL_SOURCES_DIR}/crypto/engine/eng_devcrypto.c
194 ${OPENSSL_SOURCES_DIR}/crypto/poly1305/poly1305_base2_44.c # Cannot be compiled with MinGW
195 ${OPENSSL_SOURCES_DIR}/crypto/poly1305/poly1305_ieee754.c # Cannot be compiled with MinGW
196 ${OPENSSL_SOURCES_DIR}/crypto/ppccap.c
197 ${OPENSSL_SOURCES_DIR}/crypto/s390xcap.c
198 ${OPENSSL_SOURCES_DIR}/crypto/sparcv9cap.c
199 ${OPENSSL_SOURCES_DIR}/engines/e_afalg.c # Cannot be compiled with MinGW
200 )
201
202 # Check out "${OPENSSL_SOURCES_DIR}/Configurations/README": "This is
203 # default if no option is specified, it works on any supported
204 # system." It is mandatory to define it as a macro, as it is used by
205 # all the source files that include OpenSSL (e.g. "Core/Toolbox.cpp"
206 # or curl)
207 add_definitions(-DTHIRTY_TWO_BIT)
208
209
210 if (NOT CMAKE_COMPILER_IS_GNUCXX OR
211 "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" OR
212 "${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase")
213 # Disable the use of a gcc extension, that is neither available on
214 # MinGW, nor on LSB
215 add_definitions(
216 -DOPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE
217 )
218 endif()
219
220
221 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
222 set(OPENSSL_DEFINITIONS
223 "${OPENSSL_DEFINITIONS};OPENSSL_SYSNAME_WIN32;SO_WIN32;WIN32_LEAN_AND_MEAN;L_ENDIAN;NO_WINDOWS_BRAINDEATH")
224
225 if (ENABLE_OPENSSL_ENGINES)
226 link_libraries(crypt32)
227 endif()
228
229 add_definitions(
230 -DOPENSSL_RAND_SEED_OS # ${OPENSSL_SOURCES_DIR}/crypto/rand/rand_win.c
231 )
232
233 elseif ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase")
234 # In order for "crypto/mem_sec.c" to compile on LSB
235 add_definitions(
236 -DOPENSSL_NO_SECURE_MEMORY
237 )
238 endif()
239
240
241 set_source_files_properties(
242 ${OPENSSL_SOURCES}
243 PROPERTIES COMPILE_DEFINITIONS
244 "${OPENSSL_DEFINITIONS};DSO_NONE"
245 )