[CMake] multiple add_custom_command solution

Tyler Roscoe tyler at cryptio.net
Thu Jul 2 11:24:31 EDT 2009


On Thu, Jul 02, 2009 at 11:10:04AM +0200, Micha Renner wrote:
> SET(_moduleList name1 name2 name3 name4 name5)
> 
> FOREACH(_module ${_moduleList})
> 
>   ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_module}.dummy
>       COMMAND cmake -E touch {CMAKE_CURRENT_BINARY_DIR}/${_module}.dummy
>       COMMAND prog ${_module}.txt >> tm16.txt
>       WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}
>       COMMENT "-- done") 
> 	
>      LIST(APPEND _result ${CMAKE_CURRENT_BINARY_DIR}/${_module}.dummy)
> 
> ENDFOREACH(_module ${_moduleList})
> 	  
> ADD_CUSTOM_TARGET(tProcess ALL DEPENDS ${_result}) 
> 
> The main disadvantage of this is
> - The target works correct only if tm16.txt does not exist before it
>   runs.

I'm not sure I understand what your custom_command is trying to do, but
if the problem is that tm16.txt needs to not exist before you start >>
lines to it, why not cmake -E remove it before you start writing new
lines to it?

tyler


More information about the CMake mailing list