summaryrefslogtreecommitdiff
path: root/libs/enet/CMakeLists.txt
blob: d7acbcc17d86cc65872904763e0dc2821d89d452 (plain) (blame)
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
INCLUDE(FindPkgConfig)

OPTION(WITH_BUNDLEDHEADERS "Use bundled enet headers" ON)

INCLUDE(CheckFunctionExists)
CHECK_FUNCTION_EXISTS(gethostbyaddr_r HAS_GETHOSTBYNAME_R)
IF(HAS_GETHOSTBYNAME_R EQUAL 1)
  SET (FLAGS "${FLAGS} -DHAS_GETHOSTBYADDR_R")
ENDIF()

CHECK_FUNCTION_EXISTS(poll HAS_POLL)
IF(HAS_POLL EQUAL 1)
  SET (FLAGS "${FLAGS} -DHAS_POLL")
ENDIF()

CHECK_FUNCTION_EXISTS(fcntl HAS_FCNTL)
IF(HAS_FCNTL)
  SET (FLAGS "${FLAGS} -DHAS_FCNTL")
ENDIF()

CHECK_FUNCTION_EXISTS(inet_pton HAS_INETPTON)
IF(HAS_INETPTON EQUAL 1)
  SET (FLAGS "${FLAGS} -DHAS_INETPTON")
ENDIF()

CHECK_FUNCTION_EXISTS(inet_ntop HAS_INETNTOP)
IF(HAS_INETNTOP EQUAL 1)
  SET (FLAGS "${FLAGS} -DHAS_INETNTOP")
ENDIF()

INCLUDE(CheckTypeSize)
SET (CMAKE_EXTRA_INCLUDE_FILES sys/socket.h)
CHECK_TYPE_SIZE(socklen_t SOCKLEN_T)
IF(HAVE_SOCKLEN_T)
  SET (FLAGS "${FLAGS} -DHAS_SOCKLEN_T")
ENDIF()

INCLUDE(CheckStructHasMember)
CHECK_STRUCT_HAS_MEMBER("struct msghdr" msg_flags sys/socket.h HAS_MSGHDR_FLAGS)
IF(HAS_MSGHDR_FLAGS EQUAL 1)
  SET (FLAGS "${FLAGS} -DHAS_MSGHDR_FLAGS")
ENDIF()

SET (SRCS
  callbacks.c
  compress.c
  host.c
  list.c
  packet.c
  peer.c
  protocol.c
  unix.c
  win32.c
  )

IF (WITH_BUNDLEDHEADERS)
	INCLUDE_DIRECTORIES("include")
ELSE (WITH_BUNDLEDHEADERS)
	PKG_CHECK_MODULES(ENET REQUIRED libenet)
	INCLUDE_DIRECTORIES("${ENET_INCLUDEDIR}")
ENDIF()

ADD_LIBRARY(enet STATIC ${SRCS})
IF (BEOS)
  TARGET_LINK_LIBRARIES(enet network)
ENDIF()
SET_TARGET_PROPERTIES(enet PROPERTIES COMPILE_FLAGS "${FLAGS}")