[CMake] Problem setting ENVIRONMENT for ctest

David Cole david.cole at kitware.com
Fri Dec 3 16:26:51 EST 2010


Try just the single line:
SET_TESTS_PROPERTIES(rsbtest PROPERTIES ENVIRONMENT
"PATH=$ENV{PATH};${Boost_LIBRARY_DIRS}")

Or... if there's still a \; problem with that call, then try it this
way, reversing the ordering:
SET_TESTS_PROPERTIES(rsbtest PROPERTIES ENVIRONMENT
"PATH=${Boost_LIBRARY_DIRS};$ENV{PATH}")

Let us know if that works.

It's not documented, because where would we document something like
that so that it would be useful and found by someone looking for it.
The best solution is google first, email here second... :-)


Thanks,
David


On Fri, Dec 3, 2010 at 3:49 PM, Johannes Wienke
<jwienke at techfak.uni-bielefeld.de> wrote:
> Hey,
>
> thanks for the quick reply.
>
> Am 03.12.2010 19:12 schrieb David Cole:
>> What version of cmake/ctest are you using?
>> (i.e. -- send the output of "cmake --version")
>
> On the windows machine (32 bit) where the problem is visible it is
> 2.8.3. I could also verify the generated CTestTestfile on linux 64 bit
> with 2.8.0.
>
>> What does CTestTestfile.cmake contain if you change your CMakeLists
>> file to use set_property(TEST ...) instead of set_tests_properties()?
>
> The same content that does not work.
>
>> This should work as expected in CMake. We have a test in the test
>> suite that tests the ENVIRONMENT test property at
>> CMake/Tests/Environment/CMakeLists.txt -- the test uses
>> set_tests_properties.
>
> I took a look at the contents of that test and transferred it to my
> project printing out the PATH environment variable. There I found two
> things: a) an inconsistent behavior and b) the real problem. ;)
>
> a)
> I had the correct path required for running the tests exported on the
> shell prior to calling ctest. With the SET_TESTS_PROPERTIES test file
> version generated by cmake this is ignored (PATH is completely replaced
> by the contents of the test file) whereas the SET_PROPERTIES(TEST...)
> version (modified by hand) seems to append to the current path instead
> of replacing it and hence passed through the correct export from my
> shell to the test executable.
>
> b)
> The real problem is that the system path of my machine contains an entry
> that ends with a slash (completely legal):
>
> ...tem32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\...
> (end of the powershell entry)
>
> Using the regular expression above to escape the semicolons results in:
>
> ...tem32\Wbem\;C:\Windows\System32\WindowsPowerShell\v1.0\\;C:\...
>
> You see the double-slash.
> Using this string again in the SET_TESTS_PROPERTIES macro again results
> in a path truncated after this entry because everything after the
> powershell entry is misinterpreted by the macro as a new environment
> variable or I don't know.
>
> So the real question is how to handle this case correctly? The need to
> escape the semicolons seems to be a burden for users that isn't event
> documented and in this case results in a error which requires strange
> corner cases routines.
>
> Regards,
> Johannes
>
>> On Fri, Dec 3, 2010 at 12:37 PM, Johannes Wienke
>> <jwienke at techfak.uni-bielefeld.de> wrote:
>>> 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
>>> _______________________________________________
>>> 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
>>>
>
>
>


More information about the CMake mailing list