[CMake] is it possbile to export environment varibles from cmake scripts?

Alexander Bubnov alexander.bubnov at gmail.com
Mon Jul 7 08:07:54 EDT 2008


It is clear. I just would like to know a similiar command of cmake.
...it is a pity there is no one.

Thanks.

2008/7/7, Timenkov Yuri <ytimenkov at parallels.com>:
>
>
>  On Monday 07 July 2008 15:53:00 Alexander Bubnov wrote:
>  > Hello!
>  >
>  > Below simple example to clarify the problem.
>  >
>  > My CMakeLists.txt:
>  >
>  > cmake_minimum_required(VERSION 2.6)
>  >
>  > set(ENV{MYVAR} "SOME VALUE")
>  > message("the value of MYVAR: " $ENV{MYVAR})
>  >
>  > the output:
>  >
>  > the value of MYVAR: SOME VALUE
>  > -- Configuring done
>  > -- Generating done
>  > -- Build files have been written to: /home/alek/trial/cmake/CMakeExample
>  >
>  >
>  > after that I am typing: echo $MYVAR
>  > MYVAR: Undefined variable.
>  >
>  > Is it possible to export MYVAR to shell environment?
>
> I don't think it's possible with any tool. Environment variables are
>  propagated from parent process to child when the former creates start-up
>  parameters (for exec* or CreateProcess calls) for the latter (as CMake and any
>  other program (including shell) does when executes external utilities).
>
>  The "export" or "set" are keywords of command line interpreter itself which
>  tell it to set appropriate environment variables for child processes.
>
>  As for CMake, you can try to execute script from CMakeLists.txt to see if it
>  exports variables properly.
>
>  >
>  > Thanks in advance.
>
>


-- 
/BR, Alexander


More information about the CMake mailing list