forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
279 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright (c) 2023 The Bitcoin Core developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
function(add_boost_if_needed) | ||
#[=[ | ||
TODO: Not all targets, which will be added in the future, require | ||
Boost. Therefore, a proper check will be appropriate here. | ||
|
||
Implementation notes: | ||
Although only Boost headers are used to build Bitcoin Core, | ||
we still leverage a standard CMake's approach to handle | ||
dependencies, i.e., the Boost::headers "library". | ||
A command target_link_libraries(target PRIVATE Boost::headers) | ||
will propagate Boost::headers usage requirements to the target. | ||
For Boost::headers such usage requirements is an include | ||
directory and other added INTERFACE properties. | ||
]=] | ||
|
||
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin" AND BREW_COMMAND) | ||
execute_process( | ||
COMMAND ${BREW_COMMAND} --prefix boost | ||
OUTPUT_VARIABLE BOOST_ROOT | ||
ERROR_QUIET | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
endif() | ||
|
||
set(Boost_NO_BOOST_CMAKE ON) | ||
find_package(Boost 1.64.0 REQUIRED) | ||
set_target_properties(Boost::boost PROPERTIES IMPORTED_GLOBAL TRUE) | ||
target_compile_definitions(Boost::boost INTERFACE | ||
$<$<CONFIG:Debug>:BOOST_MULTI_INDEX_ENABLE_SAFE_MODE> | ||
) | ||
if(CMAKE_VERSION VERSION_LESS 3.15) | ||
add_library(Boost::headers ALIAS Boost::boost) | ||
endif() | ||
|
||
mark_as_advanced(Boost_INCLUDE_DIR) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Copyright (c) 2023 The Bitcoin Core developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
macro(check_evhttp_connection_get_peer target) | ||
# Check whether evhttp_connection_get_peer expects const char**. | ||
# Fail if neither are available. | ||
check_cxx_source_compiles(" | ||
#include <cstdint> | ||
#include <event2/http.h> | ||
int main() | ||
{ | ||
evhttp_connection* conn = (evhttp_connection*)1; | ||
const char* host; | ||
uint16_t port; | ||
evhttp_connection_get_peer(conn, &host, &port); | ||
} | ||
" HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR | ||
) | ||
target_compile_definitions(${target} INTERFACE | ||
$<$<BOOL:${HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR}>:HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR=1> | ||
) | ||
endmacro() | ||
|
||
function(add_libevent_if_needed) | ||
# TODO: Not all targets, which will be added in the future, | ||
# require libevent. Therefore, a proper check will be | ||
# appropriate here. | ||
|
||
set(libevent_minimum_version 2.1.8) | ||
|
||
if(MSVC) | ||
find_package(Libevent ${libevent_minimum_version} REQUIRED COMPONENTS extra CONFIG) | ||
check_evhttp_connection_get_peer(libevent::extra) | ||
add_library(libevent::libevent ALIAS libevent::extra) | ||
return() | ||
endif() | ||
|
||
find_package(PkgConfig) | ||
pkg_check_modules(libevent REQUIRED libevent>=${libevent_minimum_version} IMPORTED_TARGET GLOBAL) | ||
check_evhttp_connection_get_peer(PkgConfig::libevent) | ||
target_link_libraries(PkgConfig::libevent INTERFACE | ||
$<$<BOOL:${MINGW}>:iphlpapi;ws2_32> | ||
) | ||
add_library(libevent::libevent ALIAS PkgConfig::libevent) | ||
|
||
if(NOT WIN32) | ||
pkg_check_modules(libevent_pthreads REQUIRED libevent_pthreads>=${libevent_minimum_version} IMPORTED_TARGET) | ||
endif() | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters