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, 王东岳 <[email protected]> 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
>
--

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

Reply via email to