[CMake] Executing processes as part of a COMMAND option in add_custom_command

J.S. van Bethlehem j.s.van.bethlehem at astro.rug.nl
Thu Apr 14 06:44:42 EDT 2011


Dear users,

As a new user CMake I've come across some things I don't fully 
understand yet. Here is such a thing:
when I build documentation, I want to run some files from a  'demo' 
subdirectory and create output - suppose the (binary) file is called 
'func1_demo', then in my old Makefiles I used to do:
 ./func1_demo >& func1_demo.out
 I implemented this in CMake using a special 'RunCommand.cmake' script 
that does:
   execute_process(COMMAND ${dbin} OUTPUT_FILE ${dbin_out} ERROR_FILE 
${dbin_out})
and the CMakeLists.txt file that creates the demos, has
  ${CMAKE_COMMAND} -Ddbin="./${demo_name}" -Ddbin_out="${demo_name}.out" 
-P RunCommand.cmake
as the COMMAND part of an add_custom_command. It seems a bit contrived, 
having to pass these variables through the command line to a separate 
file. Is there a better way to do this?


Yours sincerely,
Jakob van Bethlehem



More information about the CMake mailing list