26
|
1 if (${STATIC_BUILD})
|
|
2 SET(OPENSSL_SOURCES_DIR ${CMAKE_BINARY_DIR}/openssl-1.0.1c)
|
|
3 DownloadPackage("http://www.openssl.org/source/openssl-1.0.1c.tar.gz" "${OPENSSL_SOURCES_DIR}" "" "")
|
|
4
|
27
|
5 if (NOT EXISTS "${OPENSSL_SOURCES_DIR}/include/PATCHED")
|
|
6 message("Patching the symbolic links")
|
|
7 if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
|
|
8 # Patch the symbolic links by copying the files
|
|
9 file(GLOB headers "${OPENSSL_SOURCES_DIR}/include/openssl/*.h")
|
|
10 foreach(header ${headers})
|
|
11 message(${header})
|
|
12 file(READ "${header}" symbolicLink)
|
|
13 message(${symbolicLink})
|
|
14 configure_file("${OPENSSL_SOURCES_DIR}/include/openssl/${symbolicLink}" "${header}" COPYONLY)
|
|
15 endforeach()
|
|
16 file(WRITE "${OPENSSL_SOURCES_DIR}/include/PATCHED")
|
|
17 endif()
|
|
18 endif()
|
|
19
|
26
|
20 add_definitions(
|
|
21 -DOPENSSL_THREADS
|
|
22 -DOPENSSL_IA32_SSE2
|
|
23 -DOPENSSL_NO_ASM
|
|
24 -DOPENSSL_NO_DYNAMIC_ENGINE
|
|
25 -DNO_WINDOWS_BRAINDEATH
|
|
26
|
|
27 -DOPENSSL_NO_BF
|
|
28 -DOPENSSL_NO_CAMELLIA
|
|
29 -DOPENSSL_NO_CAST
|
|
30 -DOPENSSL_NO_EC
|
|
31 -DOPENSSL_NO_ECDH
|
|
32 -DOPENSSL_NO_ECDSA
|
|
33 -DOPENSSL_NO_EC_NISTP_64_GCC_128
|
|
34 -DOPENSSL_NO_GMP
|
|
35 -DOPENSSL_NO_GOST
|
|
36 -DOPENSSL_NO_HW
|
|
37 -DOPENSSL_NO_JPAKE
|
|
38 -DOPENSSL_NO_IDEA
|
|
39 -DOPENSSL_NO_KRB5
|
|
40 -DOPENSSL_NO_MD2
|
|
41 -DOPENSSL_NO_MDC2
|
|
42 -DOPENSSL_NO_MD4
|
|
43 -DOPENSSL_NO_RC2
|
|
44 -DOPENSSL_NO_RC4
|
|
45 -DOPENSSL_NO_RC5
|
|
46 -DOPENSSL_NO_RFC3779
|
|
47 -DOPENSSL_NO_SCTP
|
|
48 -DOPENSSL_NO_STORE
|
|
49 -DOPENSSL_NO_SEED
|
|
50 -DOPENSSL_NO_WHIRLPOOL
|
|
51 -DOPENSSL_NO_RIPEMD
|
|
52 )
|
|
53
|
27
|
54 if (${MSVC})
|
|
55 # http://stackoverflow.com/a/1372836/881731
|
|
56 # add_definitions(-D_WINSOCKAPI_)
|
|
57 add_definitions(
|
|
58 -DOPENSSL_SYSNAME_WIN32
|
|
59 -DOPENSSL_SYS_MSDOS
|
|
60 -DSO_WIN32
|
|
61 # -DWIN32_LEAN_AND_MEAN
|
|
62 -DOPENSSL_NO_SOCK
|
|
63 -DL_ENDIAN
|
|
64 )
|
|
65 endif()
|
|
66
|
26
|
67 include_directories(
|
|
68 ${OPENSSL_SOURCES_DIR}
|
|
69 ${OPENSSL_SOURCES_DIR}/crypto
|
|
70 ${OPENSSL_SOURCES_DIR}/crypto/asn1
|
|
71 ${OPENSSL_SOURCES_DIR}/crypto/modes
|
|
72 ${OPENSSL_SOURCES_DIR}/crypto/evp
|
|
73 ${OPENSSL_SOURCES_DIR}/include
|
|
74 )
|
|
75
|
|
76 set(OPENSSL_SOURCES_SUBDIRS
|
|
77 ${OPENSSL_SOURCES_DIR}/crypto
|
|
78 ${OPENSSL_SOURCES_DIR}/crypto/aes
|
|
79 ${OPENSSL_SOURCES_DIR}/crypto/asn1
|
|
80 ${OPENSSL_SOURCES_DIR}/crypto/bio
|
|
81 ${OPENSSL_SOURCES_DIR}/crypto/bn
|
|
82 ${OPENSSL_SOURCES_DIR}/crypto/buffer
|
|
83 ${OPENSSL_SOURCES_DIR}/crypto/cmac
|
|
84 ${OPENSSL_SOURCES_DIR}/crypto/cms
|
|
85 ${OPENSSL_SOURCES_DIR}/crypto/comp
|
|
86 ${OPENSSL_SOURCES_DIR}/crypto/conf
|
|
87 ${OPENSSL_SOURCES_DIR}/crypto/des
|
|
88 ${OPENSSL_SOURCES_DIR}/crypto/dh
|
|
89 ${OPENSSL_SOURCES_DIR}/crypto/dsa
|
|
90 ${OPENSSL_SOURCES_DIR}/crypto/dso
|
|
91 ${OPENSSL_SOURCES_DIR}/crypto/engine
|
|
92 ${OPENSSL_SOURCES_DIR}/crypto/err
|
|
93 ${OPENSSL_SOURCES_DIR}/crypto/evp
|
|
94 ${OPENSSL_SOURCES_DIR}/crypto/hmac
|
|
95 ${OPENSSL_SOURCES_DIR}/crypto/lhash
|
|
96 ${OPENSSL_SOURCES_DIR}/crypto/md5
|
|
97 ${OPENSSL_SOURCES_DIR}/crypto/modes
|
|
98 ${OPENSSL_SOURCES_DIR}/crypto/objects
|
|
99 ${OPENSSL_SOURCES_DIR}/crypto/ocsp
|
|
100 ${OPENSSL_SOURCES_DIR}/crypto/pem
|
|
101 ${OPENSSL_SOURCES_DIR}/crypto/pkcs12
|
|
102 ${OPENSSL_SOURCES_DIR}/crypto/pkcs7
|
|
103 ${OPENSSL_SOURCES_DIR}/crypto/pqueue
|
|
104 ${OPENSSL_SOURCES_DIR}/crypto/rand
|
|
105 ${OPENSSL_SOURCES_DIR}/crypto/rsa
|
|
106 ${OPENSSL_SOURCES_DIR}/crypto/sha
|
|
107 ${OPENSSL_SOURCES_DIR}/crypto/srp
|
|
108 ${OPENSSL_SOURCES_DIR}/crypto/stack
|
|
109 ${OPENSSL_SOURCES_DIR}/crypto/ts
|
|
110 ${OPENSSL_SOURCES_DIR}/crypto/txt_db
|
|
111 ${OPENSSL_SOURCES_DIR}/crypto/ui
|
|
112 ${OPENSSL_SOURCES_DIR}/crypto/x509
|
|
113 ${OPENSSL_SOURCES_DIR}/crypto/x509v3
|
|
114 ${OPENSSL_SOURCES_DIR}/ssl
|
|
115 )
|
|
116
|
|
117 foreach(d ${OPENSSL_SOURCES_SUBDIRS})
|
|
118 AUX_SOURCE_DIRECTORY(${d} OPENSSL_SOURCES)
|
|
119 endforeach()
|
|
120
|
|
121 list(REMOVE_ITEM OPENSSL_SOURCES
|
|
122 ${OPENSSL_SOURCES_DIR}/crypto/LPdir_nyi.c
|
|
123 ${OPENSSL_SOURCES_DIR}/crypto/LPdir_unix.c
|
|
124 ${OPENSSL_SOURCES_DIR}/crypto/LPdir_vms.c
|
|
125 ${OPENSSL_SOURCES_DIR}/crypto/LPdir_win.c
|
|
126 ${OPENSSL_SOURCES_DIR}/crypto/LPdir_win32.c
|
|
127 ${OPENSSL_SOURCES_DIR}/crypto/LPdir_wince.c
|
|
128 ${OPENSSL_SOURCES_DIR}/crypto/armcap.c
|
|
129 ${OPENSSL_SOURCES_DIR}/crypto/bf/bfs.cpp
|
|
130 ${OPENSSL_SOURCES_DIR}/crypto/bio/bss_rtcp.c
|
|
131 ${OPENSSL_SOURCES_DIR}/crypto/bn/exp.c
|
|
132 ${OPENSSL_SOURCES_DIR}/crypto/conf/cnf_save.c
|
|
133 ${OPENSSL_SOURCES_DIR}/crypto/conf/test.c
|
|
134 ${OPENSSL_SOURCES_DIR}/crypto/des/des3s.cpp
|
|
135 ${OPENSSL_SOURCES_DIR}/crypto/des/des_opts.c
|
|
136 ${OPENSSL_SOURCES_DIR}/crypto/des/dess.cpp
|
|
137 ${OPENSSL_SOURCES_DIR}/crypto/des/read_pwd.c
|
|
138 ${OPENSSL_SOURCES_DIR}/crypto/des/speed.c
|
|
139 ${OPENSSL_SOURCES_DIR}/crypto/evp/e_dsa.c
|
|
140 ${OPENSSL_SOURCES_DIR}/crypto/evp/m_ripemd.c
|
|
141 ${OPENSSL_SOURCES_DIR}/crypto/lhash/lh_test.c
|
|
142 ${OPENSSL_SOURCES_DIR}/crypto/md5/md5s.cpp
|
|
143 ${OPENSSL_SOURCES_DIR}/crypto/pkcs7/bio_ber.c
|
|
144 ${OPENSSL_SOURCES_DIR}/crypto/pkcs7/pk7_enc.c
|
|
145 ${OPENSSL_SOURCES_DIR}/crypto/ppccap.c
|
27
|
146 ${OPENSSL_SOURCES_DIR}/crypto/rand/randtest.c
|
26
|
147 ${OPENSSL_SOURCES_DIR}/crypto/s390xcap.c
|
|
148 ${OPENSSL_SOURCES_DIR}/crypto/sparcv9cap.c
|
|
149 ${OPENSSL_SOURCES_DIR}/crypto/x509v3/tabtest.c
|
|
150 ${OPENSSL_SOURCES_DIR}/crypto/x509v3/v3conf.c
|
|
151 ${OPENSSL_SOURCES_DIR}/ssl/ssl_task.c
|
|
152 )
|
|
153
|
|
154 add_library(OpenSSL STATIC ${OPENSSL_SOURCES})
|
|
155 link_libraries(OpenSSL)
|
|
156
|
|
157 else()
|
|
158 include(FindOpenSSL)
|
|
159
|
|
160 if (NOT ${OPENSSL_FOUND})
|
|
161 message(FATAL_ERROR "Unable to find OpenSSL")
|
|
162 endif()
|
|
163
|
|
164 include_directories(${OPENSSL_INCLUDE_DIR})
|
|
165 link_libraries(${OPENSSL_LIBRARIES})
|
|
166 endif()
|