[CMake] How can I run my excutable in build

Matthew Woehlke matthew.woehlke at kitware.com
Tue May 14 13:57:46 EDT 2013


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).

-- 
Matthew



More information about the CMake mailing list