Alan W. Irwin wrote: > The following CMake logic fragment illustrates the issue: > > add_executable(plhershey-unicode-gen ${plhershey-unicode-gen_SRCS}) > > add_custom_command( > OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/plhershey-unicode.h > COMMAND plhershey-unicode-gen > ${CMAKE_SOURCE_DIR}/fonts/plhershey-unicode.csv > ${CMAKE_CURRENT_BINARY_DIR}/plhershey-unicode.h > DEPENDS > plhershey-unicode-gen > ${CMAKE_SOURCE_DIR}/fonts/plhershey-unicode.csv > ) > > add_custom_target( > plhershey-unicode.h_built > DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/plhershey-unicode.h > ) > > If I touch the source for plhershey-unicode-gen and run "make > plhershey-unicode.h_built", then plhershey-unicode-gen gets rebuilt but the > custom command is not re-run. Apparently, a target is ignored as a DEPENDS > if it is also used as a COMMAND. That doesn't seem correct to me. > > The workaround is to replace the COMMAND by the location of the > plhershey-unicode-gen executable. In that case, if I touch the source for > plhershey-unicode-gen and run "make plhershey-unicode.h_built", then > plhershey-unicode-gen gets rebuilt, and so does plhershey-unicode.h. > > According to the documentation you should be able to use targets for > COMMANDs, and targets for DEPENDS. Furthermore according to the > documention, in the former case the file depends are not taken care of, but > in the latter case they should be (for add_executable or add_library > targets). I believe it is a bug in the implemention that the latter > case is > ignored when the target is also used for the COMMAND.
CMake has a test for this (BuildDepends), and it has this code: add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/regen.h COMMAND generator ${CMAKE_CURRENT_BINARY_DIR}/regen.h regen DEPENDS generator # adds file-level dependency to re-run rule ) The test passes, and if I comment out the DEPENDS line it fails. What version of CMake are you using? What generator? What platform? -Brad _______________________________________________ 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