[CMake] Re-executing the make command with few or no source tree changes is extremely inefficient for CMake-2.4.3

Brad King brad.king at kitware.com
Thu Aug 17 15:00:03 EDT 2006


Alan W. Irwin wrote:
> On 2006-08-17 13:53-0400 Brad King wrote:
> 
>> [out of order] You need to use ADD_CUSTOM_COMMAND.
> 
> That may be another alternative to ADD_CUSTOM_TARGET, but I don't think it
> is possible since I need a target I can refer to in parallel directories
> (not below the directory where plhershey-unicode.h gets built). I have
> never
> been able to get dependencies to work across directories for the
> ADD_CUSTOM_COMMAND, but they do work across directories for the
> ADD_CUSTOM_TARGET command.  It is important that plhershey-unicode.h gets
> built before our core library so the rest of this post concerns the
> dependency problem with ADD_CUSTOM_TARGET.

# In one directory:
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/my_header.h ...)
ADD_CUSTOM_TARGET(make_sure_my_header_is_up_to_date
  DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/my_header.h)

# In another directory:
ADD_EXECUTABLE(exe_needing_my_header ...)
ADD_DEPENDENCY(exe_needing_my_header make_sure_my_header_is_up_to_date)

> The clear implication of this documentation is that you use ALL when you
> want the target to be built every time, and without ALL it will be
> conditionally built depending on dependencies.

This was not the intended implication.  I'm committing new documentation
to make it unambiguous since this is a common mistake.

-Brad


More information about the CMake mailing list