[CMake] [CTest] ADD_TEST and working directory

Bill Hoffman bill.hoffman at kitware.com
Thu Apr 26 11:30:01 EDT 2007


Mathieu Malaterre wrote:
> Hello,
>
>  According to cmake documentation, ADD_TEST will always execute a test:
>
> The test will be run with the current
>       working directory set to the CMakeList.txt files corresponding
>       directory in the binary tree.
>
>  In my case I need to load a python module, I decided to try
> something very simple:
>
> #1, setting the PYTHONPATH on the same line as the python executable:
>
> SET(myenv "PYTHONPATH=${LIBRARY_OUTPUT_PATH}")
> SET(my_test "from test_mymodule import *\;test_mymodule()")
> ADD_TEST(PYTHON-TEST-MYMODULE  ${myenv} python -c ${my_test})
>
> unfortunately ctest expect the first argument to be an executable.
>
> #2
> I then tried setting properly the env var by doing:
>
> SET(ENV{PYTHONPATH} ${LIBRARY_OUTPUT_PATH})
> SET(my_test "from test_mymodule import *\;test_mymodule()")
> ADD_TEST(PYTHON-TEST-MYMODULE  python -c ${my_test})
>
> still no luck. The test does not seems to be running correctly.
>
> Anything else to be able to automate this simple test ?
>
> Thanks for suggestion,
>
Make the test a cmake script that runs python.  cmake -P myscript.cmake.

-Bill



More information about the CMake mailing list