forked from lsalzman/enet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
80 lines (60 loc) · 1.96 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
cmake_minimum_required(VERSION 2.6)
project(enet C)
option(USE_CRC32 "Whether to use CRC32 packet verification")
if(USE_CRC32)
add_definitions(-DUSE_CRC32)
endif(USE_CRC32)
include(CheckFunctionExists)
include(CheckTypeSize)
check_function_exists(gethostbyaddr_r GETHOSTBYADDR_R_FUNCTION_FOUND)
check_function_exists(gethostbyname_r GETHOSTBYNAME_R_FUNCTION_FOUND)
check_function_exists(poll POLL_FUNCTION_FOUND)
check_function_exists(fcntl FCNTL_FUNCTION_FOUND)
check_function_exists(inet_pton INET_PTON_FUNCTION_FOUND)
check_function_exists(inet_ntop INET_NTOP_FUNCTION_FOUND)
if(GETHOSTBYADDR_R_FUNCTION_FOUND)
add_definitions(-DHAS_GETHOSTBYADDR_R)
endif(GETHOSTBYADDR_R_FUNCTION_FOUND)
if(GETHOSTBYNAME_R_FUNCTION_FOUND)
add_definitions(-DHAS_GETHOSTBYNAME_R)
endif(GETHOSTBYNAME_R_FUNCTION_FOUND)
if(POLL_FUNCTION_FOUND)
add_definitions(-DHAS_POLL)
endif(POLL_FUNCTION_FOUND)
if(FCNTL_FUNCTION_FOUND)
add_definitions(-DHAS_FCNTL)
endif(FCNTL_FUNCTION_FOUND)
if(INET_PTON_FUNCTION_FOUND)
add_definitions(-DHAS_INET_PTON)
endif(INET_PTON_FUNCTION_FOUND)
if(INET_NTOP_FUNCTION_FOUND)
add_definitions(-DHAS_INET_NTOP)
endif(INET_NTOP_FUNCTION_FOUND)
set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h sys/socket.h)
check_type_size(socklen_t HAS_SOCKLEN_T)
set(CMAKE_EXTRA_INCLUDE_FILES)
if(HAS_SOCKLEN_T)
add_definitions(-DHAS_SOCKLEN_T)
endif(HAS_SOCKLEN_T)
set(ENET_LIBRARY
enet
CACHE INTERNAL "enet library")
set(ENET_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/include
CACHE INTERNAL "enet include directories")
set(ENET_SOURCES
host.c
list.c
callbacks.c
compress.c
packet.c
peer.c
protocol.c
unix.c
win32.c)
include_directories(${ENET_INCLUDE_DIRS})
add_library(${ENET_LIBRARY} STATIC ${ENET_SOURCES})
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
target_link_libraries(${ENET_LIBRARY} ws2_32 winmm)
endif()
set(ENET_LIBRARIES ${ENET_LIBRARY} CACHE INTERNAL "Enet libraries")