summaryrefslogtreecommitdiffstats
path: root/Source/cmFindProgramCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-10-29 21:50:19 (GMT)
committerBrad King <brad.king@kitware.com>2015-10-30 11:40:46 (GMT)
commit31e6571cca3267cf1f5e17df7c985521211885ef (patch)
treebc48bebaf259619bb7baae1681f375f537a40510 /Source/cmFindProgramCommand.cxx
parent8ea7611bc3650c75c86d22a3127cb117dbcaa9be (diff)
downloadCMake-31e6571cca3267cf1f5e17df7c985521211885ef.zip
CMake-31e6571cca3267cf1f5e17df7c985521211885ef.tar.gz
CMake-31e6571cca3267cf1f5e17df7c985521211885ef.tar.bz2
find_program: Fix regression in finding an already-known path
Changes in commit v3.4.0-rc1~124^2~1 (cmFindProgramCommand: Re-implement search using more flexible approach, 2015-09-01) did not preserve the behavior of looking for the given name with no search path at all. Fix this and add a test case covering finding an absolute path with no search directories.
Diffstat (limited to 'Source/cmFindProgramCommand.cxx')
-rw-r--r--Source/cmFindProgramCommand.cxx13
1 files changed, 13 insertions, 0 deletions
diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx
index e64ed87..219ad48 100644
--- a/Source/cmFindProgramCommand.cxx
+++ b/Source/cmFindProgramCommand.cxx
@@ -176,6 +176,13 @@ std::string cmFindProgramCommand::FindNormalProgramNamesPerDir()
{
helper.AddName(*ni);
}
+
+ // Check for the names themselves (e.g. absolute paths).
+ if (helper.CheckDirectory(std::string()))
+ {
+ return helper.BestPath;
+ }
+
// Search every directory.
for (std::vector<std::string>::const_iterator
p = this->SearchPaths.begin(); p != this->SearchPaths.end(); ++p)
@@ -200,6 +207,12 @@ std::string cmFindProgramCommand::FindNormalProgramDirsPerName()
// Switch to searching for this name.
helper.SetName(*ni);
+ // Check for the name by itself (e.g. an absolute path).
+ if (helper.CheckDirectory(std::string()))
+ {
+ return helper.BestPath;
+ }
+
// Search every directory.
for (std::vector<std::string>::const_iterator
p = this->SearchPaths.begin();