Repository navigation
build: Introduce CMake-based build system - #75
Conversation
|
Chasing for Concept (N)ACKs... |
bd57926 to
14503b1
Compare
14503b1 to
30fdfb3
Compare
|
The currently suggesting minimal CMake-based build system implementation is enough for:
add_subdirectory(minisketch EXCLUDE_FROM_ALL)
target_compile_definitions(minisketch
PRIVATE
DISABLE_DEFAULT_FIELDS
ENABLE_FIELD_32
)To became a full fledged one, the current minimal CMake-based build system requires some additional features:
Although, those features are not required for this PR goal, i.e., providing a native Windows CI task. |
30fdfb3 to
5851544
Compare
5851544 to
d2408e0
Compare
|
Imo this should be renamed "Add CMake buildsystem". I looked for this a while back and didn't find it because CMake isn't mentioned in the title. Concept ACK. Will review next week. |
|
@sipa Are you interested in CMake for this project? |
|
@theuni Yeah, will look soon. |
Done. |
|
I'm happy to add a CMake build system for minisketch. I will need review from people more experienced with build systems, though. |
I'm going to update this PR shortly. |
66b4133 to
b486457
Compare
|
Reworked. The PR description has been updated. The approach from hebasto/bitcoin#93 was used for printing summary. |
| endif() | ||
|
|
||
| if(MINGW) | ||
| add_link_options(-static) |
There was a problem hiding this comment.
I don't think we should port this functionality. Instead we should use the CMake shared/static selection machinery.
There was a problem hiding this comment.
This affects only benchmark/test binaries and allows to run them on the build system via Wine when building either a static library or a shared one.
UPD. It also links libstdc++-6 to libminisketch.dll statically when cross-compiling for Windows and -DBUILD_SHARED_LIBS=YES is provided.
There was a problem hiding this comment.
Consider
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++-posix
cmake --build build --target test
wine ./build/src/test.exe
or
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++-posix \
-DBUILD_SHARED_LIBS=YES
cmake --build build --target test
wine ./build/src/test.exe
| ) | ||
|
|
||
| if(DEFINED CMAKE_CXX_STANDARD) | ||
| if(CMAKE_CXX_STANDARD EQUAL 98 OR CMAKE_CXX_STANDARD LESS 11) |
|
Addressed @theuni's comments. |
|
What is the status here? |
I'll push an update shortly. |
| # Prevent include directories from parent project from leaking into this one. | ||
| set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "") |
There was a problem hiding this comment.
See similar code in the libmultiprocess project:
# Prevent include directories from parent project from leaking into this one.
set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "")|
Pushed some improvements basing on @ryanofsky's bitcoin-core/libmultiprocess@6adbb1d and offline discussions with @purpleKarrot.
|
85d6f32 to
0d6e8ac
Compare
|
The feedback from @purpleKarrot has been addressed.
|
|
@hebasto, I think you accidentally based your latest change on an older revision. A few changes got reverted. |
| #============================= | ||
| # Build Options | ||
| #============================= | ||
| set(CMAKE_CXX_VISIBILITY_PRESET hidden) |
There was a problem hiding this comment.
This feature actually requires a bit more work to get right. It is currently not working correctly in the autotools build either, so it can be done in a separate PR.
|
Further feedback from @purpleKarrot has been addressed. The corresponding Bitcoin Core branch that integrates the new build system is available here.
Should be OK now. |
|
ACK 850cc86 |
|
Weakly-tested ACK 850cc86 |
f74b7e2bc2 Merge bitcoin-core/minisketch#75: build: Introduce CMake-based build system 850cc868d5 ci: Add GHA workflow with native Windows job 40d56708c8 doc: Add "Building with CMake" section to `README.md` a0c86c79a7 build: Add CMake-based build system git-subtree-dir: src/minisketch git-subtree-split: f74b7e2bc2e5e1a1360927934521216bee5f345c
…BUILD_SHARED_LIBS` 7b07b22 cmake: Avoid contaminating parent project's cache with BUILD_SHARED_LIBS (Hennadii Stepanov) Pull request description: The CMake cache is global in scope. Therefore, setting the standard cache variable `BUILD_SHARED_LIBS` can inadvertently affect the behavior of a parent project. Consider configuring Bitcoin Core without explicit setting `BUILD_SHARED_LIBS`: ``` $ cmake -B build -DBUILD_KERNEL_LIB=ON ``` According to CMake’s documentation, this should configure `libbitcoinkernel` as `STATIC`. However, that's not the case: ``` $ cmake --build build -t libbitcoinkernel [143/143] Linking CXX shared library lib/libbitcoinkernel.so ``` This PR: 1. Sets the `BUILD_SHARED_LIBS` cache variable only when `libsecp256k1` is the top-level project. 2. Removes the `SECP256K1_DISABLE_SHARED` cache variable. This enables parent projects that include libsecp256k1 as a subproject to rely solely on standard CMake variables for configuring the library type. During integration into a parent project, the static library can be forced as demonstrated [here](bitcoin-core/minisketch#75 (comment)). ACKs for top commit: purpleKarrot: ACK 7b07b22 theuni: utACK 7b07b22 Tree-SHA512: 399a02e86093656ce70d9a0292a1f30834bcc5b9cf0f77d6465adc5e8a4d8e779684adedc40942eb931fed857399e4176a23fdbdf45f277184b28159fbc932d2
d1bd01e189 Merge bitcoin-core/minisketch#98: misc: drop trailing whitespace fe2c88a4fd misc: drop trailing whitespace f74b7e2bc2 Merge bitcoin-core/minisketch#75: build: Introduce CMake-based build system 850cc868d5 ci: Add GHA workflow with native Windows job 40d56708c8 doc: Add "Building with CMake" section to `README.md` a0c86c79a7 build: Add CMake-based build system git-subtree-dir: src/minisketch git-subtree-split: d1bd01e189e745cd1828707e0a7004b6a6909650
4543a3b Squashed 'src/minisketch/' changes from ea8f66b1ea..d1bd01e189 (Hennadii Stepanov) Pull request description: This PR updates the `minisketch` subtree to latest upstream, which includes: - bitcoin-core/minisketch#75 - bitcoin-core/minisketch#98 ACKs for top commit: fanquake: ACK c235aa4 Tree-SHA512: 856fb8b7dc2e743c9c67164023bf53faf8766079aeccc82a30c8b90c85920b31977b6a8b26e51e5485b20e445a3ca6ff806e701a53e95f70181ea30055e3528c
4543a3b Squashed 'src/minisketch/' changes from ea8f66b1ea..d1bd01e189 (Hennadii Stepanov) Pull request description: This PR updates the `minisketch` subtree to latest upstream, which includes: - bitcoin-core/minisketch#75 - bitcoin-core/minisketch#98 ACKs for top commit: fanquake: ACK 9b05507 Tree-SHA512: 856fb8b7dc2e743c9c67164023bf53faf8766079aeccc82a30c8b90c85920b31977b6a8b26e51e5485b20e445a3ca6ff806e701a53e95f70181ea30055e3528c
4543a3b Squashed 'src/minisketch/' changes from ea8f66b1ea..d1bd01e189 (Hennadii Stepanov) Pull request description: This PR updates the `minisketch` subtree to latest upstream, which includes: - bitcoin-core/minisketch#75 - bitcoin-core/minisketch#98 ACKs for top commit: fanquake: ACK b10f193 Tree-SHA512: 856fb8b7dc2e743c9c67164023bf53faf8766079aeccc82a30c8b90c85920b31977b6a8b26e51e5485b20e445a3ca6ff806e701a53e95f70181ea30055e3528c
4543a3b Squashed 'src/minisketch/' changes from ea8f66b1ea..d1bd01e189 (Hennadii Stepanov) Pull request description: This PR updates the `minisketch` subtree to latest upstream, which includes: - bitcoin-core/minisketch#75 - bitcoin-core/minisketch#98 ACKs for top commit: fanquake: ACK c235aa468b0dcc67b49340dbe9b675c513cec7bf Tree-SHA512: 856fb8b7dc2e743c9c67164023bf53faf8766079aeccc82a30c8b90c85920b31977b6a8b26e51e5485b20e445a3ca6ff806e701a53e95f70181ea30055e3528c
a12f5de1c Merge bitcoin-core/minisketch#105: refactor: use inline constexpr for ID_TRANS 2ac4b7c62 refactor: use inline constexpr for ID_TRANS 4a179c61e Merge bitcoin-core/minisketch#102: Avoid Clang's `-Wunused-template` under restricted field selections d14cd495f Avoid Clang's `-Wunused-template` under restricted field selections d1bd01e18 Merge bitcoin-core/minisketch#98: misc: drop trailing whitespace fe2c88a4f misc: drop trailing whitespace f74b7e2bc Merge bitcoin-core/minisketch#75: build: Introduce CMake-based build system 850cc868d ci: Add GHA workflow with native Windows job 40d56708c doc: Add "Building with CMake" section to `README.md` a0c86c79a build: Add CMake-based build system ea8f66b1e Merge bitcoin-core/minisketch#89: header: Delete default Minisketch constructor fc2495864 Merge bitcoin-core/minisketch#94: misc: trim trailing whitespace 485b16e7f misc: trim trailing whitespace d1e6bb8bb Merge bitcoin-core/minisketch#92: doc: rename from sipa to bitcoin-core b7b7dd0ec doc: rename from sipa to bitcoin-core eb37a9b8e Merge bitcoin-core/minisketch#87: Avoid copy in self-assign fe6557642 Merge bitcoin-core/minisketch#88: build: Add `-Wundef` 5cc7d2086 header: Delete default Minisketch constructor 8ea298bfa Avoid copy in self-assign 978a3d886 build: Add `-Wundef` 338704417 Merge bitcoin-core/minisketch#86: doc: fix typo in sketch_impl.h 15c2d13b6 doc: fix typo in sketch_impl.h 7be08b8a4 Merge bitcoin-core/minisketch#85: Fixes for integer precision loss 00fb4a4d8 Avoid or make integer precision conversion explicit 9d62a4d27 Avoid the need to cast/convert to size_t for vector operations 19e06cc7a Prevent overflows from large capacity/max_elements 3472e2f5e Merge bitcoin-core/minisketch#81: Avoid overflowing shift by special casing inverse of 1 653d8b2e2 Avoid overflowing shift by special casing inverse of 1 33b7c200b Merge bitcoin-core/minisketch#80: Add c++20 version of CountBits 4a48f31a3 Merge bitcoin-core/minisketch#83: ci: Fix "s390x (big-endian)" task 82b6488ac Add c++20 version of CountBits 0498084d3 ci: Fix "s390x (big-endian)" task 71709dca9 Merge bitcoin-core/minisketch#82: ci: Fix `x86_64-w64-mingw32` task 9e6127fa9 Merge bitcoin-core/minisketch#74: Avoid >> above type width in BitWriter ed420bc17 ci: Fix `x86_64-w64-mingw32` task fe1040f22 Drop -Wno-shift-count-overflow compile flag 154bcd43b Avoid >> above type width in BitWriter 67b87acdb Merge bitcoin-core/minisketch#78: ci: Update macOS image for CI 7de725041 ci: Update macOS image for CI 83d812ea9 Merge bitcoin-core/minisketch#73: ci: Use correct variable to designate C++ compiler e051a7d69 ci: Install wine32 package for Windows tests 2d2c695d7 build: Drop unused `CC` variable 1810fcbd1 ci: Use correct variable to designate C++ compiler 022b95904 Merge bitcoin-core/minisketch#77: Add missing include 08443c489 Add missing include a571ba20f Merge bitcoin-core/minisketch#68: Add missed `#include <string>` b9a7f7e2b Merge bitcoin-core/minisketch#69: refactor: Drop unused `total` local variables 8a5af94ed Merge bitcoin-core/minisketch#70: build: Remove `-Qunused-arguments` workaround for clang + ccache c36f1f03a Merge bitcoin-core/minisketch#72: Fix MSVC implementation of `CountBits()` function 0078bedda Ignore `HAVE_CLZ` macro when building with MSVC 1c772918c Fix MSVC implementation of `CountBits()` function 98f87c55f build: Remove `-Qunused-arguments` workaround for clang + ccache 11a1e25c8 refactor: Drop unused `total` local variables ed6c8fcfd Add missed `#include <string>` 47f0a2d26 Merge bitcoin-core/minisketch#66: msvc: remove direct Bitcoin Core `compat.h` include 64f17584c msvc: remove Core compat.h include git-subtree-dir: src/minisketch git-subtree-split: a12f5de1c96e21d76f64bc647ae4f65e4fc1b636
This PR introduces a new CMake-based build system, which can be reused in downstream projects, including Bitcoin Core.
Additionally, a GitHub Actions CI task for MSVC and clang-cl has been added, following this feedback.
Autotools vs CMake configuration option parity
--disable-ccache--enable-tests-DMINISKETCH_BUILD_TESTS--enable-benchmark-DMINISKETCH_BUILD_BENCHMARK--enable-fields=,-separated list-DMINISKETCH_FIELDS=;-separated list-DMINISKETCH_INSTALLNotes on the implementation
The default
CMAKE_BUILD_TYPEis left unset.CMake's per-configuration compiler flags are not modified. As a result, they may include
-DNDEBUG.The target name
testis reserved. Therefore, the testing binary has been renamed totest-noverify. Alternatively, following the naming used in thelibsecp256k1repo, the test binaries could be renamed as:test-->noverify_teststest-verify-->verify_tests