[CMake] still issues with environment variables
William A. Hoffman
billlist at nycap.rr.com
Wed Apr 5 10:48:20 EDT 2006
At 04:38 PM 3/30/2006, Alexander Neundorf wrote:
>Hi,
>
>if I remember correctly, there were problems with using $ENV{PATH} in
>cmake files, since this would return windows-paths under windows, but
>cmake needs "cmake" paths.
>So now cmake cvs has FILE(SYSTEM_PATH ...), which reads the env variables
>and converts it into a cmake-style path, AFAIK also into a cmake list if
>it is a list.
>An option to convert a string which holds a platform specific path/list
>of paths into cmake style is still missing, or did I just not find it ?
>And the FIND_FOO() commands now can take
>FIND_LIBRARY(...
>PATHS
>ENV PATH
>... )
>as argument.
>Now let's say, I want to look in $ENV{PROGRAMFILES}/gnuwin , is this
>possible with this syntax ?
That should work, the FIND_* commands will convert paths on input.
>
>I'd prefer an approach with not too many different ways to handle all
>these things (now there are three, and one is still missing).
>
>Shouldn't this work:
>STRING(TO_CMAKE cmake_var "$ENV{PATHLIST}") ?
>
>With this the special handling in the FIND_FOO() commands and the
>FILE(SYSTEM_PATH ...) wouldn't be needed I think.
OK, so I checked in the following:
FILE(TO_CMAKE_PATH path result)
FILE(TO_NATIVE_PATH path result)
TO_CMAKE_PATH will convert path into a cmake sytle path with unix /.
The input can be a single path or a system path like "$ENV{PATH}".
Note the double quotes around the ENV call TO_CMAKE_PATH only takes
one argument.
TO_NATIVE_PATH works just like TO_CMAKE_PATH, but will convert from a
cmake style path into the native path style \ for windows and / for
UNIX.
I have removed the SYSTEM_PATH from FILE.
The FIND_* commands still support the ENV PATH stuff so you can easily reorder
the search paths in one call to the command.
Also, I think all commands that take a path as input convert them to cmake
style paths.
-Bill
More information about the CMake
mailing list