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

Method FindFullPath

Source/cmSourceFile.cxx:136–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136bool cmSourceFile::FindFullPath(std::string* error,
137 std::string* cmp0115Warning)
138{
139 // If the file is generated compute the location without checking on disk.
140 // Note: We also check for a locally set GENERATED property, because
141 // it might have been set before policy CMP0118 (or CMP0163) was set
142 // to NEW.
143 if (this->GetIsGenerated(CheckScope::GlobalAndLocal)) {
144 // The file is either already a full path or is relative to the
145 // build directory for the target.
146 this->Location.DirectoryUseBinary();
147 this->FullPath = this->Location.GetFullPath();
148 this->FindFullPathFailed = false;
149 return true;
150 }
151
152 // If this method has already failed once do not try again.
153 if (this->FindFullPathFailed) {
154 return false;
155 }
156
157 // The file is not generated. It must exist on disk.
158 cmMakefile const* makefile = this->Location.GetMakefile();
159 // Location path
160 std::string const& lPath = this->Location.GetFullPath();
161 // List of extension lists
162 std::vector<std::string> exts =
163 makefile->GetCMakeInstance()->GetAllExtensions();
164 auto cmp0115 = makefile->GetPolicyStatus(cmPolicies::CMP0115);
165 auto cmp0163 = makefile->GetPolicyStatus(cmPolicies::CMP0163);
166 auto cmp0118 = makefile->GetPolicyStatus(cmPolicies::CMP0118);
167 bool const cmp0163new =
168 cmp0163 != cmPolicies::OLD && cmp0163 != cmPolicies::WARN;
169 bool const cmp0118new =
170 cmp0163new || (cmp0118 != cmPolicies::OLD && cmp0118 != cmPolicies::WARN);
171
172 // Tries to find the file in a given directory
173 auto findInDir = [this, &exts, &lPath, cmp0115, cmp0115Warning, cmp0118new,
174 makefile](std::string const& dir) -> bool {
175 // Compute full path
176 std::string const fullPath = cmSystemTools::CollapseFullPath(lPath, dir);
177 // Try full path
178 // Is this file globally marked as generated? Then mark so locally.
179 if (cmp0118new &&
180 makefile->GetGlobalGenerator()->IsGeneratedFile(fullPath)) {
181 this->IsGenerated = true;
182 }
183 if (this->IsGenerated || cmSystemTools::FileExists(fullPath)) {
184 this->FullPath = fullPath;
185 return true;
186 }
187 // This has to be an if statement due to a bug in Oracle Developer Studio.
188 // See https://community.oracle.com/tech/developers/discussion/4476246/
189 // for details.
190 if (cmp0115 == cmPolicies::OLD || cmp0115 == cmPolicies::WARN) {
191 // Try full path with extension
192 for (std::string const& ext : exts) {
193 if (!ext.empty()) {

Callers 1

cmSourceFile.cxxFile · 0.80

Calls 15

GetIsGeneratedMethod · 0.95
moveFunction · 0.85
DirectoryUseBinaryMethod · 0.80
GetAllExtensionsMethod · 0.80
IsGeneratedFileMethod · 0.80
DirectoryIsAmbiguousMethod · 0.80
cmStrCatFunction · 0.70
FileExistsFunction · 0.50
GetFullPathMethod · 0.45
GetMakefileMethod · 0.45
GetCMakeInstanceMethod · 0.45
GetPolicyStatusMethod · 0.45

Tested by

no test coverage detected