Open reuterbal opened 1 month ago
After a brief investigation, this is apparently one of the shortcomings of CMake feature_summary()
: any particular feature is always assigned to either enabled
or disabled
, independently if it is used otherwise in more that one CMake project. As mentioned in the description of the issue, this is determined by the last value taken by the feature during Project configuration.
ecBuild builds the summary information incrementally, and cannot a priori determine to which group (enabled
or disabled
) the feature will the assigned.
One viable solution could be to let CMake do the usual grouping, while simply including a "marker" to identify if for some projects the feature has been used differently. This would result is having summaries like follows.
For cmake .. -DENABLE_MYFEATURE=ON -DPROJB_ENABLE_MYFEATURE=OFF
...snip...
-- ---------------------------------------------------------
-- Feature summary
-- ---------------------------------------------------------
-- The following features have been enabled:
...snip...
-- The following features have been disabled:
...snip...
- for `cmake .. -DENABLE_MYFEATURE=OFF -DPROJB_ENABLE_MYFEATURE=ON`
...snip...
-- Feature summary
-- The following features have been enabled:
...snip...
A more radical approach would be to force a feature to be grouped as `enabled` if it has been enabled in any project. We would still require a marker to identify projects where it was disabled.
@wdeconinck , @tlmquintino , what do you think would be the approach to follow here?
What happened?
When a build is composed of multiple projects, e.g., as is the case with ecbundle, and more than one project uses an
ecbuild_add_option
with the same feature name, then the option can be toggled individually by setting<PROJ>_ENABLE_<FEATURE>
. However,ecbuild_print_summary
will report the status of these options according to the value of the last project, even if it is different for other projects.What are the steps to reproduce the bug?
Reproducer
CMakeLists.txt
:Dependent on setting the value of the variables
ENABLE_MYFEATURE
,PROJA_ENABLE_MYFEATURE
orPROJB_ENABLE_MYFEATURE
we would expect the option to be enabled for one or the other or both.The output is correct if both options have the same value, e.g.:
But is wrong when they have a different value, e.g., in the following example proja has the option disabled:
Or the other way round:
Version
3.8.3
Platform (OS and architecture)
Atos AC
Relevant log output
No response
Accompanying data
No response
Organisation
ECMWF