Skip to content

Commit db3b419

Browse files
committed
V2.6.4.0
1 parent 3793cb9 commit db3b419

File tree

1,483 files changed

+552176
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,483 files changed

+552176
-1
lines changed

CMakeLists.txt

+350
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,350 @@
1+
cmake_minimum_required (VERSION 2.8.8)
2+
include(CheckFunctionExists)
3+
include(CheckLibraryExists)
4+
include(CheckIncludeFiles)
5+
include(CheckTypeSize)
6+
7+
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" ${CMAKE_MODULE_PATH})
8+
include(cmake_export_symbol)
9+
include(GNUInstallDirs)
10+
11+
project (LibreSSL C)
12+
13+
enable_testing()
14+
15+
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/ssl/VERSION SSL_VERSION)
16+
string(STRIP ${SSL_VERSION} SSL_VERSION)
17+
string(REPLACE ":" "." SSL_VERSION ${SSL_VERSION})
18+
string(REGEX REPLACE "\\..*" "" SSL_MAJOR_VERSION ${SSL_VERSION})
19+
20+
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/crypto/VERSION CRYPTO_VERSION)
21+
string(STRIP ${CRYPTO_VERSION} CRYPTO_VERSION)
22+
string(REPLACE ":" "." CRYPTO_VERSION ${CRYPTO_VERSION})
23+
string(REGEX REPLACE "\\..*" "" CRYPTO_MAJOR_VERSION ${CRYPTO_VERSION})
24+
25+
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/tls/VERSION TLS_VERSION)
26+
string(STRIP ${TLS_VERSION} TLS_VERSION)
27+
string(REPLACE ":" "." TLS_VERSION ${TLS_VERSION})
28+
string(REGEX REPLACE "\\..*" "" TLS_MAJOR_VERSION ${TLS_VERSION})
29+
30+
option(LIBRESSL_SKIP_INSTALL "Skip installation" ${LIBRESSL_SKIP_INSTALL})
31+
option(ENABLE_ASM "Enable assembly" ON)
32+
option(ENABLE_EXTRATESTS "Enable extra tests that may be unreliable on some platforms" OFF)
33+
option(ENABLE_NC "Enable installing TLS-enabled nc(1)" OFF)
34+
option(ENABLE_VSTEST "Enable test on Visual Studio" OFF)
35+
set(OPENSSLDIR ${OPENSSLDIR} CACHE PATH "Set the default openssl directory" FORCE)
36+
37+
if(NOT LIBRESSL_SKIP_INSTALL)
38+
set( ENABLE_LIBRESSL_INSTALL ON )
39+
endif(NOT LIBRESSL_SKIP_INSTALL)
40+
41+
42+
set(BUILD_NC true)
43+
44+
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
45+
add_definitions(-fno-common)
46+
endif()
47+
48+
if(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
49+
add_definitions(-DHAVE_ATTRIBUTE__BOUNDED__)
50+
endif()
51+
52+
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
53+
add_definitions(-D_DEFAULT_SOURCE)
54+
add_definitions(-D_BSD_SOURCE)
55+
add_definitions(-D_POSIX_SOURCE)
56+
add_definitions(-D_GNU_SOURCE)
57+
endif()
58+
59+
if(CMAKE_SYSTEM_NAME MATCHES "MINGW")
60+
set(BUILD_NC false)
61+
endif()
62+
63+
if(WIN32)
64+
set(BUILD_NC false)
65+
endif()
66+
67+
if(CMAKE_SYSTEM_NAME MATCHES "HP-UX")
68+
if(CMAKE_C_COMPILER MATCHES "gcc")
69+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=gnu99 -fno-strict-aliasing")
70+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mlp64")
71+
else()
72+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O2 +DD64 +Otype_safety=off")
73+
endif()
74+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE=600 -D__STRICT_ALIGNMENT")
75+
endif()
76+
77+
if(CMAKE_SYSTEM_NAME MATCHES "SunOS")
78+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=gnu99 -fno-strict-aliasing")
79+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__EXTENSIONS__")
80+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE=600")
81+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBSD_COMP")
82+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fpic -m64")
83+
endif()
84+
85+
add_definitions(-DLIBRESSL_INTERNAL)
86+
add_definitions(-DOPENSSL_NO_HW_PADLOCK)
87+
add_definitions(-D__BEGIN_HIDDEN_DECLS=)
88+
add_definitions(-D__END_HIDDEN_DECLS=)
89+
90+
set(CMAKE_POSITION_INDEPENDENT_CODE true)
91+
92+
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
93+
add_definitions(-Wno-pointer-sign)
94+
endif()
95+
96+
if(WIN32)
97+
add_definitions(-Drestrict)
98+
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
99+
add_definitions(-D_CRT_DEPRECATED_NO_WARNINGS)
100+
add_definitions(-D_REENTRANT -D_POSIX_THREAD_SAFE_FUNCTIONS)
101+
add_definitions(-DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0501)
102+
add_definitions(-DCPPFLAGS -DOPENSSL_NO_SPEED -DNO_SYSLOG -DNO_CRYPT)
103+
endif()
104+
105+
if(MSVC)
106+
add_definitions(-Dinline=__inline)
107+
message(STATUS "Using [${CMAKE_C_COMPILER_ID}] compiler")
108+
if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
109+
set(MSVC_DISABLED_WARNINGS_LIST
110+
"C4057" # C4057: 'initializing' : 'unsigned char *' differs in
111+
# indirection to slightly different base types from 'char [2]'
112+
"C4018" # '>=': signed/unsigned mismatch
113+
"C4100" # 'exarg' : unreferenced formal parameter
114+
"C4127" # conditional expression is constant
115+
"C4146" # unary minus operator applied to unsigned
116+
# type, result still unsigned
117+
"C4242" # 'function' : conversion from 'int' to 'uint8_t',
118+
# possible loss of data
119+
"C4244" # 'function' : conversion from 'int' to 'uint8_t',
120+
# possible loss of data
121+
"C4245" # 'initializing': conversion from 'long' to
122+
# 'unsigned long', signed/unsigned mismatch
123+
"C4267" # conversion from 'size_t' to 'some type that is almost
124+
# certainly safe to convert a size_t to'.
125+
"C4389" # '!=': signed/unsigned mismatch
126+
"C4706" # assignment within conditional expression
127+
"C4820" # 'bytes' bytes padding added after construct 'member_name'
128+
"C4996" # 'read': The POSIX name for this item is deprecated. Instead,
129+
# use the ISO C++ conformant name: _read.
130+
)
131+
elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
132+
add_definitions(-D_CRT_SUPPRESS_RESTRICT)
133+
set(MSVC_DISABLED_WARNINGS_LIST
134+
"C111" # Unreachable statement
135+
"C128" # Unreachable loop
136+
"C167" # Unexplict casting unsigned to signed
137+
"C186" # Pointless comparison of unsigned int with zero
138+
"C188" # Enumerated type mixed with another type
139+
"C344" # Redeclared type
140+
"C556" # Unexplict casting signed to unsigned
141+
"C869" # Unreferenced parameters
142+
"C1786" # Deprecated functions
143+
"C2545" # Empty else statement
144+
"C2557" # Comparing signed to unsigned
145+
"C2722" # List init syntax is c++11 feature
146+
"C3280" # Declaration hides variable
147+
)
148+
endif()
149+
string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR
150+
${MSVC_DISABLED_WARNINGS_LIST})
151+
string(REGEX REPLACE "[/-]W[1234][ ]?" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
152+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -MP -W4 ${MSVC_DISABLED_WARNINGS_STR}")
153+
endif()
154+
155+
check_function_exists(asprintf HAVE_ASPRINTF)
156+
if(HAVE_ASPRINTF)
157+
add_definitions(-DHAVE_ASPRINTF)
158+
endif()
159+
160+
check_function_exists(inet_pton HAVE_INET_PTON)
161+
if(HAVE_INET_PTON)
162+
add_definitions(-DHAVE_INET_PTON)
163+
endif()
164+
165+
check_function_exists(reallocarray HAVE_REALLOCARRAY)
166+
if(HAVE_REALLOCARRAY)
167+
add_definitions(-DHAVE_REALLOCARRAY)
168+
endif()
169+
170+
check_function_exists(strcasecmp HAVE_STRCASECMP)
171+
if(HAVE_STRCASECMP)
172+
add_definitions(-DHAVE_STRCASECMP)
173+
endif()
174+
175+
check_function_exists(strlcat HAVE_STRLCAT)
176+
if(HAVE_STRLCAT)
177+
add_definitions(-DHAVE_STRLCAT)
178+
endif()
179+
180+
check_function_exists(strlcpy HAVE_STRLCPY)
181+
if(HAVE_STRLCPY)
182+
add_definitions(-DHAVE_STRLCPY)
183+
endif()
184+
185+
check_function_exists(strndup HAVE_STRNDUP)
186+
if(HAVE_STRNDUP)
187+
add_definitions(-DHAVE_STRNDUP)
188+
endif()
189+
190+
if(WIN32)
191+
set(HAVE_STRNLEN true)
192+
add_definitions(-DHAVE_STRNLEN)
193+
else()
194+
check_function_exists(strnlen HAVE_STRNLEN)
195+
if(HAVE_STRNLEN)
196+
add_definitions(-DHAVE_STRNLEN)
197+
endif()
198+
endif()
199+
200+
check_function_exists(strsep HAVE_STRSEP)
201+
if(HAVE_STRSEP)
202+
add_definitions(-DHAVE_STRSEP)
203+
endif()
204+
205+
check_function_exists(timegm HAVE_TIMEGM)
206+
if(HAVE_TIMEGM)
207+
add_definitions(-DHAVE_TIMEGM)
208+
endif()
209+
210+
check_function_exists(arc4random_buf HAVE_ARC4RANDOM_BUF)
211+
if(HAVE_ARC4RANDOM_BUF)
212+
add_definitions(-DHAVE_ARC4RANDOM_BUF)
213+
endif()
214+
215+
check_function_exists(arc4random_uniform HAVE_ARC4RANDOM_UNIFORM)
216+
if(HAVE_ARC4RANDOM_UNIFORM)
217+
add_definitions(-DHAVE_ARC4RANDOM_UNIFORM)
218+
endif()
219+
220+
check_function_exists(explicit_bzero HAVE_EXPLICIT_BZERO)
221+
if(HAVE_EXPLICIT_BZERO)
222+
add_definitions(-DHAVE_EXPLICIT_BZERO)
223+
endif()
224+
225+
check_function_exists(getauxval HAVE_GETAUXVAL)
226+
if(HAVE_GETAUXVAL)
227+
add_definitions(-DHAVE_GETAUXVAL)
228+
endif()
229+
230+
check_function_exists(getentropy HAVE_GETENTROPY)
231+
if(HAVE_GETENTROPY)
232+
add_definitions(-DHAVE_GETENTROPY)
233+
endif()
234+
235+
check_function_exists(getpagesize HAVE_GETPAGESIZE)
236+
if(HAVE_GETPAGESIZE)
237+
add_definitions(-DHAVE_GETPAGESIZE)
238+
endif()
239+
240+
check_function_exists(timingsafe_bcmp HAVE_TIMINGSAFE_BCMP)
241+
if(HAVE_TIMINGSAFE_BCMP)
242+
add_definitions(-DHAVE_TIMINGSAFE_BCMP)
243+
endif()
244+
245+
check_function_exists(timingsafe_memcmp HAVE_TIMINGSAFE_MEMCMP)
246+
if(HAVE_MEMCMP)
247+
add_definitions(-DHAVE_MEMCMP)
248+
endif()
249+
250+
check_function_exists(memmem HAVE_MEMMEM)
251+
if(HAVE_MEMMEM)
252+
add_definitions(-DHAVE_MEMMEM)
253+
endif()
254+
255+
check_include_files(err.h HAVE_ERR_H)
256+
if(HAVE_ERR_H)
257+
add_definitions(-DHAVE_ERR_H)
258+
endif()
259+
260+
if(ENABLE_ASM)
261+
if("${CMAKE_C_COMPILER_ABI}" STREQUAL "ELF")
262+
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(x86_64|amd64)")
263+
set(HOST_ASM_ELF_X86_64 true)
264+
elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i386")
265+
set(HOST_ASM_ELF_X86_64 true)
266+
endif()
267+
elseif(APPLE AND "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
268+
set(HOST_ASM_MACOSX_X86_64 true)
269+
endif()
270+
endif()
271+
272+
if(NOT (CMAKE_SYSTEM_NAME MATCHES "(Darwin|CYGWIN)"))
273+
set(BUILD_SHARED true)
274+
endif()
275+
276+
# USE_SHARED builds applications (e.g. openssl) using shared LibreSSL.
277+
# By default, applications use LibreSSL static library to avoid dependencies.
278+
# USE_SHARED isn't set by default; use -DUSE_SHARED=ON with CMake to enable.
279+
# Can be helpful for debugging; don't use for public releases.
280+
if(NOT BUILD_SHARED)
281+
set(USE_SHARED off)
282+
endif()
283+
284+
if(USE_SHARED)
285+
set(OPENSSL_LIBS tls-shared ssl-shared crypto-shared)
286+
else()
287+
set(OPENSSL_LIBS tls ssl crypto)
288+
endif()
289+
290+
if(CMAKE_HOST_WIN32)
291+
set(OPENSSL_LIBS ${OPENSSL_LIBS} ws2_32)
292+
endif()
293+
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
294+
check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME)
295+
if (HAVE_CLOCK_GETTIME)
296+
set(OPENSSL_LIBS ${OPENSSL_LIBS} rt)
297+
endif()
298+
endif()
299+
if(CMAKE_SYSTEM_NAME MATCHES "HP-UX")
300+
set(OPENSSL_LIBS ${OPENSSL_LIBS} pthread)
301+
endif()
302+
if(CMAKE_SYSTEM_NAME MATCHES "SunOS")
303+
set(OPENSSL_LIBS ${OPENSSL_LIBS} nsl socket)
304+
endif()
305+
306+
check_type_size(time_t SIZEOF_TIME_T)
307+
if(SIZEOF_TIME_T STREQUAL "4")
308+
set(SMALL_TIME_T true)
309+
add_definitions(-DSMALL_TIME_T)
310+
message(WARNING " ** Warning, this system is unable to represent times past 2038\n"
311+
" ** It will behave incorrectly when handling valid RFC5280 dates")
312+
endif()
313+
add_definitions(-DSIZEOF_TIME_T=${SIZEOF_TIME_T})
314+
315+
add_subdirectory(crypto)
316+
add_subdirectory(ssl)
317+
add_subdirectory(apps)
318+
add_subdirectory(tls)
319+
add_subdirectory(include)
320+
if(NOT MSVC)
321+
add_subdirectory(man)
322+
endif()
323+
if(NOT MSVC OR ENABLE_VSTEST)
324+
add_subdirectory(tests)
325+
endif()
326+
327+
if(NOT MSVC)
328+
# Create pkgconfig files.
329+
set(prefix ${CMAKE_INSTALL_PREFIX})
330+
set(exec_prefix \${prefix})
331+
set(libdir \${exec_prefix}/${CMAKE_INSTALL_LIBDIR})
332+
set(includedir \${prefix}/include)
333+
file(STRINGS "VERSION" VERSION LIMIT_COUNT 1)
334+
file(GLOB OPENSSL_PKGCONFIGS "*.pc.in")
335+
foreach(file ${OPENSSL_PKGCONFIGS})
336+
get_filename_component(filename ${file} NAME)
337+
string(REPLACE ".in" "" new_file "${filename}")
338+
configure_file(${filename} pkgconfig/${new_file} @ONLY)
339+
endforeach()
340+
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig
341+
DESTINATION ${CMAKE_INSTALL_LIBDIR})
342+
endif()
343+
344+
configure_file(
345+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
346+
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
347+
IMMEDIATE @ONLY)
348+
349+
add_custom_target(uninstall
350+
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)

0 commit comments

Comments
 (0)