Skip to content

cmake: Set top-level target output locations

This PR sets the target output locations to the bin and lib subdirectories within the build tree, creating a directory structure that mirrors that of the installed targets.

This approach is widely adopted by the large projects, such as LLVM:

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})

The libsecp256k1 project has also recently adopted this approach.

With this PR, all binaries are conveniently located. For example, run:

$ ./build/bin/fuzz

instead of:

$ ./build/src/test/fuzz/fuzz

On Windows, all required DLLs are now located in the same directory as the executables, allowing to run bitcoin-chainstate.exe (which loads bitcoinkernel.dll) without the need to copy DLLs or modify the PATH variable.

The idea was briefly discussed among the build team during the recent CoreDev meeting.

Merge request reports

Loading