| 328 | |
| 329 | namespace { |
| 330 | bool IncludeByVariable(cmExecutionStatus& status, std::string const& variable) |
| 331 | { |
| 332 | cmMakefile& mf = status.GetMakefile(); |
| 333 | cmValue include = mf.GetDefinition(variable); |
| 334 | if (!include) { |
| 335 | return true; |
| 336 | } |
| 337 | cmList includeFiles{ *include }; |
| 338 | |
| 339 | bool failed = false; |
| 340 | for (auto filePath : includeFiles) { |
| 341 | // Any relative path without a .cmake extension is checked for valid cmake |
| 342 | // modules. This logic should be consistent with CMake's include() command. |
| 343 | // Otherwise default to checking relative path w.r.t. source directory |
| 344 | if (!cmSystemTools::FileIsFullPath(filePath) && |
| 345 | !cmHasLiteralSuffix(filePath, ".cmake")) { |
| 346 | std::string mfile = mf.GetModulesFile(cmStrCat(filePath, ".cmake")); |
| 347 | if (mfile.empty()) { |
| 348 | status.SetError( |
| 349 | cmStrCat("could not find requested module:\n ", filePath)); |
| 350 | failed = true; |
| 351 | continue; |
| 352 | } |
| 353 | filePath = mfile; |
| 354 | } |
| 355 | std::string includeFile = cmSystemTools::CollapseFullPath( |
| 356 | filePath, mf.GetCurrentSourceDirectory()); |
| 357 | if (!cmSystemTools::FileExists(includeFile)) { |
| 358 | status.SetError( |
| 359 | cmStrCat("could not find requested file:\n ", filePath)); |
| 360 | failed = true; |
| 361 | continue; |
| 362 | } |
| 363 | if (cmSystemTools::FileIsDirectory(includeFile)) { |
| 364 | status.SetError( |
| 365 | cmStrCat("requested file is a directory:\n ", filePath)); |
| 366 | failed = true; |
| 367 | continue; |
| 368 | } |
| 369 | |
| 370 | bool const readit = mf.ReadDependentFile(filePath); |
| 371 | if (readit) { |
| 372 | // If the included file ran successfully, continue to the next file |
| 373 | continue; |
| 374 | } |
| 375 | |
| 376 | if (cmSystemTools::GetFatalErrorOccurred()) { |
| 377 | failed = true; |
| 378 | continue; |
| 379 | } |
| 380 | |
| 381 | status.SetError(cmStrCat("could not load requested file:\n ", filePath)); |
| 382 | failed = true; |
| 383 | } |
| 384 | // At this point all files were processed |
| 385 | return !failed; |
| 386 | } |
| 387 |
no test coverage detected
searching dependent graphs…