[CMake] add_custom_command question

Łukasz Tasz lukasz at tasz.eu
Thu Oct 20 14:23:18 EDT 2011


> add_custom_target(TARGET generator
>                COMMAND touch aaa.cxx
>                COMMENT generate file
> )
>
> add_custom_command(OUTPUT aaa.cxx
>                COMMAND echo "command"
>                DEPENDS generator bar
> This does not work^^^^^^^^^^^^^^^^^^^^^^^^^^^
>                COMMENT "i'm just echo"
> )
> add_executable(bar EXCLUDE_FROM_ALL c.cxx)
> add_executable(foo aaa.cxx)
>
> error is:
> [ 33%] Built target bar
> make[2]: *** No rule to make target `../generator', needed by `aaa.cxx'.  Stop.
> make[1]: *** [CMakeFiles/foo.dir/all] Error 2

one my mistake, which is slightly changing the output:

add_custom_target(generator
               COMMAND touch aaa.cxx
               COMMENT generate file
)
add_custom_command(OUTPUT aaa.cxx
               COMMAND echo "command"
               DEPENDS generator bar
               COMMENT "i'm just echo"
)
add_executable(bar EXCLUDE_FROM_ALL c.cxx)
add_executable(foo aaa.cxx)

[  0%] generate file
[ 25%] Built target generator
[ 50%] Built target bar
make[3]: *** No rule to make target `generator', needed by `aaa.cxx'.  Stop.


regards
Lukasz


More information about the CMake mailing list