[CMake] string(REGEX REPLACE …) syntax problem

Braden McDaniel braden at endoframe.com
Sat Mar 30 23:09:52 EDT 2013


I must be Doing It Wrong; but I'm not seeing how...

If I do a REGEX MATCH as follows:

> build_command(FOO)
> string(REGEX MATCH "/build ([A-Za-z]+)" BUILD_CONFIG ${FOO})
> message(STATUS "BUILD_CONFIG = ${BUILD_CONFIG}")


... I get, as expected:

> BUILD_CONFIG = /build Release

However, if I use the same expression with REGEX REPLACE:

> build_command(FOO)
> string(REGEX REPLACE "/build ([A-Za-z]+)" "\\1" BUILD_CONFIG ${FOO})
> message(STATUS "BUILD_CONFIG = ${BUILD_CONFIG}")

... BUILD_CONFIG holds the entire build command line rather than just the configuration name:

> BUILD_CONFIG = C:\PROGRA~2\MICROS~1.0\Common7\IDE\devenv.com my.sln Release /project ALL_BUILD


How am I misapplying REGEX REPLACE?

-- 
Braden McDaniel
braden at endoframe.com



More information about the CMake mailing list