[CMake] Re: Ignoring command return code in add_custom_command

Bill Hoffman bill.hoffman at kitware.com
Fri Dec 14 08:53:27 EST 2007


Rodolfo Lima wrote:
> Brandon Van Every escreveu:
> 
>> 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.
> 
> Thanks Brandon. Unfortunately this solution is a little ugly. That's
> something that could be easily implemented if cmake supported Lua. The
> command could be a lua function properly defined.
> Thanks anyway.
> 

OK, I know I will regret this, but how would lua help here?  Other than 
the myscript.cmake would be myscript.lua and the syntax would by 
slightly different, it would be the exact same thing.  The issue is that 
cmake and whatever language it uses is not around at build time unless 
you call it.  cmake creates makefiles/projects and it is no longer 
running.  Now one solution to this would be to add a feature to the 
add_custom_command that ignores the result of the command you are 
running.   Your example is a bit odd as well...

add_custom_command(OUTPUT text.cpp COMMAND false)
add_executable(test main.cpp text.cpp)

In this case text.cpp would not be created and the build would fail when 
  text.cpp was compiled...

-Bill


More information about the CMake mailing list