[CMake] Generating Source Files
Jeremy Cowgar
jeremy at cowgar.com
Wed Apr 8 13:09:15 EDT 2009
Bill Hoffman wrote:
> So, you create a custom command that runs your parser and creates a
> full CMakeLists.txt file to build the output of the parser. Then run
> ctest --build-and-test on that directory to build the parser output.
> What is the output of the parser? Is it a program or a library, or both?
The output of the parser is simply .c/.h files that are then compiled
with CMake to create the executable (linked with other existing .c/.h
files and libs).
I do not want to require CMake CVS, because I want people who download
my app to be able to compile the sources. I do not want them to have to
install CVS copies of CMake. Here is how it works from the command line...
$ euc -outdir interpreter parser.e
... builds ...
$ ls interpreter
parser.c main.c main.h regex.c sequence.c value.c
$
The translator/generator always generates main.c. So, I can depend on
that. But the others I must dynamically place into a CMake variable for
later use as:
ADD_EXECUTABLE( myapp ${GENERATED_SOURCE_LIST} )
That's all I am doing. The original CMake file I wrote did a FILE( GLOB
GENERATED_SOURCE_LIST interpreter/*.c ) ... and this worked fine if you
invoked make twice. i.e. the first time it saw that a custom command
needed to be run, it ran it. However, the FILE( GLOB ... ) was empty
because it ran before the generator ran. Thus, the compile failed
because of all sorts of missing files. Run make again, and this time the
FILE( GLOB ... ) was populated correctly because the C files where in
the dir. The app the builds great.
Jeremy
More information about the CMake
mailing list