COMPILE_FEATURES: Error on features from non-enabled language
Consider this example:
$ cat ../CMakeLists.txt
cmake_minimum_required(VERSION 3.12)
project(Issue20438 C)
# Simulate imported target from a find_package() call.
# In practice this would be a real library.
add_library(has_CXX_and_C_bindings INTERFACE IMPORTED)
set_property(TARGET has_CXX_and_C_bindings PROPERTY INTERFACE_COMPILE_FEATURES cxx_std_11)
# C-only application
add_executable(main main.c)
target_link_libraries(main PRIVATE has_CXX_and_C_bindings)
$ cmake ..
...
CMake Error in CMakeLists.txt:
Cannot use features from non-enabled language CXX
The client application uses only the C interface from the library and does not compile any C++ code, but cannot use the library due to the mere mention of cxx_*
compile features.
Edited by Brad King