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