forked from ambrop72/badvpn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
179 lines (148 loc) · 4.64 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
cmake_minimum_required(VERSION 2.6)
project(BADVPN C)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
include(TestBigEndian)
include(CheckIncludeFiles)
include(CheckSymbolExists)
include(CheckTypeSize)
find_package(OpenSSL REQUIRED)
set(LIBCRYPTO_INCLUDE_DIRS "${OpenSSL_INCLUDE_DIRS}")
set(LIBCRYPTO_LIBRARY_DIRS "${OpenSSL_LIBRARY_DIRS}")
set(LIBCRYPTO_LIBRARIES "${OpenSSL_LIBRARIES}")
find_package(NSPR REQUIRED)
find_package(NSS REQUIRED)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${LIBCRYPTO_INCLUDE_DIRS}
${NSPR_INCLUDE_DIRS}
${NSS_INCLUDE_DIRS}
lwip/custom
lwip/src/include
lwip/src/include/ipv4
)
link_directories(
${LIBCRYPTO_LIBRARY_DIRS}
${NSPR_LIBRARY_DIRS}
${NSS_LIBRARY_DIRS}
)
test_big_endian(BIG_ENDIAN)
check_type_size(int INT_SIZE)
if (NOT (INT_SIZE GREATER "3"))
message(FATAL_ERROR "int must be at least 32 bits")
endif ()
add_definitions(-std=gnu99 -Werror=implicit-function-declaration -Wno-unused-value -Wno-parentheses -Wno-switch-enum -Wredundant-decls)
# platform-specific stuff
if (WIN32)
add_definitions(-DBADVPN_USE_WINAPI -D_WIN32_WINNT=0x600 -DWIN32_LEAN_AND_MEAN)
set(CMAKE_REQUIRED_DEFINITIONS "-D_WIN32_WINNT=0x600")
check_symbol_exists(WSAID_WSARECVMSG "mswsock.h" HAVE_WSARECVMSG)
check_symbol_exists(WSAID_WSASENDMSG "mswsock.h" HAVE_WSASENDMSG)
set(CMAKE_REQUIRED_DEFINITIONS "")
if (NOT (HAVE_WSARECVMSG AND HAVE_WSASENDMSG))
add_definitions(-DBADVPN_USE_CUSTOM_MSWSOCK_H)
endif ()
else ()
set(BADVPN_THREADWORK_USE_PTHREAD 1)
add_definitions(-DBADVPN_THREADWORK_USE_PTHREAD)
link_libraries(rt)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
add_definitions(-DBADVPN_LINUX)
check_include_files(sys/signalfd.h HAVE_SYS_SIGNALFD_H)
if (HAVE_SYS_SIGNALFD_H)
add_definitions(-DBADVPN_USE_SIGNALFD)
else ()
add_definitions(-DBADVPN_USE_SELFPIPE)
endif ()
check_include_files(sys/epoll.h HAVE_SYS_EPOLL_H)
if (HAVE_SYS_EPOLL_H)
add_definitions(-DBADVPN_USE_EPOLL)
else ()
add_definitions(-DBADVPN_USE_POLL)
endif ()
check_include_files(linux/rfkill.h HAVE_LINUX_RFKILL_H)
if (HAVE_LINUX_RFKILL_H)
add_definitions(-DBADVPN_USE_LINUX_RFKILL)
set(BADVPN_USE_LINUX_RFKILL 1)
endif ()
check_include_files(linux/input.h HAVE_LINUX_INPUT_H)
if (HAVE_LINUX_INPUT_H)
add_definitions(-DBADVPN_USE_LINUX_INPUT)
set(BADVPN_USE_LINUX_INPUT 1)
endif ()
check_include_files(sys/inotify.h HAVE_SYS_INOTIFY_H)
if (HAVE_SYS_INOTIFY_H)
add_definitions(-DBADVPN_USE_INOTIFY)
set(BADVPN_USE_INOTIFY 1)
endif ()
elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
add_definitions(-DBADVPN_FREEBSD)
check_symbol_exists(kqueue "sys/types.h;sys/event.h;sys/time.h" HAVE_KQUEUE)
if (NOT HAVE_KQUEUE)
message(FATAL_ERROR "kqueue is required")
endif ()
add_definitions(-DBADVPN_USE_KEVENT)
endif ()
if (NOT DEFINED BADVPN_WITHOUT_CRYPTODEV)
check_include_files(crypto/cryptodev.h HAVE_CRYPTO_CRYPTODEV_H)
if (HAVE_CRYPTO_CRYPTODEV_H)
add_definitions(-DBADVPN_USE_CRYPTODEV)
elseif (DEFINED BADVPN_WITH_CRYPTODEV)
message(FATAL_ERROR "crypto/cryptodev.h not found")
endif ()
endif ()
endif ()
# add preprocessor definitions
if (BIG_ENDIAN)
add_definitions(-DBADVPN_BIG_ENDIAN)
else ()
add_definitions(-DBADVPN_LITTLE_ENDIAN)
endif ()
# install man pages
install(
FILES badvpn.7
DESTINATION share/man/man7
)
install(
FILES badvpn-server.8 badvpn-client.8
DESTINATION share/man/man8
)
# internal libraries
add_subdirectory(base)
add_subdirectory(system)
add_subdirectory(flow)
add_subdirectory(flowextra)
add_subdirectory(tuntap)
add_subdirectory(predicate)
add_subdirectory(nspr_support)
add_subdirectory(server_connection)
add_subdirectory(security)
add_subdirectory(socksclient)
add_subdirectory(lwip)
add_subdirectory(dhcpclient)
add_subdirectory(ncdconfig)
add_subdirectory(threadwork)
add_subdirectory(stringmap)
add_subdirectory(udpgw_client)
if (NOT WIN32)
add_subdirectory(process)
add_subdirectory(inputprocess)
add_subdirectory(udevmonitor)
endif ()
# example programs
add_subdirectory(examples)
# tests
add_subdirectory(tests)
# server
add_subdirectory(server)
# client
add_subdirectory(client)
# flooder
add_subdirectory(flooder)
# tun2socks
add_subdirectory(tun2socks)
# udpgw
add_subdirectory(udpgw)
# ncd
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
add_subdirectory(ncd)
endif ()