[CMake] How does IMPLICIT_DEPENDS work?

Paul Smith paul at mad-scientist.net
Sun Apr 28 21:25:00 EDT 2019


On Sat, 2019-04-27 at 13:49 -0400, Paul Smith wrote:
> On Fri, 2019-04-26 at 17:26 -0400, Paul Smith wrote:
> > We're trying to implement precompiled headers (yes, I've seen all the
> > various github projects around this).  As part of this we need to make
> > sure the precompiled header is rebuilt whenever any of the headers that
> > it includes changes: this seems like exactly the job for
> > add_custom_command's IMPLICIT_DEPENDS.
> > 
> > But, it doesn't seem to be doing anything at all for me so I wonder
> > what I'm doing wrong.
> 
> OK, I figured out the issue.  The problem is a combination of the way I
> was testing and a sort of bizarre "feature" of the CMake Makefile
> generator

I re-confirmed the documented restriction that IMPLICIT_DEPENDS is not
available for non-Makefile generators (e.g., Ninja).

Without this facility it seems impossible to support precompiled
headers in CMake, so I've had to disable PCH for non-Makefile (and non-
MSVC of course) generators.

Is there any chance of getting IMPLICIT_DEPENDS support for Ninja?  Is
the reason that it's not supported because Ninja does its own
dependency management or something like that?  Does anyone know how
it's done?  Is it done by using the compiler flags like -MMD/-MP etc.
or does it have its own built-in facility?



More information about the CMake mailing list