PCH: Linking a C target to a C++ library breaks PCH
In this example:
add_library(foo foo.cpp) add_executable(bar bar.c) target_link_libraries(bar foo) target_precompile_headers(bar PRIVATE "<stddef.h>")
no precompiled header is used for target
bar. The cause is this line that relies on the linker language to decide what language to use for PCH. The linker language can be affected by linked targets and so is not appropriate.