The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=14306 
====================================================================== 
Reported By:                ycollet
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   14306
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2013-07-24 03:45 EDT
Last Modified:              2013-07-24 03:45 EDT
====================================================================== 
Summary:                    environment variable set in a add_custom_target is
forgotten
Description: 
Under windows, I set an environment variable and then launch a batch file which
displays the value of the environment variable.

add_custom_target(test_env_var
                  COMMAND set MYENVVAR=this_is_a_test
                  COMMAND ${CMAKE_SOURCE_DIR}/echo.bat)

The variable is correctly displayed.

Under linux, I tried to do the same

add_custom_target(test_env_var
                  COMMAND export MYENVVAR=this_is_a_test 
                  COMMAND ${CMAKE_SOURCE_DIR}/echo.sh)

The shell script displays an empty variable.
To be able to display the environment variable, I must do like this:

add_custom_target(test_env_var
                  COMMAND export MYENVVAR=this_is_a_test &&
${CMAKE_SOURCE_DIR}/echo.sh)

And then it works.

Under linux, it's like a new shell is started each time a COMMAND is met.
Under windows, it's like a shell is started at the first COMMAND and the same
shell is reused for each COMMAND.

Steps to Reproduce: 
I added an archive with the test case.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2013-07-24 03:45 ycollet        New Issue                                    
2013-07-24 03:45 ycollet        File Added: tmp.zip                          
======================================================================

--

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://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

Reply via email to