Skip to content
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

cmake: Amend bitcoin_crypto static library #172

Merged
merged 1 commit into from
May 1, 2024
Merged

Conversation

hebasto
Copy link
Owner

@hebasto hebasto commented Apr 26, 2024

Avoid using source-specific compile options. They hard to reason about and error-prone when combining with target-specific compile options.

The resulted build logic effectively mirrors the master branch's one.

Required for #157.

Similar to #171.

Avoid using source-specific compile options. They hard to reason about
and error-prone when combining with target-specific compile options.

The resulted build logic effectively mirrors the master branch's one.
target_compile_definitions(bitcoin_crypto
PRIVATE
ENABLE_SSE41
add_library(bitcoin_crypto_sse41 STATIC EXCLUDE_FROM_ALL
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as #171. Would OBJECT libraries be better here?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as #171 (comment) :)

Yes, it could. But CMake's developers recommend to use STATIC libraries if there is no compelling reasons for OBJECT ones. For example, from Professional CMake: A Practical Guide 18th Edition

Prefer defining static libraries over object libraries. Static libraries are simpler, have more
complete and robust support from earlier CMake versions and they are well understood by most
developers. Object libraries have their uses, but they are also less flexible than static libraries.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object libraries have their uses, but they are also less flexible than static libraries.

This is not clear to me. In which ways are they less flexible?

Copy link
Owner Author

@hebasto hebasto May 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object libraries have their uses, but they are also less flexible than static libraries.

This is not clear to me. In which ways are they less flexible?

I think, this part of the quote is not related to us as we use CMake >= 3.22.

Related to https://cmake.org/cmake/help/latest/command/target_link_libraries.html#linking-object-libraries

Copy link
Owner Author

@hebasto hebasto May 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The internal CMake code that handles STATIC libraries is older and more robust than code for OBJECT ones. Sticking to the former type only allows us to have predictable behaviour across the whole codebase.

Copy link

@TheCharlatan TheCharlatan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 5ca0799

@hebasto hebasto merged commit 0c21593 into cmake-staging May 1, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker Required for other steps
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants