[CMake] ADD_CUSTOM_TARGET dependency asymmetry

Brandon J. Van Every bvanevery at gmail.com
Mon Jun 5 00:40:30 EDT 2006


I have a /boot subdirectory.  It contains chicken-boot and csi-boot 
targets, specified with ADD_EXECUTABLE.  I want to copy a few extra 
files and create an overall "boot" target.  If I do this in the 
CMakeLists.txt in the subdirectory it fails:

ADD_CUSTOM_TARGET(boot
  DEPENDS
  chicken-boot
  csi-boot
  ${CMAKE_CURRENT_BINARY_DIR}/chicken.h
  ${CMAKE_CURRENT_BINARY_DIR}/chicken-ffi-macros.scm
  ${CMAKE_CURRENT_BINARY_DIR}/chicken-more-macros.scm
)

$ make boot
make[3]: *** No rule to make target `boot/chicken-boot.exe', needed by 
`boot'.  Stop.
make[2]: *** [boot/CMakeFiles/boot.dir/all] Error 2
make[1]: *** [boot/CMakeFiles/boot.dir/rule] Error 2
make: *** [boot] Error 2

If I qualify the pathnames it still fails:

ADD_CUSTOM_TARGET(boot
  DEPENDS
  ${CMAKE_CURRENT_BINARY_DIR}/chicken-boot
  ${CMAKE_CURRENT_BINARY_DIR}/csi-boot
  ${CMAKE_CURRENT_BINARY_DIR}/chicken.h
  ${CMAKE_CURRENT_BINARY_DIR}/chicken-ffi-macros.scm
  ${CMAKE_CURRENT_BINARY_DIR}/chicken-more-macros.scm
)

$ make boot
make[3]: *** No rule to make target `boot/chicken-boot.exe', needed by 
`boot'.  Stop.
make[2]: *** [boot/CMakeFiles/boot.dir/all] Error 2
make[1]: *** [boot/CMakeFiles/boot.dir/rule] Error 2
make: *** [boot] Error 2

But if I use ADD_DEPENDENCIES for the toplevel targets, it works just fine:

ADD_CUSTOM_TARGET(boot
  DEPENDS
  ${CMAKE_CURRENT_BINARY_DIR}/chicken.h
  ${CMAKE_CURRENT_BINARY_DIR}/chicken-ffi-macros.scm
  ${CMAKE_CURRENT_BINARY_DIR}/chicken-more-macros.scm
)
ADD_DEPENDENCIES(boot chicken-boot csi-boot)

$ make boot
Generating eval.c, eval.exports

In a toplevel target, I think it's reasonable to expect DEPENDS to 
handle all dependencies, not just file-level dependencies.


Cheers,
Brandon Van Every



More information about the CMake mailing list