[CMake] Depending on all and custom targets

Marcel Loose loose at astron.nl
Fri Oct 9 07:11:22 EDT 2009


Hi  Jens,

It's not a bug. Quoting from the docs for add_custom_target:

  Dependencies listed with the DEPENDS argument may reference files and
  outputs of custom commands created with ADD_CUSTOM_COMMAND.

The problem is that your target 'extras' doesn't create any files. By
saying "add_custom_target(complete DEPENDS extras)" you're telling CMake
that target 'complete' depends on the _file_ 'extras'.

The correct way to do this is to use add_dependencies:

add_custom_target(complete)
add_dependencies(complete extras)

HTH,
Marcel Loose.


On Fri, 2009-10-09 at 12:47 +0200, jens persson wrote:
> 2009/10/9 Eric Noulard <eric.noulard at gmail.com>:
> > 2009/10/9 jens persson <jens at persson.cx>:
> >> I get the impression that I have two problems: depending on a
> >> custom_target and depending on all.
> >
> > Dependency from builtin target is currently unsupported.
> > see:
> > http://public.kitware.com/Bug/view.php?id=8438
> 
> OK, that settled then, I'll create my on taget my_all or something
> like that then :-)
> 
> >
> > I think dependency from "extras" should work did you try with
> > only "extras" and not "all"?
> 
> Yes I get the following error:
> 
> $ make complete
> [100%] Built target bar
> [100%] Built target extras
> make[3]: *** No rule to make target `extras', needed by
> `CMakeFiles/complete'.  Stop.
> make[2]: *** [CMakeFiles/complete.dir/all] Error 2
> make[1]: *** [CMakeFiles/complete.dir/rule] Error 2
> make: *** [complete] Error 2
> 
> 
> With this CMakeLists.txt file:
> 
> PROJECT (tester)
> CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
> CMAKE_POLICY (VERSION 2.6)
> 
> add_executable(bar
>         bar.c
> )
> add_custom_target(extras
>         DEPENDS bar
> )
> add_custom_target(complete
>         DEPENDS extras
> )
> 
> 
> I've tried to look into the makefiles but could not find the solution.
> 
> I have included the verbose output of make at the end of this mail
> 
> It seems that the file CMakeFiles/complete.dir/build.make references
> the extras target that is defined in CMakeFiles/extras.dir/build.make
> 
> Probably a bug. Will report it later.
> 
> /jp
> 
> 
> $ VERBOSE=1 make complete
> /usr/bin/cmake -H/home/sejenpe/tmp/cmake-tester/complete
> -B/home/sejenpe/tmp/cmake-tester/complete --check-build-system
> CMakeFiles/Makefile.cmake 0
> make -f CMakeFiles/Makefile2 complete
> make[1]: Entering directory `/home/sejenpe/tmp/cmake-tester/complete'
> /usr/bin/cmake -H/home/sejenpe/tmp/cmake-tester/complete
> -B/home/sejenpe/tmp/cmake-tester/complete --check-build-system
> CMakeFiles/Makefile.cmake 0
> /usr/bin/cmake -E cmake_progress_start
> /home/sejenpe/tmp/cmake-tester/complete/CMakeFiles 1
> make -f CMakeFiles/Makefile2 CMakeFiles/complete.dir/all
> make[2]: Entering directory `/home/sejenpe/tmp/cmake-tester/complete'
> make -f CMakeFiles/bar.dir/build.make CMakeFiles/bar.dir/depend
> make[3]: Entering directory `/home/sejenpe/tmp/cmake-tester/complete'
> cd /home/sejenpe/tmp/cmake-tester/complete && /usr/bin/cmake -E
> cmake_depends "Unix Makefiles" /home/sejenpe/tmp/cmake-tester/complete
> /home/sejenpe/tmp/cmake-tester/complete
> /home/sejenpe/tmp/cmake-tester/complete
> /home/sejenpe/tmp/cmake-tester/complete
> /home/sejenpe/tmp/cmake-tester/complete/CMakeFiles/bar.dir/DependInfo.cmake
> --color=
> make[3]: Leaving directory `/home/sejenpe/tmp/cmake-tester/complete'
> make -f CMakeFiles/bar.dir/build.make CMakeFiles/bar.dir/build
> make[3]: Entering directory `/home/sejenpe/tmp/cmake-tester/complete'
> make[3]: Nothing to be done for `CMakeFiles/bar.dir/build'.
> make[3]: Leaving directory `/home/sejenpe/tmp/cmake-tester/complete'
> /usr/bin/cmake -E cmake_progress_report
> /home/sejenpe/tmp/cmake-tester/complete/CMakeFiles  1
> [100%] Built target bar
> make -f CMakeFiles/extras.dir/build.make CMakeFiles/extras.dir/depend
> make[3]: Entering directory `/home/sejenpe/tmp/cmake-tester/complete'
> cd /home/sejenpe/tmp/cmake-tester/complete && /usr/bin/cmake -E
> cmake_depends "Unix Makefiles" /home/sejenpe/tmp/cmake-tester/complete
> /home/sejenpe/tmp/cmake-tester/complete
> /home/sejenpe/tmp/cmake-tester/complete
> /home/sejenpe/tmp/cmake-tester/complete
> /home/sejenpe/tmp/cmake-tester/complete/CMakeFiles/extras.dir/DependInfo.cmake
> --color=
> make[3]: Leaving directory `/home/sejenpe/tmp/cmake-tester/complete'
> make -f CMakeFiles/extras.dir/build.make CMakeFiles/extras.dir/build
> make[3]: Entering directory `/home/sejenpe/tmp/cmake-tester/complete'
> make[3]: Nothing to be done for `CMakeFiles/extras.dir/build'.
> make[3]: Leaving directory `/home/sejenpe/tmp/cmake-tester/complete'
> /usr/bin/cmake -E cmake_progress_report
> /home/sejenpe/tmp/cmake-tester/complete/CMakeFiles
> [100%] Built target extras
> make -f CMakeFiles/complete.dir/build.make CMakeFiles/complete.dir/depend
> make[3]: Entering directory `/home/sejenpe/tmp/cmake-tester/complete'
> cd /home/sejenpe/tmp/cmake-tester/complete && /usr/bin/cmake -E
> cmake_depends "Unix Makefiles" /home/sejenpe/tmp/cmake-tester/complete
> /home/sejenpe/tmp/cmake-tester/complete
> /home/sejenpe/tmp/cmake-tester/complete
> /home/sejenpe/tmp/cmake-tester/complete
> /home/sejenpe/tmp/cmake-tester/complete/CMakeFiles/complete.dir/DependInfo.cmake
> --color=
> make[3]: Leaving directory `/home/sejenpe/tmp/cmake-tester/complete'
> make -f CMakeFiles/complete.dir/build.make CMakeFiles/complete.dir/build
> make[3]: Entering directory `/home/sejenpe/tmp/cmake-tester/complete'
> make[3]: *** No rule to make target `extras', needed by
> `CMakeFiles/complete'.  Stop.
> make[3]: Leaving directory `/home/sejenpe/tmp/cmake-tester/complete'
> make[2]: *** [CMakeFiles/complete.dir/all] Error 2
> make[2]: Leaving directory `/home/sejenpe/tmp/cmake-tester/complete'
> make[1]: *** [CMakeFiles/complete.dir/rule] Error 2
> make[1]: Leaving directory `/home/sejenpe/tmp/cmake-tester/complete'
> make: *** [complete] Error 2
> 
> 
> -- 
> jens persson
> <jens at persson.cx>
> Mäster Olofsväg 24
> S-224 66 LUND;SWEDEN
> _______________________________________________
> 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



More information about the CMake mailing list