<div dir="ltr"><div><div>Hi Dan.<br><br></div>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).<br>
<br></div>Petr<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, May 28, 2013 at 7:33 PM, Dan Kegel <span dir="ltr"><<a href="mailto:dank@kegel.com" target="_blank">dank@kegel.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">In projects that include a directory full of example programs that<br>
don't usually need to be built,<br>
it's convenient to have a phony target 'examples' that builds the examples.<br>
<br>
add_custom_target looks like it's the way to implement phony targets, but the<br>
doc confused me. It said targets created with that are always built. That<br>
made me think it was added as a dependency of all!<br>
<br>
The example CMakeLists.txt,<br>
<br>
add_executable(foo1 EXCLUDE_FROM_ALL foo1.c)<br>
add_custom_target(bar1 DEPENDS foo1 COMMAND echo hi)<br>
<br>
seems to do the Right Thing (it doesn't build foo1 or bar1 by default,<br>
but does build it if you do 'cmake; make bar1').<br>
<br>
Should this be in the FAQ under "How do I create a phony target"?<br>
--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div><br></div>