[CMake] How can I run my excutable in build

Nils Gladitz nilsgladitz at gmail.com
Tue May 14 06:19:52 EDT 2013


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
)

Nils


On Tue, May 14, 2013 at 12:00 PM, 王东岳 <codewdy at gmail.com> wrote:

> Well, I want to run an excutable when build like the following makefile:
> 2 : 2.cpp
>     g++ 2.cpp -o 2
>
> 2.cpp : gen
>     gen 2.txt -o 2.cpp
>
> gen : gen.cpp
>     g++ gen.cpp -o gen
>
> So what should I do?
> I just have learnt how to build a simple project,
>
> --
> 清华大学计算机系
> Tsinghua University CST
> 王东岳
> Dongyue.Wang
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130514/617d155c/attachment.htm>


More information about the CMake mailing list