larsch / cmake-precompiled-header

Visual Studio and GCC precompiled header macro for CMake
160 stars 42 forks source link

GCC feature #21

Open matthias-p-nowak opened 5 years ago

matthias-p-nowak commented 5 years ago

GCC pre-compiled header found in different folder (Idea)

I got gcc pre-compiled headers to work with a regular makefile and tried your code and played with it. The whole forced include is necessary, if one uses #include "header.h. If one uses #include <header.h> instead, the pre-compiled header file can reside in the build folder, if that directory is included as the first one. Even though the documentation says that header.h and header.h.gch must be in the same directory - this is actually not true. I let cmake create a <target>_inc directory, where I let Ninja put the pre-compiled header. The FORCEINCLUDE is no longer necessary.