[CMake] add_custom_command not triggered

David Cole DLRdave at aol.com
Sat Oct 31 11:41:58 EDT 2015


Because you're giving DEPENDS as a target name, this is only an ordering
dependency, stating that the command should run after the target is built.
But not necessarily re-build whenever the target is re-built...

If you want to re-run the command based on a file changing instead, then
use the full path to a file name as your DEPENDS argument. The downloaded
file itself, or the extracted data file the command uses would probably be
reasonable choices.

Read the DEPENDS section of
https://cmake.org/cmake/help/v3.3/command/add_custom_command.html carefully.


HTH,
David C.


On Saturday, October 31, 2015, Nico Schlömer <nico.schloemer at gmail.com>
wrote:

> After downloading a file with ExternalData_Expand_Arguments [1], I would
> like to execute a command on the data to produce another file. So far, I
> have
> ```
> ExternalData_Expand_Arguments(
>   noshTestFetchData
>   OUT_DATA DATA{${CMAKE_SOURCE_DIR}/test/data/${file}}
> )
> ExternalData_Add_Target(noshTestFetchData)
>
> add_custom_command(
>   OUTPUT ${CMAKE_BINARY_DIR}/test/data/pacman.e.2.0
>   COMMAND decomp -p 2 ${CMAKE_BINARY_DIR}/test/data/pacman.e
>   DEPENDS noshTestFetchData
> )
> ```
> The file is downloaded alright, but the `add_custom_command` is never
> triggered. Why not?
>
> This is with CMake 3.2.2.
>
> Cheers,
> Nico
>
> [1] https://cmake.org/cmake/help/v3.3/module/ExternalData.html
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20151031/6ebca8e4/attachment.html>


More information about the CMake mailing list