diff options
author | sanchayanghosh <sanchayanghosh.007@gmail.com> | 2020-09-30 02:39:46 +0530 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-09-30 11:50:23 -0400 |
commit | 2ff16930662474b8450c83d06884f3f1b3f3c747 (patch) | |
tree | 839c77ad49af8252263a3976215e22e9ff20ad39 /Source/cmFindPackageCommand.cxx | |
parent | af048185b1b4c20ddda2998e448c81449b803944 (diff) | |
download | cmake-2ff16930662474b8450c83d06884f3f1b3f3c747.tar.gz |
find_package: avoid showing files as directories when searching config files
Teach `cmFileListGeneratorBase::Consider` to skip non-directories so
that all call sites get the check.
Fixes: #21212
Diffstat (limited to 'Source/cmFindPackageCommand.cxx')
-rw-r--r-- | Source/cmFindPackageCommand.cxx | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 51137b3829..4ae493e8f8 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -1971,6 +1971,9 @@ cmFileListGeneratorBase* cmFileListGeneratorBase::SetNext( bool cmFileListGeneratorBase::Consider(std::string const& fullPath, cmFileList& listing) { + if (!cmSystemTools::FileIsDirectory(fullPath)) { + return false; + } if (this->Next) { return this->Next->Search(fullPath + "/", listing); } @@ -2225,10 +2228,8 @@ private: // Look for directories among the matches. for (std::string const& f : files) { - if (cmSystemTools::FileIsDirectory(f)) { - if (this->Consider(f, lister)) { - return true; - } + if (this->Consider(f, lister)) { + return true; } } return false; |