[CMake] How can I run my excutable in build

Nils Gladitz nilsgladitz at gmail.com
Tue May 14 14:58:29 EDT 2013


Unless I misunderstand the documentation a target level dependency is 
automatically added if the command references a target created by 
add_executable.
So the order at least should be guaranteed?
Though either way your second argument is still valid.

Nils

On 05/14/2013 07:57 PM, Matthew Woehlke wrote:
> On 2013-05-14 06:19, Nils Gladitz wrote:
>> I think something like this:
>>
>> add_executable(2 2.cpp)
>> add_executable(gen gen.cpp)
>>
>> add_custom_command(OUTPUT 2.cpp
>>      COMMAND gen "${CMAKE_CURRENT_SOURCE_DIR}/2.txt" -o 2.cpp
>>      DEPENDS 2.txt
>> )
>
> 'DEPENDS 2.txt gen' :-). You want the dependency on 'gen' to ensure it 
> has been built before trying to run the custom command (also because 
> you usually want to re-run the command if 'gen' changes).
>



More information about the CMake mailing list