PCH: Failure when reusing a PCH from a target with different enabled language
Given:
cmake_minimum_required(VERSION 3.18)
project(test)
file(CONFIGURE OUTPUT pch.c CONTENT "")
file(CONFIGURE OUTPUT hello.cxx CONTENT [=[
int main()
{
printf("hello world\n");
}
]=])
add_library(pch STATIC ${CMAKE_BINARY_DIR}/pch.c)
target_precompile_headers(pch PUBLIC <stdio.h>)
add_executable(hello ${CMAKE_BINARY_DIR}/hello.cxx)
target_precompile_headers(hello REUSE_FROM pch)
Configure will succeed, but building (with Ninja) will fail with:
-- Build files have been written to: C:/Projects/cmake/bugs/pch-missing-lang/build
ninja: error: 'CMakeFiles/pch.dir/cmake_pch.hxx', needed by 'CMakeFiles/hello.dir/hello.cxx.obj', missing and no known rule to make it
Should CMake fail to configure in the first place?