Skip to content

Commit

Permalink
[FIXUP] cmake: Fix check_evhttp_connection_get_peer macro
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed Apr 13, 2023
1 parent 9412a2e commit ba50cad
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions cmake/module/AddLibeventIfNeeded.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

# Check whether evhttp_connection_get_peer expects const char**.
# See https://github.com/libevent/libevent/commit/a18301a2bb160ff7c3ffaf5b7653c39ffe27b385
macro(check_evhttp_connection_get_peer target)
# Check whether evhttp_connection_get_peer expects const char**.
# Fail if neither are available.
cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_LIBRARIES ${target})
check_cxx_source_compiles("
#include <cstdint>
#include <event2/http.h>
Expand All @@ -18,6 +20,7 @@ macro(check_evhttp_connection_get_peer target)
}
" HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR
)
cmake_pop_check_state()
target_compile_definitions(${target} INTERFACE
$<$<BOOL:${HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR}>:HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR=1>
)
Expand All @@ -38,14 +41,20 @@ function(add_libevent_if_needed)
endif()

include(CrossPkgConfig)
cross_pkg_check_modules(libevent REQUIRED libevent>=${libevent_minimum_version} IMPORTED_TARGET GLOBAL)
cross_pkg_check_modules(libevent
REQUIRED IMPORTED_TARGET GLOBAL
libevent>=${libevent_minimum_version}
)
check_evhttp_connection_get_peer(PkgConfig::libevent)
target_link_libraries(PkgConfig::libevent INTERFACE
$<$<BOOL:${MINGW}>:iphlpapi;ssp;ws2_32>
)
add_library(libevent::libevent ALIAS PkgConfig::libevent)

if(NOT WIN32)
cross_pkg_check_modules(libevent_pthreads REQUIRED libevent_pthreads>=${libevent_minimum_version} IMPORTED_TARGET)
cross_pkg_check_modules(libevent_pthreads
REQUIRED IMPORTED_TARGET GLOBAL
libevent_pthreads>=${libevent_minimum_version}
)
endif()
endfunction()

0 comments on commit ba50cad

Please sign in to comment.