CMakeLists.txt 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. cmake_minimum_required(VERSION 2.8.12)
  2. project(enet)
  3. # The "configure" step.
  4. include(CheckFunctionExists)
  5. include(CheckStructHasMember)
  6. include(CheckTypeSize)
  7. if(HAIKU)
  8. set(CMAKE_REQUIRED_LIBRARIES network)
  9. endif(HAIKU)
  10. check_function_exists("fcntl" HAS_FCNTL)
  11. check_function_exists("poll" HAS_POLL)
  12. check_function_exists("getaddrinfo" HAS_GETADDRINFO)
  13. check_function_exists("getnameinfo" HAS_GETNAMEINFO)
  14. check_function_exists("gethostbyname_r" HAS_GETHOSTBYNAME_R)
  15. check_function_exists("gethostbyaddr_r" HAS_GETHOSTBYADDR_R)
  16. check_function_exists("inet_pton" HAS_INET_PTON)
  17. check_function_exists("inet_ntop" HAS_INET_NTOP)
  18. check_struct_has_member("struct msghdr" "msg_flags" "sys/types.h;sys/socket.h" HAS_MSGHDR_FLAGS)
  19. set(CMAKE_EXTRA_INCLUDE_FILES "sys/types.h" "sys/socket.h")
  20. check_type_size("socklen_t" HAS_SOCKLEN_T BUILTIN_TYPES_ONLY)
  21. unset(CMAKE_EXTRA_INCLUDE_FILES)
  22. if(HAIKU)
  23. unset(CMAKE_REQUIRED_LIBRARIES)
  24. endif()
  25. if(HAS_FCNTL)
  26. add_definitions(-DHAS_FCNTL=1)
  27. endif()
  28. if(HAS_POLL)
  29. add_definitions(-DHAS_POLL=1)
  30. endif()
  31. if(HAS_GETNAMEINFO)
  32. add_definitions(-DHAS_GETNAMEINFO=1)
  33. endif()
  34. if(HAS_GETADDRINFO)
  35. add_definitions(-DHAS_GETADDRINFO=1)
  36. endif()
  37. if(HAS_GETHOSTBYNAME_R)
  38. add_definitions(-DHAS_GETHOSTBYNAME_R=1)
  39. endif()
  40. if(HAS_GETHOSTBYADDR_R)
  41. add_definitions(-DHAS_GETHOSTBYADDR_R=1)
  42. endif()
  43. if(HAS_INET_PTON)
  44. add_definitions(-DHAS_INET_PTON=1)
  45. endif()
  46. if(HAS_INET_NTOP)
  47. add_definitions(-DHAS_INET_NTOP=1)
  48. endif()
  49. if(HAS_MSGHDR_FLAGS)
  50. add_definitions(-DHAS_MSGHDR_FLAGS=1)
  51. endif()
  52. if(HAS_SOCKLEN_T)
  53. add_definitions(-DHAS_SOCKLEN_T=1)
  54. endif()
  55. set(INCLUDE_FILES_PREFIX enet/include/enet)
  56. set(INCLUDE_FILES
  57. ${INCLUDE_FILES_PREFIX}/callbacks.h
  58. ${INCLUDE_FILES_PREFIX}/enet.h
  59. ${INCLUDE_FILES_PREFIX}/list.h
  60. ${INCLUDE_FILES_PREFIX}/protocol.h
  61. ${INCLUDE_FILES_PREFIX}/time.h
  62. ${INCLUDE_FILES_PREFIX}/types.h
  63. ${INCLUDE_FILES_PREFIX}/unix.h
  64. ${INCLUDE_FILES_PREFIX}/utility.h
  65. ${INCLUDE_FILES_PREFIX}/win32.h
  66. )
  67. set(SOURCE_FILES
  68. enet/callbacks.c
  69. enet/compress.c
  70. enet/host.c
  71. enet/list.c
  72. enet/packet.c
  73. enet/peer.c
  74. enet/protocol.c
  75. enet/unix.c
  76. enet/win32.c)
  77. source_group(include FILES ${INCLUDE_FILES})
  78. source_group(source FILES ${SOURCE_FILES})
  79. add_library(enet STATIC
  80. ${INCLUDE_FILES}
  81. ${SOURCE_FILES}
  82. )
  83. target_include_directories(enet PUBLIC enet/include)
  84. dolphin_disable_warnings(enet)
  85. add_library(enet::enet ALIAS enet)
  86. if (MINGW)
  87. target_link_libraries(enet winmm ws2_32)
  88. endif()
  89. if(HAIKU)
  90. target_link_libraries(enet network)
  91. endif(HAIKU)