[CMake] Problem setting ENVIRONMENT for ctest

Johannes Wienke jwienke at techfak.uni-bielefeld.de
Fri Dec 3 12:37:57 EST 2010


Dear all,

I am try to set the PATH environment variable on windows for running the 
unit tests through ctest. The ctest file is generated by the cmake 
scripts. The PATH is required to for finding additional dlls required by 
the tests.

I tried to set the PATH using this cmake code:

SET(PATH_STRING "$ENV{PATH};${Boost_LIBRARY_DIRS}")
STRING(REPLACE ";" "\\;" PATH_STRING "${PATH_STRING}")
SET_TESTS_PROPERTIES(rsbtest PROPERTIES ENVIRONMENT "PATH=${PATH_STRING}")

This is done according to this list posting some time ago:
http://www.cmake.org/pipermail/cmake/2009-May/029464.html

However, it does not work for me. PATH is not changed when calling ctest 
and the dlls are not found. I investigated a bit and found out that the 
resulting CTestTestfile.cmake file contains these lines for every 
specified test:

ADD_TEST(rsbtest "<correct binary>")
SET_TESTS_PROPERTIES(rsbtest PROPERTIES  ENVIRONMENT "PATH=<correct path 
with correct escapes>")

However, "man ctest" does not even document that SET_TESTS_PROPERTIES is 
a valid command for ctest. Instead SET_PROPERTY(TEST...) is explained. 
So I changed the generated CTestTestfile.cmake according to this 
information to:

ADD_TEST(rsbtest "<correct binary>")
SET_PROPERTY(TEST rsbtest PROPERTY ENVIRONMENT "PATH=<correct path with 
correct escapes>")

Afterwards all unit tests run as expected.

What am I doing wrong here? Or is this a bug in cmake?

Thanks for any help!
Johannes


More information about the CMake mailing list