Hi David,
In our cmake project, we have the following scenario:
1. add_custom_command() call is as follows:
add_custom_command(TARGET ${TESTTARGETNAME}
POST_BUILD
COMMENT Test
target 1...
COMMAND
python ${CMAKE_SOURCE_DIR}/testthetargets.bat TestTarget1 ${TESTBIN}
)
2. The code in the batch file testthetargets.bat is as follows:
It invokes a project specific executable testtarget1.exe.
The source code of testtarget1.exe has calls to get few environment variables
using getenv() function call.
For example, a sample getenv() call is as follows:
target2_exe_path = getenv(TARGET2_EXE_PATH);
So, here the above getenv() call is supposed to get the value of environment
variable TARGET2_EXE_PATH.
Issue we are facing is as follows:
1. We set environment variable TARGET2_EXE_PATH using the following cmake
SET command before the add_custom_command() execution:
SET(ENV{TARGET2_EXE_PATH} C:/Test/Target2)
2. But when the add_custom_command() gets executed, we observe that the
environment variable TARGET2_EXE_PATH is not getting reflected in the above
getenv() call in the source code of testtarget1.exe. The getenv() call returns
an empty string.
But this issue does not occur when TARGET2_EXE_PATH environment variable is set
from Windows directly (i.e. from System Properties - Advanced - Environment
Variables). In that case, TARGET2_EXE_PATH gets reflected in the above getenv()
call.
So, basically the call to SET(ENV{TARGET2_EXE_PATH} C:/Test/Target2) has no
impact on the call to getenv() in the source code.
Kindly let us know if there is any other way in this case other than setting
the TARGET2_EXE_PATH environment variable from Windows directly ?
Thanks Regards
Ravi Raman
Xoriant Solutions Pvt. Ltd
4th Floor, Winchester, Hiranandani Business Park, Powai, Mumbai 400076, INDIA.
Tel: +91 22 30511000,9930100026 Extn: 2144 Voip No. 4088344495/96/97/98 Voip
Extn:1178| Fax: +91 22 3051
ravi.ra...@xoriant.commailto:ram.si...@xoriant.com|
http://www.xoriant.comhttp://www.xoriant.com/
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake