[CMake] How Do I make a Custom Rule.
Peter Kahn
citizenkahn at gmail.com
Mon Oct 2 15:10:35 EDT 2006
What is the right pattern to use in cmake to create a custom rule for
converting a bunch of files?
In make I can define a custome rule for file types.
What is the right way to do this in cmake?
I can create a macro, but I'm unsure how to properly connect it to a
target. I can't seem to put it in a custom target.
Example: automake:
.xml.h:
cat base.xml $< > $.hprep
transmogrify $*.hprep
My Cmake (which doesn't work)
MACRO(GENERATE_H XMLFILES)
SET(BASE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/base.xml)
FOREACH(FILE ${XMLFILES})
# File name without the extension
GET_FILENAME_COMPONENT(TMP_FILENAME ${FILE} NAME_WE)
# the input file might be full path, so handle that
GET_FILENAME_COMPONENT(TMP_FILENAME ${FILE} PATH)
# determine input filename
IF (TMP_FILEPATH)
SET(TMP_PATH ${TMP_FILEPATH}/${TMP_FILENAME}.xml)
ELSE(TMP_FILEPATH)
SET(TMP_PATH ${CONNECTED_SOURCE_DIR}/${TMP_FILENAME}.xml)
ENDIF(TMP_FILEPATH)
# Build the mch file
ADD_CUSTOM_COMMAND(
OUTPUT ${TMP_ PATH}
DEPENDS ${MCH_HEADER}
COMMAND cat
ARGS ${BASE_PATH} ${FILE}
)
# Convert
ADD_CUSTOM_COMMAND(
OUTPUT tmpFile
COMMAND transmogrify
ARGS ${TMP_MCFILE}
)
ENDFOREACH(FILE)
ENDMACRO(GENERATE_H)
--
Peter Kahn
citizenkahn at gmail.com
citizenkahn at jabber80.com, pkahnpie1 at AIM, skype: citizenkahn
http://analogoustendencies.blogspot.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20061002/b80bee59/attachment.htm
More information about the CMake
mailing list