Hi Steve
SET(VAR "C:\path\to\foo") 
->”\p” and “\f” are interpreted as escape sequences

Setting VAR via CMake GUI it is internally interpreted as:
"C:\\path\\to\\foo"

That means you have to do following to obtain what you want to:

SET(INPUT_VAR "C:\\path\\to\\foo") #or just set this variable via the interface
message(STATUS ${INPUT_VAR})

string(REGEX REPLACE "\\\\" "\\\\\\\\" OUTPUT_VAR ${INPUT_VAR}) #each "\\" == 
"\"
message(STATUS ${OUTPUT_VAR})

C:\\path\\to\\foo

(internally again: C:\\\\path\\\\to\\\\foo)

Best,
 SirAnn


Von: cmake-boun...@cmake.org [mailto:cmake-boun...@cmake.org] Im Auftrag von 
Steven Wilson
Gesendet: Samstag, 21. November 2009 02:13
An: CMake mailing list
Betreff: [CMake] string REGEX question

I have the following string in a variable "C:\path\to\foo"

I want to do something like the following:

string(REGEX REPLACE "\\" "\\\\" OUTPUT_VAR ${INPUT_VAR})

where INPUT_VAR contains the original string.

I want the result to be:

C:\\path\\to\\foo

I'm just not seeing how to make this regular expression work.   If you have any 
suggestions I would appreciate the help!

Thanks in advance,

Steve

-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
_______________________________________________
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

Reply via email to