CMakeLists.txt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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("gethostbyname_r" HAS_GETHOSTBYNAME_R)
  10. check_function_exists("gethostbyaddr_r" HAS_GETHOSTBYADDR_R)
  11. check_function_exists("inet_pton" HAS_INET_PTON)
  12. check_function_exists("inet_ntop" HAS_INET_NTOP)
  13. check_struct_has_member("struct msghdr" "msg_flags" "sys/types.h;sys/socket.h" HAS_MSGHDR_FLAGS)
  14. set(CMAKE_EXTRA_INCLUDE_FILES "sys/types.h" "sys/socket.h")
  15. check_type_size("socklen_t" HAS_SOCKLEN_T BUILTIN_TYPES_ONLY)
  16. unset(CMAKE_EXTRA_INCLUDE_FILES)
  17. if(HAS_FCNTL)
  18. add_definitions(-DHAS_FCNTL=1)
  19. endif()
  20. if(HAS_POLL)
  21. add_definitions(-DHAS_POLL=1)
  22. endif()
  23. if(HAS_GETHOSTBYNAME_R)
  24. add_definitions(-DHAS_GETHOSTBYNAME_R=1)
  25. endif()
  26. if(HAS_GETHOSTBYADDR_R)
  27. add_definitions(-DHAS_GETHOSTBYADDR_R=1)
  28. endif()
  29. if(HAS_INET_PTON)
  30. add_definitions(-DHAS_INET_PTON=1)
  31. endif()
  32. if(HAS_INET_NTOP)
  33. add_definitions(-DHAS_INET_NTOP=1)
  34. endif()
  35. if(HAS_MSGHDR_FLAGS)
  36. add_definitions(-DHAS_MSGHDR_FLAGS=1)
  37. endif()
  38. if(HAS_SOCKLEN_T)
  39. add_definitions(-DHAS_SOCKLEN_T=1)
  40. endif()
  41. include_directories(${PROJECT_SOURCE_DIR}/include)
  42. add_library(enet STATIC
  43. callbacks.c
  44. compress.c
  45. host.c
  46. list.c
  47. packet.c
  48. peer.c
  49. protocol.c
  50. unix.c
  51. win32.c
  52. )