-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build: Add CMake-based build system (6 of N) #15
Changes from 9 commits
b2bea9f
5fc2cee
1934755
d1c319d
f944ccd
2e3721e
2fd303f
cb7dc94
a2c3493
751453f
cb19814
a112470
2d8930e
43123cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# 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. | ||
|
||
if(CMAKE_HOST_APPLE) | ||
execute_process( | ||
COMMAND brew --prefix berkeley-db@4 | ||
OUTPUT_VARIABLE bdb4_brew_prefix | ||
ERROR_QUIET | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
endif() | ||
|
||
find_path(BerkeleyDB_INCLUDE_DIR | ||
NAMES db.h | ||
HINTS ${bdb4_brew_prefix}/include | ||
PATH_SUFFIXES 4.8 48 4 db4 5 5.3 db5 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of curiosity, where did you get these from? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
) | ||
|
||
if(BerkeleyDB_INCLUDE_DIR) | ||
file( | ||
STRINGS "${BerkeleyDB_INCLUDE_DIR}/db.h" version_strings | ||
REGEX ".*DB_VERSION_(MAJOR|MINOR)[ \t]+[0-9]+.*" | ||
) | ||
string(REGEX REPLACE ".*DB_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" BerkeleyDB_VERSION_MAJOR "${version_strings}") | ||
string(REGEX REPLACE ".*DB_VERSION_MINOR[ \t]+([0-9]+).*" "\\1" BerkeleyDB_VERSION_MINOR "${version_strings}") | ||
set(BerkeleyDB_VERSION ${BerkeleyDB_VERSION_MAJOR}.${BerkeleyDB_VERSION_MINOR}) | ||
endif() | ||
|
||
if(MSVC) | ||
cmake_path(GET BerkeleyDB_INCLUDE_DIR PARENT_PATH BerkeleyDB_IMPORTED_PATH) | ||
find_library(BerkeleyDB_LIBRARY_DEBUG | ||
NAMES libdb48 PATHS ${BerkeleyDB_IMPORTED_PATH}/debug/lib | ||
NO_DEFAULT_PATH | ||
) | ||
find_library(BerkeleyDB_LIBRARY_RELEASE | ||
NAMES libdb48 PATHS ${BerkeleyDB_IMPORTED_PATH}/lib | ||
NO_DEFAULT_PATH | ||
) | ||
if(BerkeleyDB_LIBRARY_DEBUG OR BerkeleyDB_LIBRARY_RELEASE) | ||
set(BerkeleyDB_required BerkeleyDB_IMPORTED_PATH) | ||
endif() | ||
else() | ||
find_library(BerkeleyDB_LIBRARY | ||
NAMES db_cxx-4.8 libdb48 db4_cxx db_cxx db_cxx-5 | ||
HINTS ${bdb4_brew_prefix}/lib | ||
) | ||
set(BerkeleyDB_required BerkeleyDB_LIBRARY) | ||
endif() | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(BerkeleyDB | ||
REQUIRED_VARS ${BerkeleyDB_required} BerkeleyDB_INCLUDE_DIR | ||
VERSION_VAR BerkeleyDB_VERSION | ||
) | ||
|
||
if(BerkeleyDB_FOUND AND NOT TARGET BerkeleyDB::BerkeleyDB) | ||
add_library(BerkeleyDB::BerkeleyDB UNKNOWN IMPORTED) | ||
set_target_properties(BerkeleyDB::BerkeleyDB PROPERTIES | ||
INTERFACE_INCLUDE_DIRECTORIES "${BerkeleyDB_INCLUDE_DIR}" | ||
) | ||
if(MSVC) | ||
if(BerkeleyDB_LIBRARY_DEBUG) | ||
set_property(TARGET BerkeleyDB::BerkeleyDB APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) | ||
set_target_properties(BerkeleyDB::BerkeleyDB PROPERTIES | ||
IMPORTED_LOCATION_DEBUG "${BerkeleyDB_LIBRARY_DEBUG}" | ||
) | ||
endif() | ||
if(BerkeleyDB_LIBRARY_RELEASE) | ||
set_property(TARGET BerkeleyDB::BerkeleyDB APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) | ||
set_target_properties(BerkeleyDB::BerkeleyDB PROPERTIES | ||
IMPORTED_LOCATION_RELEASE "${BerkeleyDB_LIBRARY_RELEASE}" | ||
) | ||
endif() | ||
else() | ||
set_target_properties(BerkeleyDB::BerkeleyDB PROPERTIES | ||
IMPORTED_LOCATION "${BerkeleyDB_LIBRARY}" | ||
) | ||
endif() | ||
endif() | ||
|
||
mark_as_advanced( | ||
BerkeleyDB_INCLUDE_DIR | ||
BerkeleyDB_LIBRARY | ||
BerkeleyDB_LIBRARY_DEBUG | ||
BerkeleyDB_LIBRARY_RELEASE | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,25 @@ target_link_libraries(bitcoin_common | |
) | ||
|
||
|
||
if(ENABLE_WALLET) | ||
add_subdirectory(wallet) | ||
|
||
if(BUILD_WALLET_TOOL) | ||
add_executable(bitcoin-wallet | ||
bitcoin-wallet.cpp | ||
init/bitcoin-wallet.cpp | ||
wallet/wallettool.cpp | ||
) | ||
target_link_libraries(bitcoin-wallet | ||
bitcoin_wallet | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The naming and semantics between |
||
bitcoin_common | ||
bitcoin_util | ||
Boost::headers | ||
) | ||
endif() | ||
endif() | ||
|
||
|
||
# P2P and RPC server functionality used by `bitcoind` and `bitcoin-qt` executables. | ||
add_library(bitcoin_node STATIC EXCLUDE_FROM_ALL | ||
addrdb.cpp | ||
|
@@ -178,9 +197,13 @@ add_library(bitcoin_node STATIC EXCLUDE_FROM_ALL | |
validation.cpp | ||
validationinterface.cpp | ||
versionbits.cpp | ||
|
||
dummywallet.cpp | ||
) | ||
if(ENABLE_WALLET) | ||
target_sources(bitcoin_node PRIVATE wallet/init.cpp) | ||
target_link_libraries(bitcoin_node PRIVATE bitcoin_wallet) | ||
else() | ||
target_sources(bitcoin_node PRIVATE dummywallet.cpp) | ||
endif() | ||
target_link_libraries(bitcoin_node | ||
PRIVATE | ||
bitcoin_common | ||
|
@@ -212,3 +235,44 @@ if(BUILD_DAEMON) | |
$<$<BOOL:${MINGW}>:-static> | ||
) | ||
endif() | ||
|
||
|
||
add_library(bitcoin_cli STATIC EXCLUDE_FROM_ALL | ||
compat/stdin.cpp | ||
rpc/client.cpp | ||
) | ||
target_link_libraries(bitcoin_cli | ||
PUBLIC | ||
univalue | ||
) | ||
|
||
|
||
# Bitcoin Core RPC client | ||
if(BUILD_CLI) | ||
add_executable(bitcoin-cli bitcoin-cli.cpp) | ||
target_link_libraries(bitcoin-cli | ||
bitcoin_cli | ||
bitcoin_common | ||
bitcoin_util | ||
libevent::libevent | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. crypto is missing here. Is it actually unneeded in autotools? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In CMake, the
No. It is still needed in Autotools. Otherwise, the |
||
) | ||
endif() | ||
|
||
|
||
if(BUILD_TX) | ||
add_executable(bitcoin-tx bitcoin-tx.cpp) | ||
target_link_libraries(bitcoin-tx | ||
bitcoin_common | ||
bitcoin_util | ||
univalue | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. No need for crypto upstream? I'll stop asking if I see more as I assume I'm missing something. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
) | ||
endif() | ||
|
||
|
||
if(BUILD_UTIL) | ||
add_executable(bitcoin-util bitcoin-util.cpp) | ||
target_link_libraries(bitcoin-util | ||
bitcoin_common | ||
bitcoin_util | ||
) | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens in the case of
CFLAGS=-isystem foo -I bar
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is all about how CMake handles the output of the
pkg-config --cflags-only-I <package>
command. All-I some_directory
instances are handled fine.For example, in a broken combo of CMake 3.16.6 + pkg-config 0.29.2, the value of the
INTERFACE_INCLUDE_DIRECTORIES
property of the importedPkgConfig::libzmq
target is a list as follows:Compare to:
Therefore, to fix the bug, it is enough to just filter out "-isystem" from the
INTERFACE_INCLUDE_DIRECTORIES
list.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a note explaining what's happening here and what it's working around please? That's not clear to me from the code alone.