Hi all,

Does anybody know why I can't evaluate environment variable inside "REGEX
REPLACE"?

Example,
I have a value:
set(value "LD_LIBRARY_PATH=my_path:$LD_LIBRARY_PATH")

I expect:
value = "LD_LIBRARY_PATH=my_path:some_system_path_from_env"

What I'm doing:
string(REGEX REPLACE "\\$\\{([a-zA-Z0-9_]+)\\}" "$ENV{\\1}" value ${value})

Regexp works,
CMAKE_MATCH_1  and \\1 both have "LD_LIBRARY_PATH" string

string(REGEX REPLACE "\\$\\{([a-zA-Z0-9_]+)\\}" "\\1" value ${value})
will return "LD_LIBRARY_PATH=my_path:LD_LIBRARY_PATH"
but why can't I use $ENV{\\1}, or maybe I'm doing something wrong?

Thanks,
Oleg
-- 

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

Reply via email to