[CMake] Running two executables sequentially in a test

David Cole david.cole at kitware.com
Mon May 2 13:57:56 EDT 2011


script.cmake:
execute_process(x)
execute_process(y)

CMakeLists.txt:
add_test(NAME MyTest COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_SOURCE_DIR}/script.cmake)

Or, configure the script into the build tree if you need variable values
from the CMakeLists.txt file and then reference the configured copy instead.

The NAME/COMMAND signature of add_test is only available in 2.8 and later,
though.


HTH,
David


On Mon, May 2, 2011 at 1:41 PM, David Doria <daviddoria at gmail.com> wrote:

> On Mon, May 2, 2011 at 1:31 PM, David Cole <david.cole at kitware.com> wrote:
> > If it's supposed to be "one test" from ctest's point of view, you should
> > write a script that makes 2 execute_process calls, and run the script as
> the
> > add_test command.
>
> I tried to write a function that runs to executables, and add that
> function to the test:
>
> cmake_minimum_required(VERSION 2.6)
>
> PROJECT(Test)
> ENABLE_TESTING()
>
> ADD_EXECUTABLE(Test1 Test1.cxx)
> ADD_EXECUTABLE(Test2 Test2.cxx)
>
> function(RunTest x y)
>  execute_process(x)
>  execute_process(y)
> endfunction()
>
> add_test(MyTest RunTest(Test1 Test2))
>
> but I get the error:
>
> Unable to find executable: RunTest
>
> This must not be what you mean by "a script"?
>
> David
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110502/505b9220/attachment.htm>


More information about the CMake mailing list