On 11/01/2010 10:47 PM, SK wrote: > I know add_custom_target does not produce output as far as CMake is > concerned. My situation is as follows: > > A traditional make process that I cannot modify produces a target on > which I must do some post-processing. > > I use add_custom_target to force the makefile to always run. I use > add_custom_command for my post-processing steps. > > How do I setup a dependency for the post-processing steps? I don't > want to run these steps unless the external make actually updated its > target.
Possibly, you can use ADD_CUSTOM_COMMAND(TARGET ... POST_BUILD ...): CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) PROJECT(POSTPROCESSING NONE) ADD_CUSTOM_TARGET(t ALL ${CMAKE_COMMAND} -E echo "Building target t" VERBATIM) ADD_CUSTOM_COMMAND(TARGET t POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo "Post-processing target t" VERBATIM) So, the custom command always runs after the custom target's one. > The add_custom_command cannot use the name of the add_custom_target as > a DEPENDS. I tried this and it assumes that the add_custom_target name > is just a file and cannot find it. IMO, this is strange. Indeed, the following doesn't work: CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) PROJECT(CUSTOMDEPENDS NONE) ADD_CUSTOM_TARGET(t ${CMAKE_COMMAND} -E echo "Building target t" VERBATIM) ADD_CUSTOM_COMMAND(OUTPUT stamp COMMAND ${CMAKE_COMMAND} -E touch stamp DEPENDS t VERBATIM) ADD_CUSTOM_TARGET(main ALL ${CMAKE_COMMAND} -E echo "Building target main" DEPENDS stamp VERBATIM) When running make, it correctly builds target t, but subsequently, it bails out saying "No rule to make target `t', needed by `stamp'." From the documentation of ADD_CUSTOM_COMMAND(), it's not clear why there is a restriction of that kind w.r.t. custom targets. Perhaps, someone can give us a hint if this is intended behaviour or should be considered as erroneous. Regards, Michael _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake