Skip to content

cmake: Switch from tri-state options to boolean. Stage ONE#161

Merged
hebasto merged 7 commits into
cmake-stagingfrom
240421-cmake-DV
Apr 22, 2024
Merged

cmake: Switch from tri-state options to boolean. Stage ONE#161
hebasto merged 7 commits into
cmake-stagingfrom
240421-cmake-DV

Conversation

@hebasto
Copy link
Copy Markdown
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
Copy Markdown

@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

Comment thread .github/workflows/cmake.yml Outdated
- 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
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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 thread depends/toolchain.cmake.in
Comment on lines +143 to +144
if("@no_upnp@")
set(WITH_MINIUPNPC OFF CACHE BOOL "")
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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
Copy Markdown

@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

Comment thread CMakeLists.txt
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)
Copy link
Copy Markdown

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
Copy Markdown
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.

Comment thread CMakeLists.txt

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

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
Copy Markdown
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.

Comment thread cmake/optional.cmake

if(WITH_GUI AND WITH_QRENCODE)
if(MSVC)
if(VCPKG_TARGET_TRIPLET)
Copy link
Copy Markdown

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
Copy Markdown
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.

Copy link
Copy Markdown

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
Copy Markdown
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
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