[CMake] target DEPENDS are ignored if the target is also used for the COMMAND
Alan W. Irwin
irwin at beluga.phys.uvic.ca
Tue Oct 27 13:41:58 EDT 2009
On 2009-10-27 12:03-0400 Brad King wrote:
> Alan W. Irwin wrote:
>> The following CMake logic fragment illustrates the issue:
>>
>> add_executable(plhershey-unicode-gen ${plhershey-unicode-gen_SRCS})
>>
>> add_custom_command(
>> OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/plhershey-unicode.h
>> COMMAND plhershey-unicode-gen
>> ${CMAKE_SOURCE_DIR}/fonts/plhershey-unicode.csv
>> ${CMAKE_CURRENT_BINARY_DIR}/plhershey-unicode.h
>> DEPENDS
>> plhershey-unicode-gen
>> ${CMAKE_SOURCE_DIR}/fonts/plhershey-unicode.csv
>> )
>>
>> add_custom_target(
>> plhershey-unicode.h_built
>> DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/plhershey-unicode.h
>> )
>>
>> If I touch the source for plhershey-unicode-gen and run "make
>> plhershey-unicode.h_built", then plhershey-unicode-gen gets rebuilt but the
>> custom command is not re-run. Apparently, a target is ignored as a DEPENDS
>> if it is also used as a COMMAND. That doesn't seem correct to me.
>>
>> The workaround is to replace the COMMAND by the location of the
>> plhershey-unicode-gen executable. In that case, if I touch the source for
>> plhershey-unicode-gen and run "make plhershey-unicode.h_built", then
>> plhershey-unicode-gen gets rebuilt, and so does plhershey-unicode.h.
>>
>> According to the documentation you should be able to use targets for
>> COMMANDs, and targets for DEPENDS. Furthermore according to the
>> documention, in the former case the file depends are not taken care of, but
>> in the latter case they should be (for add_executable or add_library
>> targets). I believe it is a bug in the implemention that the latter
>> case is
>> ignored when the target is also used for the COMMAND.
>
> CMake has a test for this (BuildDepends), and it has this code:
>
> add_custom_command(
> OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/regen.h
> COMMAND generator ${CMAKE_CURRENT_BINARY_DIR}/regen.h regen
> DEPENDS generator # adds file-level dependency to re-run rule
> )
>
> The test passes, and if I comment out the DEPENDS line it fails.
>
> What version of CMake are you using? What generator? What platform?
cmake version 2.6-patch 4;
Unix Makefiles;
Linux (Debian stable with bootstrap build of CMake-2.6.4);
What's the easiest way to try the "generator" test here (for Unix Makefiles)
so we are doing exactly the same test?
Alan
__________________________
Alan W. Irwin
Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).
Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________
Linux-powered Science
__________________________
More information about the CMake
mailing list