Skip to content

Commit 026bb22

Browse files
committedFeb 20, 2025
cmake: Set top-level target output locations
This change: 1. Collects build artifacts in dedicated locations. 2. Allows running bitcoin-chainstate.exe with bitcoinkernel.dll directly from the build tree on Windows.
1 parent db63bfb commit 026bb22

File tree

9 files changed

+64
-45
lines changed

9 files changed

+64
-45
lines changed
 

‎.github/workflows/ci.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ jobs:
238238
if: matrix.job-type == 'standard'
239239
working-directory: build
240240
env:
241-
BITCOIND: '${{ github.workspace }}\build\src\Release\bitcoind.exe'
242-
BITCOINCLI: '${{ github.workspace }}\build\src\Release\bitcoin-cli.exe'
243-
BITCOINUTIL: '${{ github.workspace }}\build\src\Release\bitcoin-util.exe'
244-
BITCOINWALLET: '${{ github.workspace }}\build\src\Release\bitcoin-wallet.exe'
241+
BITCOIND: '${{ github.workspace }}\build\bin\Release\bitcoind.exe'
242+
BITCOINCLI: '${{ github.workspace }}\build\bin\Release\bitcoin-cli.exe'
243+
BITCOINUTIL: '${{ github.workspace }}\build\bin\Release\bitcoin-util.exe'
244+
BITCOINWALLET: '${{ github.workspace }}\build\bin\Release\bitcoin-wallet.exe'
245245
TEST_RUNNER_EXTRA: ${{ github.event_name != 'pull_request' && '--extended' || '' }}
246246
shell: cmd
247247
run: py -3 test\functional\test_runner.py --jobs %NUMBER_OF_PROCESSORS% --ci --quiet --tmpdirprefix=%RUNNER_TEMP% --combinedlogslen=99999999 --timeout-factor=%TEST_RUNNER_TIMEOUT_FACTOR% %TEST_RUNNER_EXTRA%
@@ -258,7 +258,7 @@ jobs:
258258
if: matrix.job-type == 'fuzz'
259259
working-directory: build
260260
env:
261-
BITCOINFUZZ: '${{ github.workspace }}\build\src\test\fuzz\Release\fuzz.exe'
261+
BITCOINFUZZ: '${{ github.workspace }}\build\bin\Release\fuzz.exe'
262262
shell: cmd
263263
run: |
264264
py -3 test\fuzz\test_runner.py --par %NUMBER_OF_PROCESSORS% --loglevel DEBUG %RUNNER_TEMP%\qa-assets\fuzz_corpora

‎CMakeLists.txt

-3
Original file line numberDiff line numberDiff line change
@@ -609,9 +609,6 @@ endif()
609609
add_subdirectory(test)
610610
add_subdirectory(doc)
611611

612-
include(cmake/crc32c.cmake)
613-
include(cmake/leveldb.cmake)
614-
include(cmake/minisketch.cmake)
615612
add_subdirectory(src)
616613

617614
include(cmake/tests.cmake)

‎contrib/devtools/check-deps.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ declare -A LIBS
88
LIBS[cli]="libbitcoin_cli.a"
99
LIBS[common]="libbitcoin_common.a"
1010
LIBS[consensus]="libbitcoin_consensus.a"
11-
LIBS[crypto]="crypto/libbitcoin_crypto.a"
11+
LIBS[crypto]="libbitcoin_crypto.a"
1212
LIBS[node]="libbitcoin_node.a"
13-
LIBS[util]="util/libbitcoin_util.a"
14-
LIBS[wallet]="wallet/libbitcoin_wallet.a"
13+
LIBS[util]="libbitcoin_util.a"
14+
LIBS[wallet]="libbitcoin_wallet.a"
1515

1616
# Declare allowed dependencies "X Y" where X is allowed to depend on Y. This
1717
# list is taken from doc/design/libraries.md.
@@ -187,7 +187,7 @@ fi
187187
# shellcheck disable=SC2046
188188
cmake --build "$BUILD_DIR" -j"$(nproc)" -t $(lib_targets)
189189
TEMP_DIR="$(mktemp -d)"
190-
cd "$BUILD_DIR/src"
190+
cd "$BUILD_DIR/lib"
191191
extract_symbols "$TEMP_DIR"
192192
if check_libraries "$TEMP_DIR"; then
193193
echo "Success! No unexpected dependencies were detected."

‎contrib/devtools/gen-bitcoin-conf.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
export LC_ALL=C
77
TOPDIR=${TOPDIR:-$(git rev-parse --show-toplevel)}
88
BUILDDIR=${BUILDDIR:-$TOPDIR/build}
9-
BINDIR=${BINDIR:-$BUILDDIR/src}
9+
BINDIR=${BINDIR:-$BUILDDIR/bin}
1010
BITCOIND=${BITCOIND:-$BINDIR/bitcoind}
1111
SHARE_EXAMPLES_DIR=${SHARE_EXAMPLES_DIR:-$TOPDIR/share/examples}
1212
EXAMPLE_CONF_FILE=${EXAMPLE_CONF_FILE:-$SHARE_EXAMPLES_DIR/bitcoin.conf}

‎contrib/devtools/gen-manpages.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
import argparse
1010

1111
BINARIES = [
12-
'src/bitcoind',
13-
'src/bitcoin-cli',
14-
'src/bitcoin-tx',
15-
'src/bitcoin-wallet',
16-
'src/bitcoin-util',
17-
'src/qt/bitcoin-qt',
12+
'bin/bitcoind',
13+
'bin/bitcoin-cli',
14+
'bin/bitcoin-tx',
15+
'bin/bitcoin-wallet',
16+
'bin/bitcoin-util',
17+
'bin/bitcoin-qt',
1818
]
1919

2020
parser = argparse.ArgumentParser(

‎src/CMakeLists.txt

+43-21
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,18 @@ include(AddWindowsResources)
77
configure_file(${PROJECT_SOURCE_DIR}/cmake/bitcoin-build-config.h.in bitcoin-build-config.h USE_SOURCE_PERMISSIONS @ONLY)
88
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
99

10-
add_custom_target(generate_build_info
11-
BYPRODUCTS ${PROJECT_BINARY_DIR}/src/bitcoin-build-info.h
12-
COMMAND ${CMAKE_COMMAND} -DBUILD_INFO_HEADER_PATH=${PROJECT_BINARY_DIR}/src/bitcoin-build-info.h -DSOURCE_DIR=${PROJECT_SOURCE_DIR} -P ${PROJECT_SOURCE_DIR}/cmake/script/GenerateBuildInfo.cmake
13-
COMMENT "Generating bitcoin-build-info.h"
14-
VERBATIM
15-
)
16-
add_library(bitcoin_clientversion STATIC EXCLUDE_FROM_ALL
17-
clientversion.cpp
18-
)
19-
target_link_libraries(bitcoin_clientversion
20-
PRIVATE
21-
core_interface
22-
)
23-
add_dependencies(bitcoin_clientversion generate_build_info)
24-
25-
add_subdirectory(crypto)
10+
#=============================
11+
# Subprojects
12+
#=============================
13+
# Subprojects include subdirectories that do or could have tests
14+
# and/or benchmark binaries, such as all subtrees and univalue.
15+
# These need to be included before CMAKE_*_OUTPUT_DIRECTORY variables
16+
# are set, so output locations of subproject tests and libraries are
17+
# not overridden.
18+
include(../cmake/crc32c.cmake)
19+
include(../cmake/leveldb.cmake)
20+
include(../cmake/minisketch.cmake)
2621
add_subdirectory(univalue)
27-
add_subdirectory(util)
28-
if(WITH_MULTIPROCESS)
29-
add_subdirectory(ipc)
30-
endif()
31-
3222
#=============================
3323
# secp256k1 subtree
3424
#=============================
@@ -78,6 +68,38 @@ set_target_properties(secp256k1 PROPERTIES
7868
)
7969
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
8070

71+
# Set top-level target output locations.
72+
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
73+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
74+
endif()
75+
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
76+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
77+
endif()
78+
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
79+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
80+
endif()
81+
82+
add_custom_target(generate_build_info
83+
BYPRODUCTS ${PROJECT_BINARY_DIR}/src/bitcoin-build-info.h
84+
COMMAND ${CMAKE_COMMAND} -DBUILD_INFO_HEADER_PATH=${PROJECT_BINARY_DIR}/src/bitcoin-build-info.h -DSOURCE_DIR=${PROJECT_SOURCE_DIR} -P ${PROJECT_SOURCE_DIR}/cmake/script/GenerateBuildInfo.cmake
85+
COMMENT "Generating bitcoin-build-info.h"
86+
VERBATIM
87+
)
88+
add_library(bitcoin_clientversion STATIC EXCLUDE_FROM_ALL
89+
clientversion.cpp
90+
)
91+
target_link_libraries(bitcoin_clientversion
92+
PRIVATE
93+
core_interface
94+
)
95+
add_dependencies(bitcoin_clientversion generate_build_info)
96+
97+
add_subdirectory(crypto)
98+
add_subdirectory(util)
99+
if(WITH_MULTIPROCESS)
100+
add_subdirectory(ipc)
101+
endif()
102+
81103
add_library(bitcoin_consensus STATIC EXCLUDE_FROM_ALL
82104
arith_uint256.cpp
83105
consensus/merkle.cpp

‎test/functional/test_framework/test_framework.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def set_binary_paths(self):
255255
for binary, [attribute_name, env_variable_name] in binaries.items():
256256
default_filename = os.path.join(
257257
self.config["environment"]["BUILDDIR"],
258-
"src",
258+
"bin",
259259
binary + self.config["environment"]["EXEEXT"],
260260
)
261261
setattr(self.options, attribute_name, os.getenv(env_variable_name, default=default_filename))
@@ -272,8 +272,8 @@ def setup(self):
272272
self.set_binary_paths()
273273

274274
os.environ['PATH'] = os.pathsep.join([
275-
os.path.join(config['environment']['BUILDDIR'], 'src'),
276-
os.path.join(config['environment']['BUILDDIR'], 'src', 'qt'), os.environ['PATH']
275+
os.path.join(config['environment']['BUILDDIR'], 'bin'),
276+
os.environ['PATH']
277277
])
278278

279279
# Set up temp directory and start logging

‎test/fuzz/test_runner.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def main():
109109
logging.error("Must have fuzz executable built")
110110
sys.exit(1)
111111

112-
fuzz_bin=os.getenv("BITCOINFUZZ", default=os.path.join(config["environment"]["BUILDDIR"], 'src', 'test', 'fuzz', 'fuzz'))
112+
fuzz_bin=os.getenv("BITCOINFUZZ", default=os.path.join(config["environment"]["BUILDDIR"], 'bin', 'fuzz'))
113113

114114
# Build list of tests
115115
test_list_all = parse_test_list(

‎test/util/test_runner.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def bctest(testDir, testObj, buildenv):
7373
are not as expected. Error is caught by bctester() and reported.
7474
"""
7575
# Get the exec names and arguments
76-
execprog = os.path.join(buildenv["BUILDDIR"], "src", testObj["exec"] + buildenv["EXEEXT"])
76+
execprog = os.path.join(buildenv["BUILDDIR"], "bin", testObj["exec"] + buildenv["EXEEXT"])
7777
if testObj["exec"] == "./bitcoin-util":
7878
execprog = os.getenv("BITCOINUTIL", default=execprog)
7979
elif testObj["exec"] == "./bitcoin-tx":

0 commit comments

Comments
 (0)
Please sign in to comment.