[CMake] Phony targets - FAQ?
Petr Kmoch
petr.kmoch at gmail.com
Wed May 29 02:45:20 EDT 2013
Hi Dan.
Note that the docs don't say that a custom target will "always be built,"
but that it's "always considered out of date." That's something else. It
means that it will always be built *if building it is considered*. So
'make' will never skip it as "up to date," but will not build it unless
told to do so (on the command line or through a dependency).
Petr
On Tue, May 28, 2013 at 7:33 PM, Dan Kegel <dank at kegel.com> wrote:
> In projects that include a directory full of example programs that
> don't usually need to be built,
> it's convenient to have a phony target 'examples' that builds the examples.
>
> add_custom_target looks like it's the way to implement phony targets, but
> the
> doc confused me. It said targets created with that are always built. That
> made me think it was added as a dependency of all!
>
> The example CMakeLists.txt,
>
> add_executable(foo1 EXCLUDE_FROM_ALL foo1.c)
> add_custom_target(bar1 DEPENDS foo1 COMMAND echo hi)
>
> seems to do the Right Thing (it doesn't build foo1 or bar1 by default,
> but does build it if you do 'cmake; make bar1').
>
> Should this be in the FAQ under "How do I create a phony target"?
> --
>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130529/991007b8/attachment.htm>
More information about the CMake
mailing list