[CMake] Ignoring command return code in add_custom_command

Brandon Van Every bvanevery at gmail.com
Fri Dec 14 02:44:08 EST 2007


On Dec 13, 2007 11:05 PM, Rodolfo Lima <rodolfo at rodsoft.org> wrote:
> Hi, is there a way to inform cmake that it should ignore the return code
> of the command specified with add_custom_command? I want the command to
> be successful, even if it returns something different than 0.
>
> For instance:
> add_custom_command(OUTPUT text.cpp COMMAND false)
> add_executable(test main.cpp text.cpp)
>
> I'm using on linux, using Makefiles, and it bails off because 'false' is
> returning 1. What if that's an expected behavior? Is there any way to
> circumvent this?

I think you will need to do a "COMMAND cmake -P myscript.cmake".
myscript.cmake should contain an EXECUTE_PROCESS that does what you
want, then interprets the return codes however you want.  Then you'd
message(SEND_ERROR ...) or message(FATAL_ERROR ...) to indicate an
abnormal result.  There were bugs regarding CMake script return codes
once upon a time; hope those were fixed.


Cheers,
Brandon Van Every


More information about the CMake mailing list