MantisBT - CMake
View Issue Details
0013146CMakeCMakepublic2012-04-19 03:562012-09-03 16:01
Christoph Pramberger 
 
normalminoralways
closedno change required 
LinuxUbuntu12.04
CMake 2.8.7 
 
0013146: ADD_CUSTOM_COMMAND has no OUTPUT / RESULT Variable
Hello!

I want to run a command directly after the target is built. In the documentation I found the "add_custom_command" with the parm "POST_BUILD".

It works fine, but I have one problem with this command, I do not know if the command was executed correctly.

To get this information I would need a RESULT_VARIALBE like that one in "execute_process".

 add_custom_command(OUTPUT output1 [output2 ...]
                     COMMAND command1 [ARGS] [args1...]
                     [COMMAND command2 [ARGS] [args2...] ...]
                     [MAIN_DEPENDENCY depend]
                     [DEPENDS [depends...]]
                     [IMPLICIT_DEPENDS <lang1> depend1 ...]
                     [WORKING_DIRECTORY dir]
                     [COMMENT comment] [VERBATIM] [APPEND])

  execute_process(COMMAND <cmd1> [args1...]]
                  [COMMAND <cmd2> [args2...] [...]]
                  [WORKING_DIRECTORY <directory>]
                  [TIMEOUT <seconds>]
                  [RESULT_VARIABLE <variable>]
                  [OUTPUT_VARIABLE <variable>]
                  [ERROR_VARIABLE <variable>]
                  [INPUT_FILE <file>]
                  [OUTPUT_FILE <file>]
                  [ERROR_FILE <file>]
                  [OUTPUT_QUIET]
                  [ERROR_QUIET]
                  [OUTPUT_STRIP_TRAILING_WHITESPACE]
                  [ERROR_STRIP_TRAILING_WHITESPACE])

Is there any possibility to get this information, if not you can see this report as feature request.

Thank you very much
No tags attached.
Issue History
2012-04-19 03:56Christoph PrambergerNew Issue
2012-04-19 06:20David ColeNote Added: 0029226
2012-04-19 07:56Brad KingNote Added: 0029231
2012-04-19 07:56Brad KingStatusnew => resolved
2012-04-19 07:56Brad KingResolutionopen => no change required
2012-04-19 07:56Brad KingAssigned To => Brad King
2012-04-19 07:56Brad KingAssigned ToBrad King =>
2012-09-03 16:01David ColeNote Added: 0030857
2012-09-03 16:01David ColeStatusresolved => closed

Notes
(0029226)
David Cole   
2012-04-19 06:20   
Not possible, because the custom command does not run until build time, after CMake is done running. (So there's no CMake variable in which to put the result.)

If the command fails, the build will fail.

If the build succeeded, then the command succeeded...
(0029231)
Brad King   
2012-04-19 07:56   
If you want to to complex operations in a custom command like running something, checking the result, and then deciding what else to do based on the result, then you can run a .cmake script at build time inside the custom command. Specify

  COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/myscript.cmake

Then use execute_process or other commands inside the script.

The above is a suggestion to get you started, but the issue tracker is not a good place for such discussion. Please bring further questions to the mailing list:

 http://www.cmake.org/mailman/listinfo/cmake [^]
(0030857)
David Cole   
2012-09-03 16:01   
Closing resolved issues that have not been updated in more than 4 months.