-
Notifications
You must be signed in to change notification settings - Fork 59
build: Introduce CMake-based build system #75
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
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.
Hah! Stupid CMake :)
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.
Y2K problem :)
|
Addressed @theuni's comments. |
|
What is the status here? |
I'll push an update shortly. |
3170353 to
77bfe3b
Compare
|
The PR has been updated to improve integration with downstream projects and now makes use of The corresponding Bitcoin Core branch that integrates the new build system is available here. Please note that the current approach does not involve using a project-specific variable to override CMake's function(add_minisketch subdir)
message("")
message("Configuring minisketch subtree...")
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS OFF)
# Hard-code subtree's options.
set(MINISKETCH_INSTALL OFF)
set(MINISKETCH_BUILD_TESTS OFF)
set(MINISKETCH_BUILD_BENCHMARK OFF)
set(MINISKETCH_FIELDS 32)
add_subdirectory(${subdir} EXCLUDE_FROM_ALL)
target_link_libraries(minisketch
PRIVATE
core_interface
)
endfunction()In integration scenarios similar to bitcoin-core/secp256k1#1678, the cc @theuni |
| # Prevent include directories from parent project from leaking into this one. | ||
| set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "") |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
theuni
left a comment
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.
ACK 850cc86.
Once integrated into Core, I propose that we nuke the old buildsystem. I doubt sipa has much interest in supporting both here.
|
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
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