[CMake] Configured C header dependency problem

Alexander Neundorf a.neundorf-work at gmx.net
Wed Jul 28 14:54:58 EDT 2010


On Wednesday 28 July 2010, Óscar Fuentes wrote:
> Eric Noulard <eric.noulard at gmail.com> writes:
> > 2010/7/28 Óscar Fuentes <ofv at wanadoo.es>:
> >> I'm using cmake 2.8.2 on Linux/make and on Windows/make-mingw32
> >>
> >> The project configures a template config.cmake producing config.h. That
> >> header is included by all C files on the project.
> >>
> >> While building in-source, touching config.h only triggers the rebuild if
> >> config.h is included as
> >>
> >> #include "config.h"
> >>
> >> but not as
> >>
> >> #include <config.h>
> >>
> >> While building out of source, touching config.h does not trigger the
> >> rebuild of the C files not matter how the header is used.
> >>
> >> Touching any other header file triggers the rebuild of the corresponding
> >> C source files.
> >>
> >> The project follows the pattern
> >>
> >> platform macros
> >> configure config.cmake -> config.h (using configure_file)
> >> add_subdirectory
> >> add_executable(foo file1.c file2.c ...)
> >
> > Did you try adding the  config.h to your list of files in add_executable
> > ?
> >
> > Do not forget to
> > set_source_files_properties(config.h PROPERTIES GENERATED TRUE)
>
> Thanks for the suggestions. Just tried them, separately and combined. No
> change.
>
> OTOH, I would expect from configure_file to automatically do that, and
> from the depedency scanner to detect config.h.
>
> >> This is what I do on other projects, without problems. Any suggestion?
> >
> > May be config.h is found in some add_executable/add_library for
> > those project?
>
> Nope.
>
> In the C.includescache file config.h is mentioned, twice. So the
> dependency scanner detects the file, but then it is ignored. The
> config.h file is in D:/dev/other/emacs/qbuild/src/config.h (the build
> directory.) This is an excerpt of C.includescache:
>
> D:/dev/other/emacs/git/src/alloc.c
> config.h
> D:/dev/other/emacs/git/src/config.h

This looks like it decided for D:/dev/other/emacs/git/src/config.h instead of 
D:/dev/other/emacs/qbuild/src/config.h .
What's the exact compile command (from make VERBOSE=1) ?

Alex


More information about the CMake mailing list