[CMake] custom target not working on windows

Marc Schafer winddummy at gmail.com
Fri Jul 31 08:42:10 EDT 2009


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:

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
)

This works fine on Linux and Mac with the make generator but does not work
on Windows XP with the Visual studio 2008 generator.  From the build log
file, I can see that a batch file is getting generated with two commands:
one to run ant and the other to do the copy.  When the batch file is run,
the ant command works fine, but the copy never seems to happen.  My library
fails to build because it can't find messages.h even though it does exist in
${DICTIONARY_DIR}/c/messages.h

Here is the copy command from the generated batch file:
"C:\Program Files\CMake 2.6\bin\cmake.exe" -E copy_if_different
"C:/Documents and Settings/mschafer/My
Documents/foamcut/java/MessageGenerator/dictionary/c/messages.h"
"C:/Documents and Settings/mschafer/My
Documents/build_foamcut/include/messages.h"

If I run this from a command prompt, it also works fine and then the library
will build.

Visual does not report any errors.  Can anybody help me figure out why the
copy is not happening on one platform but works on the others?

Thanks,
Marc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090731/e9f52d05/attachment.htm>


More information about the CMake mailing list