[cmake-developers] find PATHS issues on Windows when Linux OS files are accessible

Alan W. Irwin irwin at beluga.phys.uvic.ca
Mon Oct 14 14:22:34 EDT 2013


On 2013-10-14 11:14-0400 Brad King wrote:

> On 10/13/2013 7:46 PM, Alan W. Irwin wrote:
>> bash.exe-3.1$ ls z:/usr/bin/lua
>> z:/usr/bin/lua
> [snip]
>> -- LUA_EXECUTABLE = /usr/bin/lua
>>
>> This is an obviously incorrect result since /usr/bin/lua does
>> not exist from the Windows system perspective, i.e.,
>
> It does exist when z: is the current working drive.  This is considered
> a feature by some users.  We've fielded bug reports in the past about it
> *not* working.

Clearly, with present cmake if the current working drive is not set to just the right
value, then you can get false results that are "found", e.g,

-- LUA_EXECUTABLE = /usr/bin/lua

bash.exe-3.1$ ls /usr/bin/lua
ls: /usr/bin/lua: No such file or directory

So at minimum the find commands should be changed to always provide
the drive letter of what was found on Windows.  If so, the above
LUA_EXECUTABLE results would have been z:/usr/bin/lua or /z/usr/bin/lua, and at
least either of those choices would have corresponded to a real file,

bash.exe-3.1$ ls z:/usr/bin/lua
z:/usr/bin/lua
bash.exe-3.1$ ls /z/usr/bin/lua
/z/usr/bin/lua

which provides much easier diagnosis of the problem when some
unexpected result (e.g., Linux executable on a Windows system) is
found.

Furthermore, there are at least two possibilities to consider for
the interpretation of PATHS values on Windows platforms.

1. Use the present approach as a convenience to users who don't
want to specify drive letters in their PATHS values even though that
can sometimes lead to unexpected results.

2. Ignore all PATHS values that don't have a specific drive letter.
This avoids the ambiguities and false results that are possible with
the first approach at the cost of some convenience. However, from a
quick survey of PATHS values used in find modules, that are officially
supported by CMake, I don't think that inconvenience would be very
large since PATH values without associated drive letters are normally
designed for Unix use only (e.g., FindLua51.cmake) and are normally
meant to be ignored in the Windows case.

You have already made the case that some Windows users would prefer
the first possibility, but, on the other hand, I think a small but
significant subset of Windows users (e.g., the Wine users of CMake at
minimum) would prefer the second possibility to avoid the inherent
ambiguity of the first approach when a partition containing a Unix OS
happens to be mounted.

Therefore, I think a good compromise would be to provide both of these
possibilities to users, with the first one being used by default, but
with the second one used instead if a specific variable or property
(called, say, IGNORE_PATHS_WITHOUT_DRIVE_LETTERS) is set to true on
Windows platforms.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________



More information about the cmake-developers mailing list