[CMake] Setting an environment variable when executing make script

James Bigler jamesbigler at gmail.com
Thu Mar 26 17:27:39 EDT 2009


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
>


More information about the CMake mailing list