[CMake] windowsproblem with backslashes in path variables - how to avoid?

Sören Freudiger muffmolch at gmx.de
Tue Aug 30 05:48:44 EDT 2005


Within windows we have this stupid problem with the backslash character
instead of slash character for seperate folders:

Enviroment variabels often are something like "C:\Programs\MPI"

If I do something like:
INCLUDE_DIRECTORIES( $ENV{MPI_DIR}/include )
Then folowing error occurs:
"Cmake Error: Invalid escape sequence \P"

Yeah that's right, because it should be "C:\\Programs\\MPI"       
Or better: "C:/Programs/MPI" 

I tried 
STRING(REGEX REPLACE "\" "/" TEST_VARIABLE "${TEST_VARIABLE}")
and
STRING(REGEX REPLACE "\\" "/" TEST_VARIABLE "${TEST_VARIABLE}")  
but all of this ends up in an error.

But if I'm doing:
SET(TEST1 $ENV{MPI_DIR})
MESSAGE(&{TEST1 }) --> C:\Programs\MPI
SET(TEST1 ${EMPTY})  --> EMPTY wasn't defined before
MESSAGE(&{TEST1 }) --> C:/Programs/MPI

So what's the standard way to avoid this problem?

Best regards,
SirAnn	 




More information about the CMake mailing list