Skip to content

Commit

Permalink
build: check libev version
Browse files Browse the repository at this point in the history
Signed-off-by: hexian000 <hexian000@outlook.com>
  • Loading branch information
hexian000 committed Jan 7, 2024
1 parent c92d1f7 commit 66fd747
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
12 changes: 10 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,16 @@ if(BUILD_STATIC OR LINK_STATIC_LIBS)
else()
find_library(LIBEV_LIBRARY NAMES ev)
endif()
if((NOT EXISTS ${LIBEV_INCLUDE_DIR}) OR (NOT EXISTS ${LIBEV_LIBRARY}))
message(FATAL_ERROR "libev not found")
if(EXISTS "${LIBEV_INCLUDE_DIR}/ev.h")
file(READ "${LIBEV_INCLUDE_DIR}/ev.h" LIBEV_VERSION_STR)
string(REGEX MATCH "#define EV_VERSION_MAJOR[ \t]+([0-9]+)" _ ${LIBEV_VERSION_STR})
set(EV_VERSION_MAJOR ${CMAKE_MATCH_1})
string(REGEX MATCH "#define EV_VERSION_MINOR[ \t]+([0-9]+)" _ ${LIBEV_VERSION_STR})
set(EV_VERSION_MINOR ${CMAKE_MATCH_1})
set(LIBEV_VERSION "${EV_VERSION_MAJOR}.${EV_VERSION_MINOR}")
endif()
if((NOT ${LIBEV_VERSION} VERSION_GREATER_EQUAL "4.31") OR (NOT EXISTS ${LIBEV_LIBRARY}))
message(FATAL_ERROR "libev (>= 4.31) not found")
endif()
message(STATUS "libev: ${LIBEV_LIBRARY}")
target_include_directories(kcptun-libev SYSTEM PRIVATE ${LIBEV_INCLUDE_DIR})
Expand Down
7 changes: 4 additions & 3 deletions src/sockutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ bool sa_equals(const struct sockaddr *a, const struct sockaddr *b);
bool sa_matches(const struct sockaddr *bind, const struct sockaddr *dest);
int format_sa(const struct sockaddr *sa, char *buf, size_t buf_size);

enum { RESOLVE_TCP = 0x0,
RESOLVE_UDP = 0x1,
RESOLVE_PASSIVE = 0x2,
enum {
RESOLVE_TCP = 0x0,
RESOLVE_UDP = 0x1,
RESOLVE_PASSIVE = 0x2,
};
bool resolve_addr(union sockaddr_max *sa, const char *s, int flags);

Expand Down

0 comments on commit 66fd747

Please sign in to comment.