[CMake] string REGEX question

"Sören Freudiger" muffmolch at gmx.de
Sat Nov 21 04:11:35 EST 2009


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-bounces at cmake.org [mailto:cmake-bounces at 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


More information about the CMake mailing list