[Cmake] Generated files, again

Iker Arizmendi iker at research.att.com
Sun, 11 Apr 2004 02:41:50 -0400


Hello all,

I've read through various posting on the mailing
list that describe how to include generated
files in a build but have had no success in getting
them to work.

I have the following problem:

    "gen.c", a file that will take the file "x.in" and
    generate the "x.h" header by redirecting its
    output (eg, "gen x.in >x.h")

    "file1.c" and "file2.c", these files include "x.h"
    and should then go into a library.

Can someone point me to the "best practice" set of
CMake commands to accomplish this?

Regards,
Iker

P.S.
What I thought would have been the cleanest solution:

     ADD_EXECUTABLE(gen gen.c)
     ADD_CUSTOM_COMMAND(TARGET gen
                        POST_BUILD
                        ARGS ${GEN_EXE} ${X_IN} >${X_H})
     ADD_LIBRARY(mylib file1.c file2.c)
     ADD_DEPENDENCIES(mylib gen)

apparently doesn't work because CMake generates a Makefile
where the "file1.c" and "file2.c" dependencies are
listed before the dependency on "gen". This results in
the Makefile trying to build the those files first. Is
there any way to make the dependency on "gen" appear
first?


-- 
Iker Arizmendi
AT&T Labs - Research
Speech and Image Processing Lab
e: iker at research.att.com
w: http://research.att.com