forked from Socks5Balancer/Socks5BalancerAsio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
161 lines (136 loc) · 5.06 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
cmake_minimum_required(VERSION 3.16)
set(ProjectMainName Socks5BalancerAsio)
project(${ProjectMainName})
set(CMAKE_CXX_STANDARD 17)
if (MSVC)
# recommend config
# cmake.exe -G "Visual Studio 16 2019" -DBOOST_INCLUDEDIR=H:/CodeLib/boost_1_73_0 -DOPENSSL_ROOT_DIR=h:\CodeLib\openssl-1.1.1h\x64 -DUSE_DYNAMIC_BOOST=0
# https://stackoverflow.com/questions/52206636/force-cmake-to-look-for-x64-bit-libraries-instead-of-x32
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-DBOOST_ALL_NO_LIB)
add_definitions(-DMSVC)
if (COMMAND _WIN32_WINNT)
else ()
# if _WIN32_WINNT not set. set the _WIN32_WINNT to 0x0A00 (Windows 10)
# you can add " /D_WIN32_WINNT=0x0601" in CMAKE_CXX_FLAGS to set it to 0x0601 (win7)
add_definitions(-D_WIN32_WINNT=0x0A00)
endif ()
add_compile_options(/bigobj)
add_definitions(/W4)
else ()
add_definitions(-Wall -Wextra)
endif ()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
option(MINI_BUILD_MODE "Config Enable MINI BUILD Mode")
if (MINI_BUILD_MODE)
set(NOT_USE_BOOST_THEAD 1)
set(NOT_USE_EmbedWebServer 1)
set(FORCE_disableConnectTest 1)
set(FORCE_disableConnectionTracker 1)
set(FORCE_traditionTcpRelay 1)
message(STATUS "Use MINI_BUILD_MODE !!!")
else ()
option(NOT_USE_BOOST_THEAD "Config NOT_USE_BOOST_THEAD")
option(NOT_USE_EmbedWebServer "Config NOT_USE_EmbedWebServer")
option(FORCE_disableConnectTest "Config FORCE_disableConnectTest")
option(FORCE_disableConnectionTracker "Config FORCE_disableConnectionTracker")
option(FORCE_traditionTcpRelay "Config FORCE_traditionTcpRelay")
endif ()
if (NOT_USE_EmbedWebServer)
add_definitions(-DDISABLE_EmbedWebServer)
message(STATUS "NOT_USE_EmbedWebServer !!!")
endif ()
if (FORCE_disableConnectTest)
add_definitions(-DFORCE_disableConnectTest)
message(STATUS "FORCE_disableConnectTest !!!")
endif ()
if (FORCE_disableConnectionTracker)
add_definitions(-DFORCE_disableConnectionTracker)
message(STATUS "FORCE_disableConnectionTracker !!!")
endif ()
if (FORCE_traditionTcpRelay)
add_definitions(-DFORCE_traditionTcpRelay)
message(STATUS "FORCE_traditionTcpRelay !!!")
endif ()
if (NOT_USE_BOOST_THEAD)
set(BOOST_THEAD_MODULE "")
message(STATUS "NOT_USE_BOOST_THEAD !!!")
else ()
set(BOOST_THEAD_MODULE "thread")
add_definitions(-DUSE_BOOST_THEAD)
endif ()
option(USE_DYNAMIC_BOOST "Config USE_DYNAMIC_BOOST")
if (USE_DYNAMIC_BOOST)
message(STATUS "USE DYNAMIC BOOST !!!")
add_definitions(-DBOOST_ALL_DYN_LINK=1)
else ()
message(STATUS "USE STATIC BOOST !!!")
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_RUNTIME OFF)
endif ()
set(Boost_USE_MULTITHREADED ON)
find_package(Boost 1.70.0 REQUIRED COMPONENTS system filesystem program_options ${BOOST_THEAD_MODULE} REQUIRED)
message(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
message(STATUS "Boost_LIBRARY_DIRS: ${Boost_LIBRARY_DIRS}")
message(STATUS "Boost_LIBRARIES: ${Boost_LIBRARIES}")
message(STATUS "Boost_VERSION: ${Boost_VERSION}")
if (MSVC)
else ()
# if (${Boost_VERSION} VERSION_LESS_EQUAL 1.72.0)
# # https://github.com/boostorg/asio/issues/312
# # https://github.com/microsoft/vcpkg/issues/9731
# # https://github.com/boostorg/beast/issues/1884
# add_definitions(-DBOOST_ASIO_DISABLE_CONCEPTS)
# message(STATUS "Boost_VERSION <= 1.72")
# endif ()
endif ()
find_package(OpenSSL 1.1.0 REQUIRED)
add_executable(${ProjectMainName}
src/main.cpp
src/TcpRelayServer.cpp
src/TcpRelayServer.h
src/UpstreamPool.cpp
src/UpstreamPool.h
src/StateMonitorServer.cpp
src/StateMonitorServer.h
src/ConnectTestHttps.cpp
src/ConnectTestHttps.h
src/ConfigLoader.cpp
src/ConfigLoader.h
src/TcpTest.cpp
src/TcpTest.h
src/FirstPackAnalyzer.cpp
src/FirstPackAnalyzer.h
src/TcpRelayStatisticsInfo.cpp
src/TcpRelayStatisticsInfo.h
src/ConnectionTracker.cpp
src/ConnectionTracker.h
src/ConnectType.h
src/EmbedWebServer.cpp
src/EmbedWebServer.h
src/ConfigRuleEnum.h
src/AsyncDelay.cpp
src/AsyncDelay.h
src/UtilTools.cpp
src/UtilTools.h)
target_link_libraries(${ProjectMainName} ${CMAKE_THREAD_LIBS_INIT})
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(${ProjectMainName} ${Boost_LIBRARIES})
link_directories(${Boost_LIBRARY_DIRS})
include_directories(${OPENSSL_INCLUDE_DIR})
target_link_libraries(${ProjectMainName} ${OPENSSL_LIBRARIES})
if (OPENSSL_VERSION VERSION_GREATER_EQUAL 1.1.1)
option(ENABLE_SSL_KEYLOG "Build with SSL KeyLog support" ON)
if (ENABLE_SSL_KEYLOG)
add_definitions(-DENABLE_SSL_KEYLOG)
endif ()
option(ENABLE_TLS13_CIPHERSUITES "Build with TLS1.3 ciphersuites support" ON)
if (ENABLE_TLS13_CIPHERSUITES)
add_definitions(-DENABLE_TLS13_CIPHERSUITES)
endif ()
endif ()
if (WIN32)
target_link_libraries(${ProjectMainName} wsock32 ws2_32 crypt32)
else ()
endif ()