cmake: Adjust build option defaults#196
Conversation
| option(BUILD_UTIL "Build bitcoin-util executable." ON) | ||
|
|
||
| option(BUILD_TESTS "Build test_bitcoin executable." ON) | ||
| option(BUILD_TX "Build bitcoin-tx executable." ${BUILD_TESTS}) |
There was a problem hiding this comment.
This expands BUILD_TESTS to control (by default) whether to build test_bitcoin, bitcoin-tx, bitcoin-util, bitcoin-wallet, bench_bitcoin and fuzz.
Those are beyond the scope of "tests" and so using BUILD_TESTS to control them is confusing. One way to avoid this is to not have the dependency and have each option be independent of the others (ditch this PR, I think it is like this with autotools?).
Or if we insist on having all those being controlled by one option (for convenience?), then maybe introduce a new meta option BUILD_EXTRA that turns ON/OFF all of BUILD_TESTS (maybe BUILD_UNIT_TESTS is a better name because there are also functional tests and benchmark tests and fuzz tests), BUILD_TX, BUILD_UTIL, BUILD_WALLET_TOOL, BUILD_BENCH, BUILD_FUZZ_BINARY.
There was a problem hiding this comment.
We decided (on this week's call) on this approach because the functional tests depend on these binaries and silently skip tests if they're not present. It's not ideal, but we agreed it's better than the alternative.
There was a problem hiding this comment.
A new angle on this:
Having in mind the problem that if the user compiles without e.g. bitcoin-tx, then some functional tests will be skipped.
Before this PR: BUILD_TX is ON, so the problem does not exist if the user uses the defaults and does not fiddle with the options. The problem arises if they explicitly set BUILD_TX is OFF.
After this PR: same as above, so this PR brings no improvement?
However, there is an undesirable side effect with this PR: if BUILD_TESTS is set to OFF, then automatically BUILD_TX will be turned to OFF as well.
Maybe it would be better if each option is kept independent. Then if BUILD_TX is explicitly changed from its default ON to OFF, then emit a warning during configure: "some functional tests will be skipped without bitcoin-tx".
There was a problem hiding this comment.
Two other objections to this:
-
In
bitcoindwe have some options turn on/off other options. This is oftentimes complicated and difficult to asses what will happen if a given option is changed. It is hard on both ends - from the user's perspective and from developer's perspective when changing the code. I think it is better to keep it simple stupid and avoid having one option flip the value of another, which is more aligned with https://en.wikipedia.org/wiki/Principle_of_least_astonishment. -
"Full execution of functional tests" and "Whether to build unit tests executable" are unrelated and tying them together would be odd.
There was a problem hiding this comment.
I still disagree with this as I'd rather err on the side of "whoops, I built an extra binary but all the tests got run".
| @@ -65,8 +65,11 @@ include(CMakeDependentOption) | |||
| option(BUILD_DAEMON "Build bitcoind executable." ON) | |||
| option(BUILD_GUI "Build bitcoin-qt executable." OFF) | |||
| option(BUILD_CLI "Build bitcoin-cli executable." ON) | |||
There was a problem hiding this comment.
bitcoin-cli is also referenced from the functional tests. Shouldn't it also be treated like the others, e.g. bitcoin-tx?
There was a problem hiding this comment.
I'd keep it ON by default and, as you said, independently from tests.
| option(BUILD_UTIL "Build bitcoin-util executable." ON) | ||
|
|
||
| option(BUILD_TESTS "Build test_bitcoin executable." ON) | ||
| option(BUILD_TX "Build bitcoin-tx executable." ${BUILD_TESTS}) |
There was a problem hiding this comment.
A new angle on this:
Having in mind the problem that if the user compiles without e.g. bitcoin-tx, then some functional tests will be skipped.
Before this PR: BUILD_TX is ON, so the problem does not exist if the user uses the defaults and does not fiddle with the options. The problem arises if they explicitly set BUILD_TX is OFF.
After this PR: same as above, so this PR brings no improvement?
However, there is an undesirable side effect with this PR: if BUILD_TESTS is set to OFF, then automatically BUILD_TX will be turned to OFF as well.
Maybe it would be better if each option is kept independent. Then if BUILD_TX is explicitly changed from its default ON to OFF, then emit a warning during configure: "some functional tests will be skipped without bitcoin-tx".
| @@ -65,8 +65,11 @@ include(CMakeDependentOption) | |||
| option(BUILD_DAEMON "Build bitcoind executable." ON) | |||
| option(BUILD_GUI "Build bitcoin-qt executable." OFF) | |||
There was a problem hiding this comment.
Currently, in master, we build bitcoin-qt by default, what's the reasoning behind this to be changed?
There was a problem hiding this comment.
During our calls, we discussed the concept of build options. We have reached a rough consensus to make them "opt-in" rather than "opt-out" as much as possible.
4d4cf13 to
8bb7538
Compare
| "cacheVariables": { | ||
| "VCPKG_TARGET_TRIPLET": "x64-windows", | ||
| "BUILD_GUI": "ON", | ||
| "BUILD_BENCH": "ON", |
|
I'm afraid we could bikeshed these forever. IMO it's good enough for a first pass, and we'll learn quickly post-merge if people are upset/confused. |
|
Rebased to resolve a conflict. @theuni's #196 (comment) has been addressed. |
This PR adjusts build option defaults per the discussion during today's call.