[CMake] How to make a target depends from target 'all'

Alexander Neundorf a.neundorf-work at gmx.net
Thu Apr 3 16:21:17 EDT 2008


On Thursday 03 April 2008, Mehdi Rabah wrote:
...
> ok then I re-explain : I have a custom rule "sync" that send binaries to a
> embedded computer. To make sure that the binaries that I send are the
> lastest version (ie the source have recompiled since my last modification)
> I wanted to make my "sync" target depend on "all". ie when I type "make
> sync" the project is rebuild before the synchronisation is made. the same
> result can be done by typing "make && make sync" but I want it to be
> managed by cmake because other people in the project doesn't need to know
> that they need to rebuild the project before each sync. They just have to
> know "make sync".

Ah, ok.

You can't do this with add_dependencies() or something similar.
Are you using exclusively "make" or also e.g. XCode or Visual Studio ?
(ok, you're cross compiling with makefiles, so XCode and VS don't work...)


The following should work (not tested):

add_custom_target(sync 
         COMMAND ${CMAKE_BUILD_TOOLS} -C ${CMAKE_CURRENT_BINARY_DIR} all 
         COMMAND <sync your binary to the target> )


Alex


More information about the CMake mailing list