OK, the below suggestion did have one problem, but I was able to make it work. The problem, kind of hinted at in David Cole's answer, was that, since the file is run at test time, variables defined at configure time don't work. So, this did NOT work:

added to top level CMakeLists.txt:
set_directory_properties(PROPERTIES TEST_INCLUDE_FILE
  "${CMAKE_SOURCE_DIR}/cmake-modules/TestConfig.cmake")


TestConfig.cmake:
set(ENV{PATH} "${XXXX_BINDIR}:$ENV{PATH}")

because $XXXX_BINDIR was defined at configure time, and unfortunately wasn't defined at test time.

So, I had to generate a file as part of configure time. So the entire fix was these two lines in the top level CMakeLists.txt file(WRITE ${CMAKE_BINARY_DIR}/TestConfig.cmake "set(ENV{PATH} \"${XXXX_BINDIR}:\$ENV{PATH}\")\n")
set_directory_properties(PROPERTIES TEST_INCLUDE_FILE
  "${CMAKE_BINARY_DIR}/TestConfig.cmake")

this generated a TestConfig.cmake file like this:
set(ENV{PATH} "/usr/local/XXXX/bin:$ENV{PATH}")


Which works, so thanks!
Jim

On 07/31/2014 03:10 AM, David Cole wrote:
CMake itself does this to include a file at ctest time that applies to
*all* tests:

   set_directory_properties(PROPERTIES
     TEST_INCLUDE_FILE
     "${CMake_BINARY_DIR}/Tests/EnforceConfig.cmake")

It results in this line being generated in CTestTestfile.cmake at the
very top of the file:

    include("C:/n/d/Nightly/cmake
Win32-ninja-cl11-Debug/Tests/EnforceConfig.cmake")

If you wrote/configured a file that had this in it (can be in your
build tree, as CMake's is...):

   set(ENV{PATH} "/actual/value/of/XXXX_BINDIR:$ENV{PATH}")

...and then set that file as your TEST_INCLUDE_FILE, it should do what
you want in this case.

The documentation is sparse, but there:

   http://www.cmake.org/cmake/help/v3.0/prop_dir/TEST_INCLUDE_FILE.html


HTH,
David C.




--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to