I would like to know if anyone here has managed to use CMake to build a precompiled header in a single location within a project and then use it from that location to build the other libraries and executables of the project. The only way I have managed to do this is to copy the pch file manually in each library/executable folder but I want to avoid having to do this because it takes a lot of space and time.
Say I have this project structure
root
| include
- precompiled.h
- common_project_header_files
| src
| precompiled
- precompiled.cc
| lib1
- source/header files for lib1
| lib2
- source/header files for lib2
| lib
I would like to first build precompiled.pch using precompiled.h and precompiled.cc (which only includes precompiled.h) in a location visible to the libraries' files and then use it from there to build lib1 and lib2.
Can this be done using CMake?