[CMake] setup enviroment for all tests
Leek, Jim
leek2 at llnl.gov
Wed Jul 30 19:21:32 EDT 2014
I recently converted my project to configure with cmake, and am now trying to get the tests to run under ctest. I may be doing this completely incorrectly, so let me know if anything you see below looks like a bad idea.
All my tests use a particular program to check the output of the tests against the correct output. The tests output in a particular format, so I have to use a particular 'diff' program to compare them. This program was not developed by me, and is not part of the project. So, I wrote a FindXXXX.cmake file to find the program and supply the location.
So, I have the path to the diff program as XXXX_BINDIR.
My tests are all driven by a generic script. This script takes a couple of command line arguments to get the important paths for running the test and checking the results. Like this:
add_test (test1 ${TEST_SCRIPT_DIR}/test.sh
${PROJECT_BINARY_DIR}/bin/meos ${CMAKE_CURRENT_SOURCE_DIR} test1.input)
If it's not obvious, test.sh is the test script. The first argument is the path to the binary I'm testing, the second is the directory where both the input files and expected output files can be found, and the last is the name of the input for this test.
So, I could pass the path to the 'diff' program as another command line argument, but that's already beginning to become cumbersome. It's seems more reasonable just to stick it in the system PATH variable.
I can do that like this:
set_property(TEST test1 PROPERTY ENVIRONMENT PATH="${XXXX_BINDIR}:$ENV{PATH}")
The only annoying thing is, I have to have that line for EVERY test. I have lots of tests. I would rather set that path for ALL the tests. But I can't seem to find a way to do that. This doesn't work:
set_property(GLOBAL PROPERTY ENVIRONMENT PATH="${XXXX_BINDIR}:$ENV{PATH}")
Is there a way to set up the environment for all the tests in one line?
Thanks,
Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140730/ffa6d36e/attachment.html>
More information about the CMake
mailing list