PCH: Precompiled header not found when reusing PCH in combination with COMPILE_PDB_NAME
project(Test LANGUAGES CXX)
add_library(lib lib.cxx)
target_precompile_headers(lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/pch.h)
add_executable(exec exec.cxx)
target_precompile_headers(exec REUSE_FROM lib)
set_target_properties(exec PROPERTIES COMPILE_PDB_NAME "my")
When building the script with Visual Studio I get the following error:
C:\cygwin64\home\daniel.eiband\test\playground\exec.cxx : fatal error C1083: Cannot open precompiled header file: 'C:/cygwin64/home/daniel.eiband/test/build/lib.dir/Debug/cmake_pch.pch': No such file or directory
Most likely the precompiled header was removed by a MSBuild target which couldn't locate the PDB.
Edited by Daniel Eiband