MantisBT - CMake
View Issue Details
0009879CMakeCMakepublic2009-11-10 12:012016-06-10 14:31
doub 
Kitware Robot 
normalmajoralways
closedmoved 
CMake-2-6 
 
0009879: find_program command doesn't take PATHEXT into account
The find_program command cannot find programs that don't use the .exe extension, for example .cmd scripts.

On Windows, the PATH environment variable is only part of what is used by the command line (and compatible programs) to determine what files are executable. The other part is the PATHEXT environment variable, which lists extensions of executable files.

The find_program command seems to assume that .exe is the only extension to check. It should be modified to extract the extension list from PATHEXT, and test all extensions listed there, in the same order as is the Windows command line evaluating them.
No tags attached.
has duplicate 0015191closed  find_program should search commands in PATHEXT env. 
related to 0011680closed Brad King FIND_PROGRAM fails to locate a versioned compiler 
Issue History
2009-11-10 12:01doubNew Issue
2010-12-14 16:11David ColeAssigned To => David Cole
2010-12-14 16:11David ColeStatusnew => assigned
2010-12-14 16:13David ColeNote Added: 0023974
2011-01-11 17:41Brad KingRelationship addedrelated to 0011680
2011-10-25 22:25David ColeStatusassigned => backlog
2011-10-25 22:28David ColeAssigned ToDavid Cole =>
2014-10-03 08:15Brad KingRelationship addedhas duplicate 0015191
2014-10-05 21:06Yoshisato YanagisawaNote Added: 0036901
2016-06-10 14:27Kitware RobotNote Added: 0041614
2016-06-10 14:27Kitware RobotStatusbacklog => resolved
2016-06-10 14:27Kitware RobotResolutionopen => moved
2016-06-10 14:27Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0023974)
David Cole   
2010-12-14 16:13   
We should pay attention to the PATHEXT variable on Windows. Good observation.

There is a workaround that works, though: name the *.cmd file explicitly as an alternate NAME for the find_program command. Just as a workaround, it works fine.
(0036901)
Yoshisato Yanagisawa   
2014-10-05 21:06   
find_program is often used in Modules for finding a certain command.
I think it straight forward solution to make CMake support PATHEXT instead of making a copy of Modules.

If using PATHEXT environment is difficult, I suggest to support at lest .com;.exe;.bat;.cmd, which is the default value of PATHEXT:
http://technet.microsoft.com/en-us/library/cc723564.aspx#XSLTsection127121120120 [^]
(0041614)
Kitware Robot   
2016-06-10 14:27   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.