[CMake] Converting xml-Files during build

Timo Penndorf Timo.Penndorf at tu-dresden.de
Mon Aug 18 08:24:20 EDT 2008


Hello,

I try to convert the build process of my project from gnu make to cmake.
During the build (of a shared library) I have to convert an additional
xml-File from one xml-language to another. Therefor I use a
xsl-stylesheet and 'xsltproc'.

The gnu make rule looks like this

$(BUILD_DIR)/%.xmlt:	%(SOURCE_DIR)/%.xmls
			xsltproc converter.xsl %< > $@

The file types xmlt and xmls just distinguish between source and target
xml languange.

Now my question is, how can I create such a build rule with cmake.

I tried (with 'cp' just to get it work...)


ADD_CUSTOM_COMMAND(OUTPUT $(CMAKE_BUILD_DIR)/file.xmlt
                   COMMAND cp ${CMAKE_SOURCE_DIR}/file.xmlt
                              $(CMAKE_BUILD_DIR)/file.xmls
                   MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/file.xmlt
                   COMMENT "Create xml file")

but it does not work.

One problem is that the source xml file can be changed without changing
the source code of the project. In this case the target xml file has
be rebuilt. 


Timo





More information about the CMake mailing list