2020-12-27 10:56:33 -07:00
|
|
|
cmake_minimum_required(VERSION 2.8.12)
|
2015-02-15 05:34:44 -07:00
|
|
|
|
|
|
|
project(enet)
|
|
|
|
|
|
|
|
# The "configure" step.
|
|
|
|
include(CheckFunctionExists)
|
|
|
|
include(CheckStructHasMember)
|
|
|
|
include(CheckTypeSize)
|
2017-02-22 10:21:10 -07:00
|
|
|
|
|
|
|
if(HAIKU)
|
2023-04-02 08:43:06 -06:00
|
|
|
set(CMAKE_REQUIRED_LIBRARIES network)
|
2017-02-22 10:21:10 -07:00
|
|
|
endif(HAIKU)
|
|
|
|
|
2015-02-15 05:34:44 -07:00
|
|
|
check_function_exists("fcntl" HAS_FCNTL)
|
|
|
|
check_function_exists("poll" HAS_POLL)
|
2015-06-02 15:25:13 -06:00
|
|
|
check_function_exists("getaddrinfo" HAS_GETADDRINFO)
|
|
|
|
check_function_exists("getnameinfo" HAS_GETNAMEINFO)
|
2015-02-15 05:34:44 -07:00
|
|
|
check_function_exists("gethostbyname_r" HAS_GETHOSTBYNAME_R)
|
|
|
|
check_function_exists("gethostbyaddr_r" HAS_GETHOSTBYADDR_R)
|
|
|
|
check_function_exists("inet_pton" HAS_INET_PTON)
|
|
|
|
check_function_exists("inet_ntop" HAS_INET_NTOP)
|
|
|
|
check_struct_has_member("struct msghdr" "msg_flags" "sys/types.h;sys/socket.h" HAS_MSGHDR_FLAGS)
|
|
|
|
set(CMAKE_EXTRA_INCLUDE_FILES "sys/types.h" "sys/socket.h")
|
|
|
|
check_type_size("socklen_t" HAS_SOCKLEN_T BUILTIN_TYPES_ONLY)
|
|
|
|
unset(CMAKE_EXTRA_INCLUDE_FILES)
|
2017-02-22 10:21:10 -07:00
|
|
|
|
|
|
|
if(HAIKU)
|
2023-04-02 08:43:06 -06:00
|
|
|
unset(CMAKE_REQUIRED_LIBRARIES)
|
2017-02-22 10:21:10 -07:00
|
|
|
endif()
|
|
|
|
|
2015-02-15 05:34:44 -07:00
|
|
|
if(HAS_FCNTL)
|
|
|
|
add_definitions(-DHAS_FCNTL=1)
|
|
|
|
endif()
|
|
|
|
if(HAS_POLL)
|
|
|
|
add_definitions(-DHAS_POLL=1)
|
|
|
|
endif()
|
2015-06-02 15:25:13 -06:00
|
|
|
if(HAS_GETNAMEINFO)
|
|
|
|
add_definitions(-DHAS_GETNAMEINFO=1)
|
|
|
|
endif()
|
|
|
|
if(HAS_GETADDRINFO)
|
|
|
|
add_definitions(-DHAS_GETADDRINFO=1)
|
|
|
|
endif()
|
2015-02-15 05:34:44 -07:00
|
|
|
if(HAS_GETHOSTBYNAME_R)
|
|
|
|
add_definitions(-DHAS_GETHOSTBYNAME_R=1)
|
|
|
|
endif()
|
|
|
|
if(HAS_GETHOSTBYADDR_R)
|
|
|
|
add_definitions(-DHAS_GETHOSTBYADDR_R=1)
|
|
|
|
endif()
|
|
|
|
if(HAS_INET_PTON)
|
|
|
|
add_definitions(-DHAS_INET_PTON=1)
|
|
|
|
endif()
|
|
|
|
if(HAS_INET_NTOP)
|
|
|
|
add_definitions(-DHAS_INET_NTOP=1)
|
|
|
|
endif()
|
|
|
|
if(HAS_MSGHDR_FLAGS)
|
|
|
|
add_definitions(-DHAS_MSGHDR_FLAGS=1)
|
|
|
|
endif()
|
|
|
|
if(HAS_SOCKLEN_T)
|
|
|
|
add_definitions(-DHAS_SOCKLEN_T=1)
|
|
|
|
endif()
|
2017-02-22 10:21:10 -07:00
|
|
|
|
2023-12-09 10:05:05 -07:00
|
|
|
set(INCLUDE_FILES_PREFIX enet/include/enet)
|
2023-04-02 08:43:06 -06:00
|
|
|
set(INCLUDE_FILES
|
|
|
|
${INCLUDE_FILES_PREFIX}/callbacks.h
|
|
|
|
${INCLUDE_FILES_PREFIX}/enet.h
|
|
|
|
${INCLUDE_FILES_PREFIX}/list.h
|
|
|
|
${INCLUDE_FILES_PREFIX}/protocol.h
|
|
|
|
${INCLUDE_FILES_PREFIX}/time.h
|
|
|
|
${INCLUDE_FILES_PREFIX}/types.h
|
|
|
|
${INCLUDE_FILES_PREFIX}/unix.h
|
|
|
|
${INCLUDE_FILES_PREFIX}/utility.h
|
|
|
|
${INCLUDE_FILES_PREFIX}/win32.h
|
|
|
|
)
|
|
|
|
|
|
|
|
set(SOURCE_FILES
|
2023-12-09 10:05:05 -07:00
|
|
|
enet/callbacks.c
|
|
|
|
enet/compress.c
|
|
|
|
enet/host.c
|
|
|
|
enet/list.c
|
|
|
|
enet/packet.c
|
|
|
|
enet/peer.c
|
|
|
|
enet/protocol.c
|
|
|
|
enet/unix.c
|
|
|
|
enet/win32.c)
|
2023-04-02 08:43:06 -06:00
|
|
|
|
|
|
|
source_group(include FILES ${INCLUDE_FILES})
|
|
|
|
source_group(source FILES ${SOURCE_FILES})
|
|
|
|
|
2015-02-15 05:34:44 -07:00
|
|
|
add_library(enet STATIC
|
2023-04-02 08:43:06 -06:00
|
|
|
${INCLUDE_FILES}
|
|
|
|
${SOURCE_FILES}
|
|
|
|
)
|
2023-12-09 10:05:05 -07:00
|
|
|
target_include_directories(enet PUBLIC enet/include)
|
2023-04-02 08:43:06 -06:00
|
|
|
|
2024-03-19 00:08:54 -06:00
|
|
|
dolphin_disable_warnings(enet)
|
2023-04-15 23:57:34 -06:00
|
|
|
add_library(enet::enet ALIAS enet)
|
2023-04-02 08:43:06 -06:00
|
|
|
|
|
|
|
if (MINGW)
|
|
|
|
target_link_libraries(enet winmm ws2_32)
|
|
|
|
endif()
|
|
|
|
|
2017-02-22 10:21:10 -07:00
|
|
|
if(HAIKU)
|
2023-04-02 08:43:06 -06:00
|
|
|
target_link_libraries(enet network)
|
2017-02-22 10:21:10 -07:00
|
|
|
endif(HAIKU)
|