Best practice for a library with multiple language bindings: target definitions with compile_features

I develop a library with language bindings for c, c++, and Fortran. The library c++ bindings require cxx_std_17 features.

If I create the shared library target and use target_compile_features(XYZ PUBLIC cxx_std_17) and export the target for use by other projects, then those projects must activate the CXX language even if they are pure Fortran. That is, a pure Fortran project must use

project(my-fortran-app LANGUAGES Fortran CXX)
find_package(XYZ)

where XYZ is my library. It seems like the CXX in the project command should not be necessary. However, it if is not there CMake gives the error: Cannot use features from non-enabled language CXX

Am I missing something? How should the XYZ package create and export its targets to avoid this? Should multiple targets, one for each language binding, be created?

If the C++17 requirement is for the library itself only, then you should set the compile feature privately: target_compile_features(XYZ PRIVATE cxx_std_17)

I now see that this issues has been identified and discussed on the gitlab issues:

https://gitlab.kitware.com/cmake/cmake/-/issues/20438

It seems there is currently no fix for this, but it is a known issue.