[CMake] Phony targets - FAQ?
Dan Kegel
dank at kegel.com
Tue May 28 13:33:24 EDT 2013
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"?
More information about the CMake
mailing list