| 70 | } |
| 71 | |
| 72 | std::string cmFindPathCommand::FindHeaderInFramework( |
| 73 | std::string const& file, std::string const& dir) const |
| 74 | { |
| 75 | std::string fileName = file; |
| 76 | std::string frameWorkName; |
| 77 | std::string::size_type pos = fileName.find('/'); |
| 78 | // if there is a / in the name try to find the header as a framework |
| 79 | // For example bar/foo.h would look for: |
| 80 | // bar.framework/Headers/foo.h |
| 81 | if (pos != std::string::npos) { |
| 82 | // remove the name from the slash; |
| 83 | fileName = fileName.substr(pos + 1); |
| 84 | frameWorkName = file; |
| 85 | frameWorkName = |
| 86 | frameWorkName.substr(0, frameWorkName.size() - fileName.size() - 1); |
| 87 | // if the framework has a path in it then just use the filename |
| 88 | if (frameWorkName.find('/') != std::string::npos) { |
| 89 | fileName = file; |
| 90 | frameWorkName.clear(); |
| 91 | } |
| 92 | if (!frameWorkName.empty()) { |
| 93 | std::string fpath = cmStrCat(dir, frameWorkName, ".framework"); |
| 94 | std::string intPath = cmStrCat(fpath, "/Headers/", fileName); |
| 95 | if (cmSystemTools::FileExists(intPath) && |
| 96 | this->Validate(this->IncludeFileInPath ? intPath : fpath)) { |
| 97 | if (this->DebugState) { |
| 98 | this->DebugState->FoundAt(intPath); |
| 99 | } |
| 100 | if (this->IncludeFileInPath) { |
| 101 | return intPath; |
| 102 | } |
| 103 | return fpath; |
| 104 | } |
| 105 | if (this->DebugState) { |
| 106 | this->DebugState->FailedAt(intPath); |
| 107 | } |
| 108 | } |
| 109 | } |
| 110 | // if it is not found yet or not a framework header, then do a glob search |
| 111 | // for all frameworks in the directory: dir/*.framework/Headers/<file> |
| 112 | std::string glob = cmStrCat(dir, "*.framework/Headers/", file); |
| 113 | cmsys::Glob globIt; |
| 114 | globIt.FindFiles(glob); |
| 115 | std::vector<std::string> files = globIt.GetFiles(); |
| 116 | if (!files.empty()) { |
| 117 | std::string fheader = cmSystemTools::ToNormalizedPathOnDisk(files[0]); |
| 118 | if (this->DebugState) { |
| 119 | this->DebugState->FoundAt(fheader); |
| 120 | } |
| 121 | if (this->IncludeFileInPath) { |
| 122 | return fheader; |
| 123 | } |
| 124 | fheader.resize(fheader.size() - file.size()); |
| 125 | return fheader; |
| 126 | } |
| 127 | |
| 128 | // No frameworks matched the glob, so nothing more to add to debug.FailedAt() |
| 129 | return ""; |
no test coverage detected