| 2913 | } |
| 2914 | |
| 2915 | bool cmFindPackageCommand::FindConfigFile(std::string const& dir, |
| 2916 | PackageDescriptionType type, |
| 2917 | std::string& file, |
| 2918 | FoundPackageMode& foundMode) |
| 2919 | { |
| 2920 | for (auto const& config : this->Configs) { |
| 2921 | if (type != pdt::Any && config.Type != type) { |
| 2922 | continue; |
| 2923 | } |
| 2924 | file = cmStrCat(dir, '/', config.Name); |
| 2925 | if (this->DebugModeEnabled()) { |
| 2926 | this->DebugBuffer = cmStrCat(this->DebugBuffer, " ", file, '\n'); |
| 2927 | } |
| 2928 | if (cmSystemTools::FileExists(file, true)) { |
| 2929 | // Allow resolving symlinks when the config file is found through a link |
| 2930 | if (this->UseRealPath) { |
| 2931 | file = cmSystemTools::GetRealPath(file); |
| 2932 | } else { |
| 2933 | file = cmSystemTools::ToNormalizedPathOnDisk(file); |
| 2934 | } |
| 2935 | if (this->CheckVersion(file)) { |
| 2936 | foundMode = cmFindPackageCommand::FoundMode(config.Type); |
| 2937 | return true; |
| 2938 | } |
| 2939 | this->ConsideredPaths.emplace_back( |
| 2940 | file, cmFindPackageCommand::FoundMode(type), |
| 2941 | this->ConsideredConfigs.back().result, |
| 2942 | this->ConsideredConfigs.back().message); |
| 2943 | } else { |
| 2944 | this->ConsideredPaths.emplace_back( |
| 2945 | file, cmFindPackageCommand::FoundMode(type), SearchResult::NoExist); |
| 2946 | } |
| 2947 | } |
| 2948 | return false; |
| 2949 | } |
| 2950 | |
| 2951 | bool cmFindPackageCommand::CheckVersion(std::string const& config_file) |
| 2952 | { |
no test coverage detected