Skip to content

Instantly share code, notes, and snippets.

@hebasto
Last active June 16, 2022 09:28
Show Gist options
  • Save hebasto/aac97d2f6b18c4ec2ad951baeb1ac00c to your computer and use it in GitHub Desktop.
Save hebasto/aac97d2f6b18c4ec2ad951baeb1ac00c to your computer and use it in GitHub Desktop.
Bitcoin Core CMake-based build system

Bitcoin Core CMake-based build system

See: hebasto/bitcoin#3

The stuff below has been outdated.


This work is in progress...

Current branch to test: https://github.com/hebasto/bitcoin/commits/cmake/pr

Done:

  • bitcoind executable, could be disabled with -DBUILD_DAEMON=OFF
  • bitcoin-cli executable, could be disabled with -DBUILD_CLI=OFF
  • libbitcoinconsensus shared library, could be disabled with -DBUILD_BITCOINCONSENSUS_LIB=OFF
  • libbitcoinkernel shared library, could be disabled with -DBUILD_BITCOINKERNEL_LIB=OFF
  • wallet support (SQLite, not BDB), could be disabled with -DENABLE_WALLET=OFF
  • ccache support, could be disabled with -DUSE_CCACHE=OFF
  • cross-compiling, including Windows builds with DEBUG=1
  • reduce exported symbols support, could be enabled with -DREDUCE_EXPORTS=ON (broken on macOS yet)

Not implemented yet:

  • optional package support
  • BDB wallet support
  • ...

Need to be fixed:

  • -DREDUCE_EXPORTS=ON on macOS

A benefit to note -- cross compiling libbitcoinconsensus.dll with DEBUG=1 just works (see bitcoin/bitcoin#19772)

Native compiling has been tested on the following OSes:

  • Ubuntu 22.04
  • macOS Monterey
  • FreeBSD 12.3
rm -rf build && cmake -S . -B build
cmake --build build
  • OpenBSD 7.1
rm -rf build && cmake -DCMAKE_MAKE_PROGRAM=gmake -S . -B build
cmake --build build

Cross compiling for Windows on Ubuntu 22.04

make -j$(nproc) -C depends HOST=x86_64-w64-mingw32 NO_QT=1
rm -rf build && cmake -C $PWD/depends/x86_64-w64-mingw32/share/depends.cmake -S . -B build
cmake --build build -j$(nproc)

Cross compiling for macOS on Ubuntu 22.04

make -j$(nproc) -C depends HOST=x86_64-apple-darwin NO_QT=1
rm -rf build && cmake -C $PWD/depends/x86_64-apple-darwin/share/depends.cmake -S . -B build
cmake --build build -j$(nproc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment