aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CMakeLists.txt130
1 files changed, 130 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..e642bcc
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,130 @@
1cmake_minimum_required (VERSION 3.2)
2include(CheckFunctionExists)
3
4project (LibreSSL)
5
6if(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
7 add_definitions(-DHAVE_ATTRIBUTE__BOUNDED__)
8endif()
9
10add_definitions(-DLIBRESSL_INTERNAL)
11add_definitions(-DOPENSSL_NO_HW_PADLOCK)
12add_definitions(-DOPENSSL_NO_ASM)
13
14if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
15 add_definitions(-Wno-pointer-sign)
16endif()
17
18if(MSVC)
19 add_definitions(-Dinline=__inline)
20 add_definitions(-Drestrict)
21 add_definitions(-D_CRT_SECURE_NO_WARNINGS)
22 add_definitions(-D_CRT_DEPRECATED_NO_WARNINGS)
23 add_definitions(-D_REENTRANT -D_POSIX_THREAD_SAFE_FUNCTIONS)
24 add_definitions(-DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0501)
25 add_definitions(-DCPPFLAGS -DOPENSSL_NO_SPEED -DNO_SYSLOG -DNO_CRYPT)
26
27 set(MSVC_DISABLED_WARNINGS_LIST
28 "C4057" # C4057: 'initializing' : 'unsigned char *' differs in
29 # indirection to slightly different base types from 'char [2]'
30 "C4100" # 'exarg' : unreferenced formal parameter
31 "C4127" # conditional expression is constant
32 "C4242" # 'function' : conversion from 'int' to 'uint8_t',
33 # possible loss of data
34 "C4244" # 'function' : conversion from 'int' to 'uint8_t',
35 # possible loss of data
36 "C4706" # assignment within conditional expression
37 "C4820" # 'bytes' bytes padding added after construct 'member_name'
38 "C4996" # 'read': The POSIX name for this item is deprecated. Instead,
39 # use the ISO C++ conformant name: _read.
40 )
41 string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR
42 ${MSVC_DISABLED_WARNINGS_LIST})
43 set(CMAKE_C_FLAGS "-MP -W4 ${MSVC_DISABLED_WARNINGS_STR}")
44endif()
45
46check_function_exists(asprintf HAVE_ASPRINTF)
47if(HAVE_ASPRINTF)
48 add_definitions(-DHAVE_ASPRINTF)
49endif()
50
51check_function_exists(inet_pton HAVE_INET_PTON)
52if(HAVE_INET_PTON)
53 add_definitions(-DHAVE_INET_PTON)
54endif()
55
56check_function_exists(reallocarray HAVE_REALLOCARRAY)
57if(HAVE_REALLOCARRAY)
58 add_definitions(-DHAVE_REALLOCARRAY)
59endif()
60
61check_function_exists(strcasecmp HAVE_STRCASECMP)
62if(HAVE_STRCASECMP)
63 add_definitions(-DHAVE_STRCASECMP)
64endif()
65
66check_function_exists(strlcat HAVE_STRLCAT)
67if(HAVE_STRLCAT)
68 add_definitions(-DHAVE_STRLCAT)
69endif()
70
71check_function_exists(strlcat HAVE_STRLCPY)
72if(HAVE_STRLCPY)
73 add_definitions(-DHAVE_STRLCPY)
74endif()
75
76check_function_exists(strndup HAVE_STRNDUP)
77if(HAVE_STRNDUP)
78 add_definitions(-DHAVE_STRNDUP)
79endif()
80
81if(MSVC)
82 set(HAVE_STRNLEN)
83 add_definitions(-DHAVE_STRNLEN)
84else()
85 check_function_exists(strnlen HAVE_STRNLEN)
86 if(HAVE_STRNLEN)
87 add_definitions(-DHAVE_STRNLEN)
88 endif()
89endif()
90
91check_function_exists(strsep HAVE_STRSEP)
92if(HAVE_STRSEP)
93 add_definitions(-DHAVE_STRSEP)
94endif()
95
96check_function_exists(arc4random_buf HAVE_ARC4RANDOM_BUF)
97if(HAVE_ARC4RANDOM_BUF)
98 add_definitions(-DHAVE_ARC4RANDOM_BUF)
99endif()
100
101check_function_exists(explicit_bzero HAVE_EXPLICIT_BZERO)
102if(HAVE_EXPLICIT_BZERO)
103 add_definitions(-DHAVE_EXPLICIT_BZERO)
104endif()
105
106check_function_exists(getauxval HAVE_GETAUXVAL)
107if(HAVE_GETAUXVAL)
108 add_definitions(-DHAVE_GETAUXVAL)
109endif()
110
111check_function_exists(getentropy HAVE_GETENTROPY)
112if(HAVE_GETENTROPY)
113 add_definitions(-DHAVE_GETENTROPY)
114endif()
115
116check_function_exists(timingsafe_bcmp HAVE_TIMINGSAFE_BCMP)
117if(HAVE_TIMINGSAFE_BCMP)
118 add_definitions(-DHAVE_TIMINGSAFE_BCMP)
119endif()
120
121check_function_exists(timingsafe_memcmp HAVE_TIMINGSAFE_MEMCMP)
122if(HAVE_MEMCMP)
123 add_definitions(-DHAVE_MEMCMP)
124endif()
125
126add_subdirectory(crypto)
127add_subdirectory(ssl)
128add_subdirectory(apps)
129add_subdirectory(tls)
130add_subdirectory(tests)