-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
65 lines (50 loc) · 1.48 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
cmake_minimum_required(VERSION 2.8.11)
# A C project
project(C)
set(CMAKE_VERBOSE_MAKEFILE ON)
if(ANDROID)
ADD_LIBRARY(zdtun SHARED zdtun.c utils.c)
TARGET_LINK_LIBRARIES(zdtun)
add_definitions(-DANDROID)
find_library(log-lib log)
TARGET_LINK_LIBRARIES(zdtun ${log-lib})
else()
ADD_LIBRARY(zdtun STATIC zdtun.c utils.c)
ADD_LIBRARY(zdtun_dbg STATIC zdtun.c utils.c)
add_executable(zdtun_pivot zdtun_pivot.c)
add_executable(zdtun_client zdtun_client.c utils.c)
if(NOT WIN32)
add_executable(zdtun_gateway zdtun_gateway.c)
TARGET_LINK_LIBRARIES(zdtun_gateway zdtun_dbg)
endif()
TARGET_LINK_LIBRARIES(zdtun_pivot zdtun_dbg)
set_target_properties(zdtun PROPERTIES COMPILE_FLAGS -DNO_DEBUG)
endif()
if(WIN32)
target_link_libraries(zdtun_pivot ws2_32)
add_definitions(-DWIN32)
# assume LITTLE_ENDIAN on Windows
else()
set(CMAKE_C_FLAGS "-Wall -Wno-unused-variable -Wno-unused-function -g")
include (TestBigEndian)
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
endif()
if(IS_BIG_ENDIAN)
message(STATUS "BIG_ENDIAN")
add_definitions(-D_BIG_ENDIAN)
else()
message(STATUS "LITTLE_ENDIAN")
add_definitions(-D_LITTLE_ENDIAN)
endif()
# Force static linking on Windows
set(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()