Skip to content

Make ecbuild_add_lang_flags more verbose about all flags used on failure #121

@Andrew-Beggs-ECMWF

Description

@Andrew-Beggs-ECMWF

Is your feature request related to a problem? Please describe.

This issue has come up a few times in CloudSC where invalid flags are read from a toolchain.cmake file into CMAKE_Fortran_FLAGS. While this is the fault of the user, the first time the error is picked up is typically by ecbuild_add_fortran_flags() as CMake uses try_compile() to validate these flags. This is actually something CMake warns about on the wiki page for the underlying check_fortran_compiler_flag() that ecbuild calls.

Annoyingly this makes it seem like the flag passed to ecbuild_add_fortran_flags() is invalid, instead of the flag from the toolchain.cmake file.

Describe the solution you'd like

Could ecbuild_add_lang_flags() add variables such as CMAKE_<LANG>_FLAGS to its error message? Ideally I'd like to have the error message from the try_compile(), but this is wrapped by check_fortran_compiler_flag() and so we only get the boolean result of pass/fail. I think this might be sufficient to prompt the user to look at all flags vs just the one they were attempting to add.

I'm fine to add this change/a variation of it myself if approved.

Describe alternatives you've considered

  • Error message from the compiler
    • Not feasible, see above

Additional context

No response

Organisation

ECMWF

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions