[CMake] custom target not working on windows

Hendrik Sattler post at hendrik-sattler.de
Fri Jul 31 09:18:55 EDT 2009


Zitat von Marc Schafer <winddummy at gmail.com>:

> I have a java program that generates a header file for the C++ shared
> library that I am trying to build with cmake.  The java generator has an ant
> script that runs it but it does not take a destination directory for an
> argument.  Therefore I have to run it and then copy the resulting files into
> my binary directory.  I created the following custom target to do this:

I suggest to do it diffently: copy the source with copy_if_different  
into your build tree and create the .h file there.
If the source files are mentioned in the .xml file, you can use  
configure_file() to create the .xml (in build tree) from an .xml.in  
file (in source tree) and run ant on the result.

> add_custom_target ( generated_messages ALL
>   COMMAND
>   ${ANT_EXECUTABLE} -f ${PROJECT_SOURCE_DIR}/java/MessageGenerator/build.xml
> run
>   COMMAND
>   ${CMAKE_COMMAND} -E copy_if_different ${DICTIONARY_DIR}/c/messages.h
> ${PROJECT_BINARY_DIR}/include/messages.h
> )

Make that a add_custom_command() to get the dependencies right. The  
custom command for the .h file should have the .xml as dependency (see  
above).

HS




More information about the CMake mailing list