Skip to content

target_compile_features: Do not fail on features for non-enabled languages

Brad King requested to merge brad.king/cmake:compile-features-non-enabled into master

If a project exports a shared library that exports both a C and C++11 interface, it can use INTERFACE_COMPILE_FEATURES cxx_std_11 so that consumers activate C++11 support in their C++ compiler. However, if a consuming application uses only the C interface it might not enable the CXX language at all. It should not be an error to link to the library from that application to use the C interface just because a CXX feature happens to be mentioned.

For now we retain the existing error when $<COMPILE_FEATURES:...> is used with a feature from a non-enabled language. Add a (previously missing) test case to verify that error still occurs.

Fixes: #20438

Edited by Brad King

Merge request reports