[CMake] Set environment variable

David Cole david.cole at kitware.com
Wed Jan 25 09:23:43 EST 2006


Setting an env var in this manner sets it in the currently running 
environment (a session of cmake).

When it's over, the env var is gone, too. It's set during the adding of 
the test (cmake processing), not during the execution of the test.

You can use the CTEST_ENVIRONMENT variable in a ctest -S script if your 
tests run in a dashboard setting.

Not sure if there's another way to guarantee environment settings at 
test execution time... You could pass the value to the test on its 
command line - then the test itself could do a setenv.


Hope this helps,
David


Xavier Delannoy wrote:

>On Wed, 25 Jan 2006 09:14:42 -0500
>David Cole <david.cole at kitware.com> wrote:
>
>  
>
>>Try:
>>
>>SET(ENV{MYVAR} myvalue)
>>
>>(with no "$"...) The "$" causes substitution...
>>    
>>
>
>I have already try .. this does'nt work too
>
>  
>
>>Xavier Delannoy wrote:
>>
>>    
>>
>>>Hi all, 
>>>
>>>My tests require some environment variable
>>>
>>>I try to set my env. var with: 
>>>SET($ENV{MYVAR} myvalue)
>>>ADD_TEST(testname ${EXECUTABLE_OUTPUT_PATH}/test1)
>>>
>>>but this doesn't work, all my tests failed because environement variable aren't set ;(
>>>
>>>So, how to set some environment variable before running test.
>>>
>>>regards,
>>>
>>> 
>>>
>>>      
>>>
>
>
>  
>


More information about the CMake mailing list