[CMake] ctest - how to set environment

Ken Martin ken.martin at kitware.com
Wed Feb 20 15:05:22 EST 2008


Really we need to implement

set_property(TEST testname ENVIRONMENT "bah=foo;fu=bar;display=:0.0")

and have ctest honor it which really should be pretty easy just a matter of
coding it up. The property stuff is already there and gets passed to the
test in ctest. CTest just has to look for that property and do some setenv
calls.

Ken

Ken Martin PhD 
Kitware Inc.
28 Corporate Drive
Clifton Park NY 12065
518 371 3971 

> -----Original Message-----
> From: cmake-bounces+ken.martin=kitware.com at cmake.org [mailto:cmake-
> bounces+ken.martin=kitware.com at cmake.org] On Behalf Of Bill Hoffman
> Sent: Wednesday, February 20, 2008 2:21 PM
> To: David Cole
> Cc: cmake at cmake.org
> Subject: Re: [CMake] ctest - how to set environment
> 
> David Cole wrote:
> 
> >     As I wrote in my first mail, I'm failed using CTEST_ENVIRONMENT
> inside a
> >     CMakeLists.txt. I have not tried this in a special ctest script
> >     because I'm
> >     searching for lean solution. Which means write a 'CMakeList.txt'
> once,
> >     run 'cmake' once and be able to run 'make test' for every change on
> my
> >     software. My problem is: there is make test target, I want to use
> >     it, but all
> >     tests fail because of the missing environment variables.
> >
> >     Maintaining a ctest script besides the CMakeLists.txt is too much
> >     effort for
> >     my current purpose. As described in
> >     http://www.cmake.org/Wiki/CMake_Testing_With_CTest "Simple Testing"
> >     ("The easiest way to create CTest input files is using CMake."), I
> >     just want
> >     to generate / call the tests within the build process (with the
> >     existing test
> >     target), and not define/maintain a parallel build/test process.
> >
> So, this whole issue has to do with cmake time vs build time.  As long
> as cmake is a running process then you can set env vars.  When that
> process is over then the env is gone.   One thing you could do is have
> your test be run by a cmake script. So, you would wrap your tests in
> some cmake script that set the environment variable.  The scripts would
> use execute_process to run the tests, and -D options to the script to
> pass options to your test.
> 
> -Bill
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list