[CMake] Question about add_custom_command

Ingolf Steinbach ingolf.steinbach at googlemail.com
Fri Sep 10 11:25:45 EDT 2010


2010/9/10 Michael Wild <themiwi at gmail.com>:
>> Does this also create dependencies on the multitude of header files
>> included by the .c files in SRCS (which would probably be desired in
>> case of the OP)?
>>
>> Ingolf
>
> No, it will not. But usually you have anyways something like:
>
> set(SRCS a.c b.c c.h d.c e.c)
> set(HDRS a.h b.h c.h d.h e.h)

Which would still fail if some of the .c files also depend on, say, a
headers-only library (C++ templates) from another part of the project.

Isn't there some simple mechanism which
- creates an auto_created.c file
- compiles this auto_created.c file with the default flags for the project
- links the target "foo" using the object files derived from the
"normal" sources and this auto_created.c file
whenever "foo" needs to be re-built (or maybe whenever make enters the
directory containing "foo")?

Maybe there is a way to derive the name of the object files resulting
from SRCS and then have auto_created.c depend on those object files?

Ingolf


More information about the CMake mailing list