-
Notifications
You must be signed in to change notification settings - Fork 20
/
CMakeLists.txt
129 lines (121 loc) · 5.99 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
cmake_minimum_required(VERSION 3.0.0)
if (POLICY CMP0015)
cmake_policy(SET CMP0015 NEW)
endif(POLICY CMP0015)
OPTION(ENABLE_GCOV "Enable gcov (debug, Linux builds only)" OFF)
IF (ENABLE_GCOV AND NOT WIN32 AND NOT APPLE)
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} --coverage -fprofile-arcs -ftest-coverage")
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} --coverage -fprofile-arcs -ftest-coverage -lgcov")
ENDIF()
macro(use_c99)
if (CMAKE_VERSION VERSION_LESS "3.1")
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set (CMAKE_C_FLAGS "--std=c99 -D_XOPEN_SOURCE=600 ${CMAKE_C_FLAGS}")
endif ()
else ()
set (CMAKE_C_STANDARD 99)
endif ()
endmacro(use_c99)
macro(use_c11)
if (CMAKE_VERSION VERSION_LESS "3.1")
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set (CMAKE_C_FLAGS "--std=c11 ${CMAKE_C_FLAGS}")
endif ()
else ()
set (CMAKE_C_STANDARD 11)
endif ()
endmacro(use_c11)
# Workspace name
project(mysocks)
find_package(OpenSSL QUIET)
IF (OPENSSL_FOUND)
IF (OPENSSL_VERSION VERSION_LESS 1.1)
include_directories(gnulib/lib libmd5-rfc libuv-1.18.0/include OpenSSL_1_1_0/include wolfssl-3.11.0-stable)
ELSE()
include_directories(gnulib/lib libmd5-rfc libuv-1.18.0/include ${OPENSSL_INCLUDE_DIR} wolfssl-3.11.0-stable)
ENDIF()
include_directories(gnulib/lib libmd5-rfc libuv-1.18.0/include OpenSSL_1_1_0/in
clude wolfssl-3.11.0-stable)
ENDIF()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# Projects
SET(CMAKE_C_FLAGS_RELEASE "$ENV{CFLAGS} -DNDEBUG")
IF (MSVC)
set (CMAKE_C_FLAGS "-D_WIN32_WINNT=0x0600 -D_GNU_SOURCE -DHAVE_UNISTD_H=0 -DWIN32_LEAN_AND_MEAN ${CMAKE_C_FLAGS}")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:LIBCMT /NODEFAULTLIB:LIBCMTD")
link_directories( libuv-1.18.0/$(ConfigurationName)/lib OpenSSL_1_1_0 wolfssl-3.11.0-stable/Debug)
add_executable(ssclient gnulib/lib/arcfour.c libmd5-rfc/md5.c src/client.c src/cipher.c src/getopt.c src/main.c src/s5.c src/server.c src/util.c)
target_link_libraries(ssclient iphlpapi psapi userenv libuv ws2_32)
add_executable(ssclient-openssl src/client.c src/cipher-openssl.c src/getopt.c src/main.c src/s5.c src/server.c src/util.c)
target_link_libraries(ssclient-openssl libcrypto iphlpapi psapi userenv libuv ws2_32)
set_target_properties ( ssclient-openssl PROPERTIES COMPILE_FLAGS "-DWITH_OPENSSL" )
add_executable(ssclient-wolfssl src/client.c src/cipher-wolfssl.c src/getopt.c src/main.c src/s5.c src/server.c src/util.c)
target_link_libraries(ssclient-wolfssl iphlpapi psapi userenv libuv wolfssl ws2_32)
set_target_properties ( ssclient-wolfssl PROPERTIES COMPILE_FLAGS "-DWITH_WOLFSSL" )
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "MINGW")
set (CMAKE_C_FLAGS "-D_WIN32 -D_WIN32_WINNT=0x0600 -D_GNU_SOURCE -DHAVE_UNISTD_H=0 ${CMAKE_C_FLAGS}")
IF(CMAKE_SYSTEM_NAME MATCHES "MINGW32")
set (CMAKE_C_FLAGS "-I/mingw32/include ${CMAKE_C_FLAGS}")
ELSE()
set (CMAKE_C_FLAGS "-I/mingw64/include ${CMAKE_C_FLAGS}")
ENDIF()
add_executable(ssclient gnulib/lib/arcfour.c libmd5-rfc/md5.c src/client.c src/cipher.c src/getopt.c src/main.c src/s5.c src/server.c src/util.c)
target_link_libraries(ssclient uv ws2_32)
add_executable(ssclient-openssl src/client.c src/cipher-openssl.c src/getopt.c src/main.c src/s5.c src/server.c src/util.c)
target_link_libraries(ssclient-openssl uv crypto ssl ws2_32)
set_target_properties ( ssclient-openssl PROPERTIES COMPILE_FLAGS "-DWITH_OPENSSL" )
add_executable(ssclient-wolfssl src/client.c src/cipher-wolfssl.c src/getopt.c src/main.c src/s5.c src/server.c src/util.c)
target_link_libraries(ssclient-wolfssl uv wolfssl ws2_32)
set_target_properties ( ssclient-wolfssl PROPERTIES COMPILE_FLAGS "-DWITH_WOLFSSL" )
ELSE()
SET(CMAKE_C_FLAGS "-DHAVE_UNISTD_H=1 ${CMAKE_C_FLAGS}")
SET(CMAKE_C_FLAGS_DEBUG "-DHAVE_UNISTD_H=1 ${CMAKE_C_FLAGS_DEBUG}")
SET(CMAKE_C_FLAGS_RELEASE "-DHAVE_UNISTD_H=1 ${CMAKE_C_FLAGS_RELEASE}")
link_directories(libuv-1.18.0/.libs OpenSSL_1_1_0 wolfssl-3.11.0-stable/src/.libs)
add_executable(ssclient gnulib/lib/arcfour.c libmd5-rfc/md5.c src/client.c src/cipher.c src/main.c src/s5.c src/server.c src/util.c)
target_link_libraries(ssclient uv )
add_executable(ssclient-openssl src/client.c src/cipher-openssl.c src/main.c src/s5.c src/server.c src/util.c)
IF (OPENSSL_FOUND)
IF (OPENSSL_VERSION VERSION_LESS 1.1)
target_link_libraries(ssclient-openssl uv crypto ssl)
ELSE()
target_link_libraries(ssclient-openssl uv ${OPENSSL_LIBRARIES})
ENDIF()
ELSE()
target_link_libraries(ssclient-openssl uv crypto ssl)
ENDIF()
set_target_properties ( ssclient-openssl PROPERTIES COMPILE_FLAGS "-DWITH_OPENSSL" )
add_executable(ssclient-wolfssl src/client.c src/cipher-wolfssl.c src/main.c src/s5.c src/server.c src/util.c)
target_link_libraries(ssclient-wolfssl wolfssl uv)
set_target_properties ( ssclient-wolfssl PROPERTIES COMPILE_FLAGS "-DWITH_WOLFSSL" )
ENDIF()
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
SET(CMAKE_C_FLAGS_DEBUG "$ENV{CFLAGS} ${CMAKE_C_FLAGS_DEBUG} -O0 -Wall -g -ggdb")
# require at least gcc 4.9
if (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9)
use_c99()
set_property(TARGET ssclient PROPERTY C_STANDARD 99)
set_property(TARGET ssclient-openssl PROPERTY C_STANDARD 99)
else()
use_c11()
set_property(TARGET ssclient PROPERTY C_STANDARD 11)
set_property(TARGET ssclient-openssl PROPERTY C_STANDARD 11)
endif()
elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
# require at least clang 3.1
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1)
use_c99()
set_property(TARGET ssclient PROPERTY C_STANDARD 99)
set_property(TARGET ssclient-openssl PROPERTY C_STANDARD 99)
else()
use_c11()
set_property(TARGET ssclient PROPERTY C_STANDARD 11)
set_property(TARGET ssclient-openssl PROPERTY C_STANDARD 11)
endif()
endif()
enable_testing()
install(TARGETS ssclient RUNTIME DESTINATION bin)
install(TARGETS ssclient-openssl RUNTIME DESTINATION bin)
install(TARGETS ssclient-wolfssl RUNTIME DESTINATION bin)