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: Switch from tri-state options to boolean. Stage ONE #161

Merged
merged 7 commits into from
Apr 22, 2024

Conversation

hebasto
Copy link
Owner

@hebasto hebasto commented Apr 21, 2024

This PR partially pulled from #83 with options, which default values seem non-controversial.

As a bonus, the help string duplication in depends/toolchain.cmake.in has been eliminated for the touched lines.

The Autotools vs CMake Feature Parity Table has been updated as well.

Copy link

@vasild vasild left a comment

Choose a reason for hiding this comment

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

Approach ACK d66f911

@@ -227,7 +227,7 @@ jobs:

- name: Generate build system
run: |
cmake -B build -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 -DBoost_INCLUDE_DIR="${PWD}/${{ matrix.conf.boost_archive }}" -DENABLE_WALLET=ON -DWITH_EXTERNAL_SIGNER=ON -DWITH_MINIUPNPC=ON -DWITH_NATPMP=ON -DWITH_ZMQ=ON -DWITH_USDT=ON -DWERROR=ON
cmake -B build --preset ci-linux -DWITH_GUI=OFF -DBoost_INCLUDE_DIR="${PWD}/${{ matrix.conf.boost_archive }}"
Copy link

Choose a reason for hiding this comment

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

I would expect commit a12b692 cmake: Add CI-specific presets to just move options from the command line to the presets file, however this is not the case. I guess this is unintentional, or the commit message needs to be more elaborate on why those changes are made:

  • removed from the command line, but not added to the presets file:
    • -DCMAKE_C_COMPILER=gcc-11
    • -DCMAKE_CXX_COMPILER=g++-11
    • -DENABLE_WALLET=ON
  • added to the command line, not in the presets file before or after this commit (for Linux):
    • -DWITH_GUI=OFF -- why not have it in the ci-linux preset?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I would expect commit a12b692 cmake: Add CI-specific presets to just move options from the command line to the presets file, however this is not the case.

Thanks! Reworked to meet expectations.

Copy link

Choose a reason for hiding this comment

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

Thanks! Do you think it makes sense to have all options in the presents file, so that they are not scattered between the command line and the presets file? Or would that be too un-flexible?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I'm not sure. However, it won't affect flexibility, because there will be an opportunity to override any option in the command line.

Comment on lines +143 to +144
if("@no_upnp@")
set(WITH_MINIUPNPC OFF CACHE BOOL "")
Copy link

Choose a reason for hiding this comment

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

I am not sure how those "@no_foo@" are generated, but there is some inconsistency between upnp and the others. For example, CMakeLists.txt defines WITH_NATPMP and in depends/toolchain.cmake.in the check is using no_natpmp. But for upnp: CMakeLists.txt: WITH_MINIUPNPC, depends/toolchain.cmake.in: no_upnp.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I am not sure how those "@no_foo@" are generated...

bitcoin/depends/Makefile

Lines 288 to 298 in d66f911

-e 's|@no_qt@|$(NO_QT)|' \
-e 's|@no_qr@|$(NO_QR)|' \
-e 's|@no_zmq@|$(NO_ZMQ)|' \
-e 's|@no_wallet@|$(NO_WALLET)|' \
-e 's|@no_bdb@|$(NO_BDB)|' \
-e 's|@no_sqlite@|$(NO_SQLITE)|' \
-e 's|@no_upnp@|$(NO_UPNP)|' \
-e 's|@no_natpmp@|$(NO_NATPMP)|' \
-e 's|@no_usdt@|$(NO_USDT)|' \
-e 's|@no_harden@|$(NO_HARDEN)|' \
-e 's|@multiprocess@|$(MULTIPROCESS)|' \

... but there is some inconsistency between upnp and the others. For example, CMakeLists.txt defines WITH_NATPMP and in depends/toolchain.cmake.in the check is using no_natpmp. But for upnp: CMakeLists.txt: WITH_MINIUPNPC, depends/toolchain.cmake.in: no_upnp.

You mean, WITH_MINIUPNPC should be renamed to WITH_UPNP?

Copy link

Choose a reason for hiding this comment

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

You mean, WITH_MINIUPNPC should be renamed to WITH_UPNP?

Either this or change the above to -e 's|@no_miniupnpc@|$(NO_MINIUPNPC)|'. No strong opinion, but it is nice to be more consistent.

Copy link

@vasild vasild left a comment

Choose a reason for hiding this comment

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

ACK df4e46b

@hebasto hebasto merged commit a012404 into cmake-staging Apr 22, 2024
30 checks passed
tristate_option(WITH_MINIUPNPC "Enable UPnP." "if libminiupnpc is found." AUTO)
tristate_option(WITH_ZMQ "Enable ZMQ notifications." "if libzmq is found." AUTO)

option(WITH_NATPMP "Enable NAT-PMP." OFF)

Choose a reason for hiding this comment

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

Aren't we meant to be reming these, or is that happening at a later point?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yes, I'm going to rename all options at once at a later point.


option(WITH_ZMQ "Enable ZMQ notifications." OFF)
if(WITH_ZMQ)
if(VCPKG_TARGET_TRIPLET)

Choose a reason for hiding this comment

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

Why is vcpkg being carved out here? Can just use the same logic for both until we can use the new logic?

Copy link
Owner Author

Choose a reason for hiding this comment

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

The find_package(ZeroMQ CONFIG) invocation is recommended by the vcpkg. I didn't test pkg-config approach for it.

@@ -189,12 +135,13 @@ else()
endif()

if(WITH_GUI AND WITH_QRENCODE)
if(MSVC)
if(VCPKG_TARGET_TRIPLET)

Choose a reason for hiding this comment

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

Why was this changed?

Copy link
Owner Author

Choose a reason for hiding this comment

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

This makes an intention clearer because the logic is specific to vcpkg package manager, not to the MSVC compiler.

Choose a reason for hiding this comment

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

Is anyone using MSVC without vcpkg? Is this being done consistently?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Is anyone using MSVC without vcpkg?

I don't think so. But vcpkg might be used on other OSes.

Is this being done consistently?

I hope it is consistent now in the staging branch.

hebasto added a commit that referenced this pull request May 1, 2024
5de23c7 fixup! cmake: Add preset for MSVC build (Hennadii Stepanov)
09b1d5b fixup! ci: Test CMake edge cases (Hennadii Stepanov)
820a538 cmake [KILL 3-STATE]: Switch `WITH_QRENCODE` to boolean w/ default ON (Hennadii Stepanov)
017aeda cmake [FIXUP]: Move `find_program(brew)` out from introspection file (Hennadii Stepanov)

Pull request description:

  This PR is a continuation of #161, #162 and #164 and tackles with the `WITH_QRENCODE`  options.

  It becomes enabled when building GUI with the default value `ON`.

Top commit has no ACKs.

Tree-SHA512: 9cd923ef89e0a485330205db4389e42c001cbd6683a14b1e0c665d8e790e8bb2cae7b8b1929818443aea8eb5cbf6cafa79f4e44f41a893f54a5cdc09abc49dc1
hebasto added a commit that referenced this pull request May 1, 2024
598eda8 cmake [KILL 3-STATE]: Switch `WITH_USDT` to boolean w/ default OFF (Hennadii Stepanov)
f3c2fea fixup! cmake: Add `systemtap-sdt` optional package support (Hennadii Stepanov)

Pull request description:

  Same as #161, but USDT-specific with refactoring of the USDT search logic into its own "FindUSDT" module.

  The first commit is a pure refactoring.

Top commit has no ACKs.

Tree-SHA512: 2d67c7e72509fc78eb906a8af93e7525b8125bdeb38a5f45ceda1c0c75f300c74501402c39d8d17de2585b2ed2939de0009a33231d1164438ce929236d4b742a
@hebasto hebasto added this to the UI, 23th May milestone May 1, 2024
hebasto added a commit that referenced this pull request May 4, 2024
2b4ad50 cmake [KILL 3-STATE]: Switch `WITH_{SQLITE,BDB}` to boolean (Hennadii Stepanov)

Pull request description:

  This PR is a continuation of #161 and #162 and tackles with the `WITH_SQLITE` and `WITH_BDB` options.

  For the latter the default value `OFF` is suggested.

  The #83 (comment):
  > Shouldn't `WITH_SQLITE=ON` imply `ENABLE_WALLET`? What (extra) does `ENABLE_WALLET` do here? I'm not sure we'll actually want to keep it as an option.

  has been addressed.

ACKs for top commit:
  TheCharlatan:
    ACK 2b4ad50

Tree-SHA512: 13d5bd16709ab557ee736696fe1d5d3fe64bae8cb77c000401c26b8be2deab0473474f7fa9bb958884ba3ab9c4d0b66e44766ca5c1c86d0fab3957642ec996b9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants