1 cmake_minimum_required(VERSION 2.6)
5 # The "configure" step.
6 include(CheckFunctionExists)
7 include(CheckStructHasMember)
9 check_function_exists("fcntl" HAS_FCNTL)
10 check_function_exists("poll" HAS_POLL)
11 check_function_exists("getaddrinfo" HAS_GETADDRINFO)
12 check_function_exists("getnameinfo" HAS_GETNAMEINFO)
13 check_function_exists("gethostbyname_r" HAS_GETHOSTBYNAME_R)
14 check_function_exists("gethostbyaddr_r" HAS_GETHOSTBYADDR_R)
15 check_function_exists("inet_pton" HAS_INET_PTON)
16 check_function_exists("inet_ntop" HAS_INET_NTOP)
17 check_struct_has_member("struct msghdr" "msg_flags" "sys/types.h;sys/socket.h" HAS_MSGHDR_FLAGS)
18 set(CMAKE_EXTRA_INCLUDE_FILES "sys/types.h" "sys/socket.h")
19 check_type_size("socklen_t" HAS_SOCKLEN_T BUILTIN_TYPES_ONLY)
20 unset(CMAKE_EXTRA_INCLUDE_FILES)
24 add_definitions(-Wno-error)
28 add_definitions(-DHAS_FCNTL=1)
31 add_definitions(-DHAS_POLL=1)
34 add_definitions(-DHAS_GETNAMEINFO=1)
37 add_definitions(-DHAS_GETADDRINFO=1)
39 if(HAS_GETHOSTBYNAME_R)
40 add_definitions(-DHAS_GETHOSTBYNAME_R=1)
42 if(HAS_GETHOSTBYADDR_R)
43 add_definitions(-DHAS_GETHOSTBYADDR_R=1)
46 add_definitions(-DHAS_INET_PTON=1)
49 add_definitions(-DHAS_INET_NTOP=1)
52 add_definitions(-DHAS_MSGHDR_FLAGS=1)
55 add_definitions(-DHAS_SOCKLEN_T=1)
58 include_directories(${PROJECT_SOURCE_DIR}/include)
60 add_library(enet STATIC
73 target_link_libraries(enet winmm ws2_32)
76 install(TARGETS enet ARCHIVE DESTINATION lib
77 LIBRARY DESTINATION lib
78 RUNTIME DESTINATION bin)
80 install(DIRECTORY include/