[CMake] TEST Property ENVIRONMENT combined with ctest --build-and-test

Hugo Heden heden at foi.se
Tue Jun 21 12:09:03 EDT 2011


Good day all,

I am using ADD_TEST like this:

   ADD_TEST(
     nameOfMyTest
     ${CMAKE_CTEST_COMMAND}
     --build-and-test  ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}
     --build-generator ${CMAKE_GENERATOR}
     --build-makeprogram ${CMAKE_BUILD_TOOL}
     --build-nocmake
     --build-noclean
     --build-project ${MY_PRODUCT_NAME}
     --build-target someTestTarget
     )

-- that is: *ctest --build-and-test* is invoked "from within" the 
test.*ctest --build-and-test* will in turn invoke the build tool:

*make someTestTarget*

(assuming Unix make is the build tool).

That's correct so far, isn't it?

Question:

I would now like to specify an environment variable in this 
CMakeLists.txt, namely "TJO=SAN", that affects the invocation of *make 
someTestTarget*. The result would be that ctest --build-and-test 
"creates" an invocation like:

*TJO=SAN make someTestTarget*

How can I do that? A naïve idea would be to write

SET_PROPERTY(TEST nameOfMyTest PROPERTY ENVIRONMENT "TJO=SAN" )

-- but that will not work (right?) Because it will only set the 
environment variable for the invocation of ctest:

*TJO=SAN ctest --build-and-test ....*

-- but /not/ the subsequent call to make.

Any ideas?

/Is there any way to tell *ctest --build-and-test* to set an environment 
variable for the invocation of the build tool?/

Best,

- Hugo Heden

FOI, Sweden
www.foi.se

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110621/a1c2f0d2/attachment.htm>


More information about the CMake mailing list