[CMake] Generating files during building

Gustavo glab at iol.pt
Thu May 31 19:44:39 EDT 2007


> >> I am not sure the following is necessary if the source files are built
> >> in the same directory where they are needed, but for the case where
> >> source files are built in a different directory (the case for my
> >> generated header), you must have your executable or library target
> >> depend on an empty custom target which in turn depends on your custom
> >> command to insure the source files get built before they need to be
> >> compiled.

I am doing that. Otherwise it will not be included in the dependency graph.

> >> In any case, I do not think multiple invocations of cmake will be
> >> necessary in order to use generated source files.
> >
> > But if I understand correctly then at cmake time the files which will
> > have to be compiled are not yet known, right ?
> > I think this is a problem.

I know their names, since it is just a case of incrementing the number in the 
file's name. The problem is that, should I overcalculate N, make ought to 
complain about a file not found. If I undercalculate it, make will be 
skipping needed files.

The simplified process is something like this:

a.txt -> a.pl
b.txt -> b.pl
...

Processing each of these files:
?.pl -> big_file.isco -> big_file_1.isco, big_file_2.isco, ..., 
big_file_N.isco

Then, for each of these:
big_file_i.isco -> big_file_i.pl -> big_file_i.o

Then the .o files follow the same path as the rest of the "normal" code.

(these are prolog files, btw)

> However, what then is the purpose of the SET_SOURCE_FILES_PROPERTIES
> GENERATED property?  I have never used that flag, but I cannot think of any
> use for it except the present situation.

I'm new to CMake, but I never set this, and all works fine in my generated 
files.

Thank you.
-- Gustavo


More information about the CMake mailing list