compile_commands.json points to invalid pdb file name "TARGET_COMPILE_PDB" when using shared precompiled headers
When cmake generates compile_commands.json on Windows, it adds the compile option '/FdTARGET_COMPILE_PDB' which is supposed to define the pdb file name. But it looks like the TARGET_COMPILE_PDB variable has not been resolved correctly. That variable is also used in the build.ninja file, where it is assigned the correct file name.
This simple CMakeLists.txt
cmake_minimum_required(VERSION 3.21)
project(test VERSION 1.0.0 LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED 23)
set(CMAKE_CXX_EXTENSIONS OFF)
add_library(pch OBJECT "a.cpp")
target_precompile_headers(pch PRIVATE "pch.h")
add_library(lib OBJECT "b.cpp")
target_precompile_headers(lib REUSE_FROM pch)
add_executable(exe "c.cpp")
target_link_libraries(exe PRIVATE pch lib)
generates three pdb files .../lib.dir/pch.pdb, .../pch.dir/pch.pdb and exe.pdb. The command lines should reference the correct ones.
The resulting command line in compile_commands.json is wrong. Visual Studio Code's "Compile Active File" e.g. will not work.
The entire cmake project: testcase.zip