CMakeLists.txt 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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(MSVC)
  20. add_definitions(-W3)
  21. endif()
  22. if(HAS_FCNTL)
  23. add_definitions(-DHAS_FCNTL=1)
  24. endif()
  25. if(HAS_POLL)
  26. add_definitions(-DHAS_POLL=1)
  27. endif()
  28. if(HAS_GETNAMEINFO)
  29. add_definitions(-DHAS_GETNAMEINFO=1)
  30. endif()
  31. if(HAS_GETADDRINFO)
  32. add_definitions(-DHAS_GETADDRINFO=1)
  33. endif()
  34. if(HAS_GETHOSTBYNAME_R)
  35. add_definitions(-DHAS_GETHOSTBYNAME_R=1)
  36. endif()
  37. if(HAS_GETHOSTBYADDR_R)
  38. add_definitions(-DHAS_GETHOSTBYADDR_R=1)
  39. endif()
  40. if(HAS_INET_PTON)
  41. add_definitions(-DHAS_INET_PTON=1)
  42. endif()
  43. if(HAS_INET_NTOP)
  44. add_definitions(-DHAS_INET_NTOP=1)
  45. endif()
  46. if(HAS_MSGHDR_FLAGS)
  47. add_definitions(-DHAS_MSGHDR_FLAGS=1)
  48. endif()
  49. if(HAS_SOCKLEN_T)
  50. add_definitions(-DHAS_SOCKLEN_T=1)
  51. endif()
  52. include_directories(${PROJECT_SOURCE_DIR}/include)
  53. add_library(enet STATIC
  54. callbacks.c
  55. compress.c
  56. host.c
  57. list.c
  58. packet.c
  59. peer.c
  60. protocol.c
  61. unix.c
  62. win32.c
  63. )