[CMake] Compiled file cannot be executed

Swaroop Ramachandra swaroopgr at gmail.com
Wed Aug 26 18:58:11 EDT 2009


Hi,

I'm trying to do the following in my CMake file:

1. Generate a "xyz.txt" file
2. Compile a "generate.c" file to give out a  "generate" binary in my bin
directory.
3. Execute the "generate" binary (The binary just reads contents of
"xyz.txt" and creates a copy of "xyz.txt"using read() and write() functions
in C)

The problem:
When I do a fresh build, 1 and 2 succeed. 3 fails with the following error
*"bin/generate: Command not found"*

However, if I *re-run the build immediately* after, since the "generate"
binary is already created, all 3 successfully execute. Here's a snippet of
what I have written.

------------
------------
/*---- Code to generate xyz.txt -- Successfully generated each time------*/
----------
---------
ADD_EXECUTABLE(generate ${CMAKE_CURRENT_SOURCE_DIR}/server/generate.c)

set(GEN ${CMAKE_BINARY_DIR}/bin/generate)

ADD_CUSTOM_COMMAND(
   TARGET generate POST_BUILD
   COMMAND ${GEN}
   DEPENDS ${CMAKE_BINARY_DIR}/server/xyz.txt}
   )
In my ADD_CUSTOM_COMMAND, I have specified POST_BUILD, which I understood to
be that the command will be executed only after creation of the "generate"
binary.

Any help is greatly appreciated. Thank you in advance for your time.

Regards,
Swaroop
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090826/2b748d3e/attachment.htm>


More information about the CMake mailing list