PCH: Precompiled header relative to source directory fails to compile
project(Test LANGUAGES CXX)
add_library(lib lib.cxx)
target_precompile_headers(lib PUBLIC pch.h)
The file pch.h is located next to the file CMakeLists.txt. When building the script with Visual Studio I get the following compile error:
C:/cygwin64/home/daniel.eiband/test/build/CMakeFiles/lib.dir/cmake_pch.hxx(5): fatal error C1083: Cannot open include file: 'pch.h': No such file or directory
The generated file cmake_pch.hxx contains the same relative path:
/* generated by CMake */
#pragma system_header
#ifdef __cplusplus
#include "pch.h"
#endif // __cplusplus
Edited by Daniel Eiband