Skip to content

Commit 4133fd2

Browse files
committed
add CMakeLists.txt
1 parent eba42ff commit 4133fd2

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

CMakeLists.txt

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
cmake_minimum_required(VERSION 2.6)
2+
3+
project(enet)
4+
5+
# The "configure" step.
6+
include(CheckFunctionExists)
7+
include(CheckStructHasMember)
8+
include(CheckTypeSize)
9+
check_function_exists("fcntl" HAS_FCNTL)
10+
check_function_exists("poll" HAS_POLL)
11+
check_function_exists("gethostbyname_r" HAS_GETHOSTBYNAME_R)
12+
check_function_exists("gethostbyaddr_r" HAS_GETHOSTBYADDR_R)
13+
check_function_exists("inet_pton" HAS_INET_PTON)
14+
check_function_exists("inet_ntop" HAS_INET_NTOP)
15+
check_struct_has_member("struct msghdr" "msg_flags" "sys/types.h;sys/socket.h" HAS_MSGHDR_FLAGS)
16+
set(CMAKE_EXTRA_INCLUDE_FILES "sys/types.h" "sys/socket.h")
17+
check_type_size("socklen_t" HAS_SOCKLEN_T BUILTIN_TYPES_ONLY)
18+
unset(CMAKE_EXTRA_INCLUDE_FILES)
19+
20+
if(HAS_FCNTL)
21+
add_definitions(-DHAS_FCNTL=1)
22+
endif()
23+
if(HAS_POLL)
24+
add_definitions(-DHAS_POLL=1)
25+
endif()
26+
if(HAS_GETHOSTBYNAME_R)
27+
add_definitions(-DHAS_GETHOSTBYNAME_R=1)
28+
endif()
29+
if(HAS_GETHOSTBYADDR_R)
30+
add_definitions(-DHAS_GETHOSTBYADDR_R=1)
31+
endif()
32+
if(HAS_INET_PTON)
33+
add_definitions(-DHAS_INET_PTON=1)
34+
endif()
35+
if(HAS_INET_NTOP)
36+
add_definitions(-DHAS_INET_NTOP=1)
37+
endif()
38+
if(HAS_MSGHDR_FLAGS)
39+
add_definitions(-DHAS_MSGHDR_FLAGS=1)
40+
endif()
41+
if(HAS_SOCKLEN_T)
42+
add_definitions(-DHAS_SOCKLEN_T=1)
43+
endif()
44+
45+
include_directories(${PROJECT_SOURCE_DIR}/include)
46+
47+
add_library(enet STATIC
48+
callbacks.c
49+
compress.c
50+
host.c
51+
list.c
52+
packet.c
53+
peer.c
54+
protocol.c
55+
unix.c
56+
win32.c
57+
)

0 commit comments

Comments
 (0)