-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
37 lines (31 loc) · 1.15 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
cmake_minimum_required(VERSION 3.14.0)
project(microsocks11 CXX)
find_package(cxxopts CONFIG REQUIRED)
set(PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
)
set(LIBRARY socks5)
add_library(${LIBRARY} STATIC)
set_target_properties(${LIBRARY} PROPERTIES ${PROPERTIES})
target_sources(${LIBRARY} PRIVATE server.cpp socks5.cpp)
set(SERVER microsocks)
add_executable(${SERVER})
set_target_properties(${SERVER} PROPERTIES ${PROPERTIES})
target_link_libraries(${SERVER} PRIVATE ${LIBRARY} cxxopts::cxxopts)
target_sources(${SERVER} PRIVATE main.cpp)
add_subdirectory(include)
if (NOT MSVC)
target_link_libraries(${LIBRARY} pthread)
endif()
if(BUILD_STATIC)
if (MSVC)
string(REGEX REPLACE "/M[TD]d?" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
string(REGEX REPLACE "/M[TD]d?" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
target_link_options(${SERVER} PRIVATE /INCREMENTAL:NO /NODEFAULTLIB:MSVCRT)
else ()
target_link_options(${SERVER} PRIVATE -static)
endif()
endif()