On Mon, May 2, 2011 at 2:27 PM, Tyler <ty...@cryptio.net> wrote:
> You could use -D flags (cmake -Dvar=value -P script.cmake).

That seems reasonable. I tried it:

CMakeLists.txt
-------------
cmake_minimum_required(VERSION 2.6)

PROJECT(Test)
ENABLE_TESTING()

ADD_EXECUTABLE(Test1 Test1.cxx)
ADD_EXECUTABLE(Test2 Test2.cxx)

add_test(NAME MyTest COMMAND ${CMAKE_COMMAND} -Dcommand1=Test1
-Dcommand2=Test2 -P ${CMAKE_CURRENT_SOURCE_DIR}/script.cmake)

script.cmake
-------------
execute_process(command1)
execute_process(command2)

but CMake fails with:
execute_process given unknown argument "command1".

When I replace with:
execute_process(${command1})
execute_process(${command2})

it still fails, but this time with:
execute_process given unknown argument "Test1".

I thought it might not have been looking in the right path or
something, so I tried:

add_test(NAME MyTest COMMAND ${CMAKE_COMMAND}
-Dcommand1=${CMAKE_CURRENT_BINARY_DIR}/Test1
-Dcommand2=${CMAKE_CURRENT_BINARY_DIR}/Test2 -P
${CMAKE_CURRENT_SOURCE_DIR}/script.cmake)

but now it fails with:
execute_process given unknown argument "/home/doriad/TestCMake/bin/Test1"

That executable indeed exists and runs fine.

-----------
Also, to support previous versions I could just remove the NAME and
COMMAND keywords to get:

add_test(MyTest ${CMAKE_COMMAND} -Dcommand1=Test1 -Dcommand2=Test2 -P
${CMAKE_CURRENT_SOURCE_DIR}/script.cmake)

right?

David
_______________________________________________
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