CMakeLists.txt 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. cmake_minimum_required(VERSION 2.6)
  2. project(enet)
  3. # The "configure" step.
  4. include(CheckFunctionExists)
  5. include(CheckStructHasMember)
  6. include(CheckTypeSize)
  7. check_function_exists("fcntl" HAS_FCNTL)
  8. check_function_exists("poll" HAS_POLL)
  9. check_function_exists("getaddrinfo" HAS_GETADDRINFO)
  10. check_function_exists("getnameinfo" HAS_GETNAMEINFO)
  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. if(HAS_FCNTL)
  20. add_definitions(-DHAS_FCNTL=1)
  21. endif()
  22. if(HAS_POLL)
  23. add_definitions(-DHAS_POLL=1)
  24. endif()
  25. if(HAS_GETNAMEINFO)
  26. add_definitions(-DHAS_GETNAMEINFO=1)
  27. endif()
  28. if(HAS_GETADDRINFO)
  29. add_definitions(-DHAS_GETADDRINFO=1)
  30. endif()
  31. if(HAS_GETHOSTBYNAME_R)
  32. add_definitions(-DHAS_GETHOSTBYNAME_R=1)
  33. endif()
  34. if(HAS_GETHOSTBYADDR_R)
  35. add_definitions(-DHAS_GETHOSTBYADDR_R=1)
  36. endif()
  37. if(HAS_INET_PTON)
  38. add_definitions(-DHAS_INET_PTON=1)
  39. endif()
  40. if(HAS_INET_NTOP)
  41. add_definitions(-DHAS_INET_NTOP=1)
  42. endif()
  43. if(HAS_MSGHDR_FLAGS)
  44. add_definitions(-DHAS_MSGHDR_FLAGS=1)
  45. endif()
  46. if(HAS_SOCKLEN_T)
  47. add_definitions(-DHAS_SOCKLEN_T=1)
  48. endif()
  49. include_directories(${PROJECT_SOURCE_DIR}/include)
  50. add_library(enet STATIC
  51. callbacks.c
  52. compress.c
  53. host.c
  54. list.c
  55. packet.c
  56. peer.c
  57. protocol.c
  58. unix.c
  59. win32.c
  60. )