MCPcopy Create free account
hub / github.com/Kitware/CMake / FindHeaderInFramework

Method FindHeaderInFramework

Source/cmFindPathCommand.cxx:72–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72std::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 "";

Callers 1

FindFrameworkHeaderMethod · 0.95

Calls 13

FoundAtMethod · 0.80
FailedAtMethod · 0.80
FindFilesMethod · 0.80
cmStrCatFunction · 0.70
FileExistsFunction · 0.50
findMethod · 0.45
substrMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45
emptyMethod · 0.45
ValidateMethod · 0.45
GetFilesMethod · 0.45

Tested by

no test coverage detected