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

ecbuild_print_summary reports options according to last project only #65

Open
reuterbal opened this issue Sep 13, 2024 · 2 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@reuterbal
Copy link

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:

cmake_minimum_required( VERSION 3.20 FATAL_ERROR )
find_package( ecbuild 3.4 REQUIRED )

project( proja LANGUAGES NONE VERSION 0.2 )
ecbuild_add_option(
    FEATURE MYFEATURE
    DEFAULT ON
)

project( projb LANGUAGES NONE VERSION 0.1 )
ecbuild_add_option(
    FEATURE MYFEATURE
    DEFAULT OFF
)

ecbuild_print_summary()

Dependent on setting the value of the variables ENABLE_MYFEATURE, PROJA_ENABLE_MYFEATURE or PROJB_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.:

$ cmake <...> -DENABLE_MYFEATURE=ON
[...]
-- ---------------------------------------------------------
-- [proja] (0.2)
-- Feature TESTS enabled
-- Feature PKGCONFIG enabled
-- Feature MYFEATURE enabled
-- ---------------------------------------------------------
-- [projb] (0.1)
-- Feature TESTS enabled
-- Feature PKGCONFIG enabled
-- Feature MYFEATURE enabled
-- ---------------------------------------------------------
-- Build summary
-- ---------------------------------------------------------
[...]
-- The following features have been enabled:

 * TESTS, proja: Enable the unit tests, projb: Enable the unit tests
 * PKGCONFIG, proja: Enable ecbuild_pkgconfig, projb: Enable ecbuild_pkgconfig
 * MYFEATURE, proja: , projb:

But is wrong when they have a different value, e.g., in the following example proja has the option disabled:

$ cmake .. -DENABLE_MYFEATURE=OFF -DPROJB_ENABLE_MYFEATURE=ON
[...]
-- ---------------------------------------------------------
-- [proja] (0.2)
-- Feature TESTS enabled
-- Feature PKGCONFIG enabled
-- ---------------------------------------------------------
-- [projb] (0.1)
-- Feature TESTS enabled
-- Feature PKGCONFIG enabled
CMake Warning at /usr/local/apps/ecbuild/3.8.3/share/ecbuild/cmake/ecbuild_log.cmake:162 (message):
  WARN - Both ENABLE_MYFEATURE and PROJB_ENABLE_MYFEATURE are set for
  feature MYFEATURE.  Using PROJB_ENABLE_MYFEATURE=ON
Call Stack (most recent call first):
  /usr/local/apps/ecbuild/3.8.3/share/ecbuild/cmake/ecbuild_add_option.cmake:172 (ecbuild_warn)
  CMakeLists.txt:13 (ecbuild_add_option)


-- Feature MYFEATURE enabled
-- ---------------------------------------------------------
-- Build summary
-- ---------------------------------------------------------
[...]
-- The following features have been enabled:

 * TESTS, proja: Enable the unit tests, projb: Enable the unit tests
 * PKGCONFIG, proja: Enable ecbuild_pkgconfig, projb: Enable ecbuild_pkgconfig
 * MYFEATURE, proja: , projb:

Or the other way round:

$ cmake .. -DENABLE_MYFEATURE=ON -DPROJB_ENABLE_MYFEATURE=OFF
[...]
-- ---------------------------------------------------------
-- [proja] (0.2)
-- Feature TESTS enabled
-- Feature PKGCONFIG enabled
-- Feature MYFEATURE enabled
-- ---------------------------------------------------------
-- [projb] (0.1)
-- Feature TESTS enabled
-- Feature PKGCONFIG enabled
CMake Warning at /usr/local/apps/ecbuild/3.8.3/share/ecbuild/cmake/ecbuild_log.cmake:162 (message):
  WARN - Both ENABLE_MYFEATURE and PROJB_ENABLE_MYFEATURE are set for
  feature MYFEATURE.  Using PROJB_ENABLE_MYFEATURE=OFF
Call Stack (most recent call first):
  /usr/local/apps/ecbuild/3.8.3/share/ecbuild/cmake/ecbuild_add_option.cmake:172 (ecbuild_warn)
  CMakeLists.txt:13 (ecbuild_add_option)


-- ---------------------------------------------------------
-- Build summary
-- ---------------------------------------------------------
[...]
-- The following features have been disabled:

 * MYFEATURE, proja: , projb:

Version

3.8.3

Platform (OS and architecture)

Atos AC

Relevant log output

No response

Accompanying data

No response

Organisation

ECMWF

@reuterbal reuterbal added the bug Something isn't working label Sep 13, 2024
@marcosbento
Copy link
Collaborator

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:

* MYFEATURE, proja(✅): '', projb(❌): ''

...snip...
  • for cmake .. -DENABLE_MYFEATURE=OFF -DPROJB_ENABLE_MYFEATURE=ON
...snip...
-- ---------------------------------------------------------
-- Feature summary
-- ---------------------------------------------------------
-- The following features have been enabled:

* MYFEATURE, proja(❌): '', projb(✅): ''

...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?

@marcosbento marcosbento self-assigned this Oct 31, 2024
marcosbento added a commit that referenced this issue Oct 31, 2024
- Add enabled/disabled features marker in project summary
- Force once enabled features to be displayed as enabled, regardless of
  of any disabled use

Re Github #65
marcosbento added a commit that referenced this issue Oct 31, 2024
- Add enabled/disabled features marker in project summary
- Force once enabled features to be displayed as enabled, regardless of
  of any disabled use

Re Github #65
marcosbento added a commit that referenced this issue Oct 31, 2024
- Add enabled/disabled features marker in project summary
- Force once enabled features to be displayed as enabled, regardless of
  of any disabled use

Re Github #65
marcosbento added a commit that referenced this issue Oct 31, 2024
- Add enabled/disabled features marker in project summary
- Force once enabled features to be displayed as enabled, regardless of
  of any disabled use

Re Github #65
marcosbento added a commit that referenced this issue Oct 31, 2024
- Add enabled/disabled features marker in project summary
- Force once enabled features to be displayed as enabled, regardless of
  of any disabled use

Re Github #65
@wdeconinck
Copy link
Member

@reuterbal this should now have been added to the develop branch and will be released in the coming week

wdeconinck added a commit that referenced this issue Nov 18, 2024
* gh/release/3.9.0:
  Version 3.9.0
  Add downstream ci (#72)
  Fix ecbuild_disable_unused_feature
  Add workflow to check release version is correct (#54)
  Add ecbuild_override_compiler_flags macro
  Add utility to initialise overrideable compiler flags
  Add utility to purge compiler flags for a given language
  Add tests according to Github issue #65
  Enable distinction between enabled/disabled features
  Update ci action to v2 (#68)
  Stricter match condition for _fail strings (#64)
  CPP out LOC calls for NAG.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants