[cmake-developers] Recommended usage of OBJECT_DEPENDS

Brad King brad.king at kitware.com
Fri Jun 15 08:11:52 EDT 2012


On 06/14/2012 05:04 PM, Alexander Neundorf wrote:
> In KDEs FindQt4.cmake the macro
> 
> qt4_generate_moc(inCppFile outMocFile)
> 
> uses the OBJECT_DEPENDS property to enforce that the moc file
> is generated before the cpp file is built.

The original purpose of OBJECT_DEPENDS was to solve a problem
with generated headers *way* back in the original makefile
generator.  Since the modern generator ensures all custom
commands have been evaluated to generate things before CMake
scan dependencies its original purpose is no longer necessary.

However, it is still useful to bring a custom command into
a target without explicitly naming the custom command output
as a target source.  If the output of a custom command is the
OBJECT_DEPENDS of some compiled source file that is in the
target then both will be brought in.  I think that may be the
case for moc but I'm not sure of the top of my head.

-Brad



More information about the cmake-developers mailing list