[CMake] Setting an environment variable when executing make script

Carlson Daniel daniel.c.carlson at gmail.com
Sun Mar 29 09:04:13 EDT 2009


Hello and sorry for my late response!

I can not get this to work. When i execute the command COMMAND
${CMAKE_COMMAND} -E ${template.cmake}
  I get an error saying something like:

CMake Error: cmake version 2.6-patch 2
Usage: /home/daniel/Public/cmake-2.6.2/bin/cmake -E [command] [arguments
...]
Available commands:
  chdir dir cmd [args]...   - run command in a given directory

Which means that I can not call cmake -E with a cmake-sript. Do I do
anything wrong? Should it be possible to feed cmake -E with a cmake-script?

Regards Daniel Carlson

2009/3/26 James Bigler <jamesbigler at gmail.com>

> So far as I know, the only way to set an environment variable during
> build time is to create a script during runtime that sets the
> environment variable and executes a command.
>
> configure_file(template.cmake runmycommand.cmake)
>
> add_custom_command(OUTPUT somefile
>  COMMAND ${CMAKE_COMMAND} -E ${template.cmake}
>  )
>
> and template.cmake would be:
>
> set(ENV{SOME_ENV_VAR} "${SOME_ENV_VAR_VALUE}")
> execute_process(COMMAND ${CMAKE_C_COMPILER} some args)
>
> James
>
> On Thu, Mar 26, 2009 at 1:49 PM, Carlson Daniel
> <daniel.c.carlson at gmail.com> wrote:
> > Hi!
> >
> > I want to set an environment variable that is used to state the license
> file
> > for my compiler. But, if I use the set-function the environment variable
> > will be cleared when cmake terminates. Is there a way to set an
> environment
> > variable at make file execution time?
> >
> > Daniel Carlson
> >
> > _______________________________________________
> > 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
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090329/25d72b27/attachment-0001.htm>


More information about the CMake mailing list