set CTEST_ENVIRONMENT from within CMakeLists.txt?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

set CTEST_ENVIRONMENT from within CMakeLists.txt?

Roland Bock-4
Hi,

I would like to set some environment variables for ctest which are set
when I call

make test

but not when I call

make foo


I have read that in a ctest script, I can do this by

SET (CTEST_ENVIRONMENT "foo=bar")

But the same line does not seem to have any effect when I put it in my
CMakeLists.txt file. Any ideas? Or is this a 2.6 feature (I am still
using cmake 2.4 on Ubuntu-8.04 64bit)?


Thanks and regards,

Roland

_______________________________________________
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: set CTEST_ENVIRONMENT from within CMakeLists.txt?

David Cole
CTEST_ENVIRONMENT cannot be used from within CMakeLists.txt -- it is a "ctest -S script" only variable...

To do what you want, you will have to use CVS CMake, or wait until CMake 2.8 and then use the ENVIRONMENT test property.

With CVS or the upcoming CMake 2.8, after calling ADD_TEST in your CMakeLists.txt file, you can do:
  set_property(TEST TestName PROPERTY
    ENVIRONMENT "CMAKE_ENVIRONMENT_TEST_VAR=Happy Thanksgiving!"
  )


HTH,
David


On Wed, Sep 9, 2009 at 12:04 PM, Roland Bock <[hidden email]> wrote:
Hi,

I would like to set some environment variables for ctest which are set when I call

make test

but not when I call

make foo


I have read that in a ctest script, I can do this by

SET (CTEST_ENVIRONMENT "foo=bar")

But the same line does not seem to have any effect when I put it in my CMakeLists.txt file. Any ideas? Or is this a 2.6 feature (I am still using cmake 2.4 on Ubuntu-8.04 64bit)?


Thanks and regards,

Roland

_______________________________________________
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


_______________________________________________
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: set CTEST_ENVIRONMENT from within CMakeLists.txt?

Roland Bock-4
Hi,

that's good news for the future.

In the meantime, I have created a workaround that does the trick for the
tests in my current project (and until CMake2.8).

#-----------------------------
# M_ADD_LOCAL_TEST
#
# Parameters:
# name of the test
# command string (including all parameters)
# additional environment settings string (optional)
#-------------------------------
MACRO (M_ADD_LOCAL_TEST name command)
   ADD_TEST(${name}
          "bash"
          "-c"
          "foo=\"bar\" ${ARGN} ${CMAKE_CURRENT_BINARY_DIR}/${command}")
ENDMACRO ()
#-------------------------------

For instance

M_ADD_LOCAL_TEST(test1
    "myTestProgram"
    --verbose" "LD_LIBRARY_PATH=/usr/local/myProject/lib")

Thanks and regards,

Roland

David Cole wrote:

> CTEST_ENVIRONMENT cannot be used from within CMakeLists.txt -- it is a
> "ctest -S script" only variable...
>
> To do what you want, you will have to use CVS CMake, or wait until CMake
> 2.8 and then use the ENVIRONMENT test property.
>
> With CVS or the upcoming CMake 2.8, after calling ADD_TEST in your
> CMakeLists.txt file, you can do:
>   set_property(TEST TestName PROPERTY
>     ENVIRONMENT "CMAKE_ENVIRONMENT_TEST_VAR=Happy Thanksgiving!"
>   )
>
>
> HTH,
> David
>
>
> On Wed, Sep 9, 2009 at 12:04 PM, Roland Bock <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hi,
>
>     I would like to set some environment variables for ctest which are
>     set when I call
>
>     make test
>
>     but not when I call
>
>     make foo
>
>
>     I have read that in a ctest script, I can do this by
>
>     SET (CTEST_ENVIRONMENT "foo=bar")
>
>     But the same line does not seem to have any effect when I put it in
>     my CMakeLists.txt file. Any ideas? Or is this a 2.6 feature (I am
>     still using cmake 2.4 on Ubuntu-8.04 64bit)?
>
>
>     Thanks and regards,
>
>     Roland
>
>     _______________________________________________
>     Powered by www.kitware.com <http://www.kitware.com>
>
>     Visit other Kitware open-source projects at
>     http://www.kitware.com/opensource/opensource.html
>
>     Please keep messages on-topic and check the CMake FAQ at:
>     http://www.cmake.org/Wiki/CMake_FAQ
>
>     Follow this link to subscribe/unsubscribe:
>     http://www.cmake.org/mailman/listinfo/cmake
>
>
_______________________________________________
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake