[Cmake] Targets, Output Files, Command Lines
William A. Hoffman
billlist at nycap.rr.com
Mon Aug 9 13:28:41 EDT 2004
OK, I think I have found the source of your problems.
You have a case that is not directly covered by cmake or the
cmake book. You have the case where a generator program
is generating multiple source files as output. Currently,
the ADD_CUSTOM_COMMAND command does not directly support more
than one file as output. However, there is a way to do this
in the current cmake. I have added an example of how to do
this in the CMake FAQ, question 2.4:
http://www.cmake.org/Wiki/CMake_FAQ
Basically, you want something like this:
For each of your .g files do something like this:
ADD_CUSTOM_COMMAND(OUTPUT ${bit_streamer_BINARY_DIR}/AddressTableParser.cpp
COMMAND java
ARGS -classpath ${THIRD_PARTY_PATH}lib/vc/antlr.jar antlr.Tool -o ${bit_streamer_BINARY_DIR} ${bit_streamer_SOURCE_DIR}/AddressTable.g
MAIN_DEPENDENCY ${bit_streamer_SOURCE_DIR}/AddressTable.g
)
Then add a dummy custom command for each of the outputs produced by antlr and
have each of them depend on this first output.
ADD_CUSTOM_COMMAND(OUTPUT ${bit_streamer_BINARY_DIR}/AddressTableParser.hpp
COMMAND echo
DEPENDS ${bit_streamer_BINARY_DIR}/AddressTableParser.cpp
)
ADD_CUSTOM_COMMAND(OUTPUT ${bit_streamer_BINARY_DIR}/AddressTableLexer.hpp
COMMAND echo
DEPENDS ${bit_streamer_BINARY_DIR}/AddressTableParser.cpp
)
ADD_CUSTOM_COMMAND(OUTPUT ${bit_streamer_BINARY_DIR}/AddressTableLexer.cpp
COMMAND echo
DEPENDS ${bit_streamer_BINARY_DIR}/AddressTableParser.cpp
)
-Bill
At 10:19 AM 8/9/2004, Andrew Dupont wrote:
>Bill,
>
> Sorry I haven't given you good information up to this point, I
>was basically working blind on trying to produce this Makfile and VS
>project. The .g files are given to antlr and run using a custom command
>that should go to the command prompt. Antlr then produces a list of
>.hpp, .h and a single .txt file, which are needed for the build of the
>bit_streamer. I need to add the dependency on each .g file with all of
>the .hpp and .h outputs so every time the project is built, antlr is
>called and produces the desired header files.
>
>Thanks,
>Andy
More information about the Cmake
mailing list