[CMake] problem on windows with $ENV{something}

Amitha Perera perera at cs.rpi.edu
Mon Feb 13 15:36:16 EST 2006


David Cole wrote:
> I'd have to vote for this as a "feature" actually. I think 
> "$ENV{something}" should evaluate to exactly the value of the 
> environment variable and nothing more. Any transformations have to be up 
> to the user because we can't know what the environment variable 
> represents...

I second this position.

> Having said that... perhaps there should be an easier way to say "take 
> this value that I got from the environment and transform it into a CMake 
> friendly path"...
> 
> The "string(regex replace ...)" technique works, but has to be 
> conditonalized on ... what? WIN32 and NOT UNIX...? Finding a "\\" in the 
> result of $ENV{something}"? What's the ultimate cross-platform 
> recommendation?

How about a "STRING(CONVERT_PATH ..." that will assume the given path list
is in the native format, and will unconditionally convert it to the CMake
format? So, on a Unix CMake, it'll convert ":" to ";"; on a Windows CMake,
it'll convert "\" to "/", and deal appropriately with quoted paths. On a Mac,
it'll do as a Mac needs to be done. I think Cygwin == Unix as far as paths
are concerned.

Yes, it could all probably be done in a macro, but CMake itself probably knows
better what the actual platform is, or is going to be.

Amitha.


More information about the CMake mailing list