Skip to content

Commit ba50cad

Browse files
committed
[FIXUP] cmake: Fix check_evhttp_connection_get_peer macro
1 parent 9412a2e commit ba50cad

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

cmake/module/AddLibeventIfNeeded.cmake

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
# Distributed under the MIT software license, see the accompanying
33
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
# Check whether evhttp_connection_get_peer expects const char**.
6+
# See https://github.com/libevent/libevent/commit/a18301a2bb160ff7c3ffaf5b7653c39ffe27b385
57
macro(check_evhttp_connection_get_peer target)
6-
# Check whether evhttp_connection_get_peer expects const char**.
7-
# Fail if neither are available.
8+
cmake_push_check_state(RESET)
9+
set(CMAKE_REQUIRED_LIBRARIES ${target})
810
check_cxx_source_compiles("
911
#include <cstdint>
1012
#include <event2/http.h>
@@ -18,6 +20,7 @@ macro(check_evhttp_connection_get_peer target)
1820
}
1921
" HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR
2022
)
23+
cmake_pop_check_state()
2124
target_compile_definitions(${target} INTERFACE
2225
$<$<BOOL:${HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR}>:HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR=1>
2326
)
@@ -38,14 +41,20 @@ function(add_libevent_if_needed)
3841
endif()
3942

4043
include(CrossPkgConfig)
41-
cross_pkg_check_modules(libevent REQUIRED libevent>=${libevent_minimum_version} IMPORTED_TARGET GLOBAL)
44+
cross_pkg_check_modules(libevent
45+
REQUIRED IMPORTED_TARGET GLOBAL
46+
libevent>=${libevent_minimum_version}
47+
)
4248
check_evhttp_connection_get_peer(PkgConfig::libevent)
4349
target_link_libraries(PkgConfig::libevent INTERFACE
4450
$<$<BOOL:${MINGW}>:iphlpapi;ssp;ws2_32>
4551
)
4652
add_library(libevent::libevent ALIAS PkgConfig::libevent)
4753

4854
if(NOT WIN32)
49-
cross_pkg_check_modules(libevent_pthreads REQUIRED libevent_pthreads>=${libevent_minimum_version} IMPORTED_TARGET)
55+
cross_pkg_check_modules(libevent_pthreads
56+
REQUIRED IMPORTED_TARGET GLOBAL
57+
libevent_pthreads>=${libevent_minimum_version}
58+
)
5059
endif()
5160
endfunction()

0 commit comments

Comments
 (0)