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

Method CheckInterfaceDirs

Source/cmExportInstallFileGenerator.cxx:416–490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

414}
415
416bool cmExportInstallFileGenerator::CheckInterfaceDirs(
417 std::string const& prepro, cmGeneratorTarget const* target,
418 std::string const& prop) const
419{
420 std::string const& installDir =
421 target->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
422 std::string const& topSourceDir =
423 target->GetLocalGenerator()->GetSourceDirectory();
424 std::string const& topBinaryDir =
425 target->GetLocalGenerator()->GetBinaryDirectory();
426
427 std::vector<std::string> parts;
428 cmGeneratorExpression::Split(prepro, parts);
429
430 bool const inSourceBuild = topSourceDir == topBinaryDir;
431
432 bool hadFatalError = false;
433
434 for (std::string const& li : parts) {
435 size_t genexPos = cmGeneratorExpression::Find(li);
436 if (genexPos == 0) {
437 continue;
438 }
439 if (cmHasPrefix(li, this->GetImportPrefixWithSlash())) {
440 continue;
441 }
442 if (genexPos != std::string::npos) {
443 hadFatalError = true;
444 }
445 if (!cmSystemTools::FileIsFullPath(li)) {
446 std::ostringstream e;
447 /* clang-format off */
448 e << "Target \"" << target->GetName() << "\" " << prop <<
449 " property contains relative path:\n"
450 " \"" << li << "\"";
451 /* clang-format on */
452 target->GetLocalGenerator()->IssueMessage(MessageType::FATAL_ERROR,
453 e.str());
454 }
455 bool inBinary = isSubDirectory(li, topBinaryDir);
456 bool inSource = isSubDirectory(li, topSourceDir);
457 if (isSubDirectory(li, installDir)) {
458 // The include directory is inside the install tree. If the
459 // install tree is inside the source tree or build tree then do not
460 // fall through to the checks below that the include directory is not
461 // also inside the source tree or build tree.
462 if ((!inBinary || isSubDirectory(installDir, topBinaryDir)) &&
463 (!inSource || isSubDirectory(installDir, topSourceDir))) {
464 continue;
465 }
466 }
467 if (inBinary) {
468 std::ostringstream e;
469 /* clang-format off */
470 e << "Target \"" << target->GetName() << "\" " << prop <<
471 " property contains path:\n"
472 " \"" << li << "\"\nwhich is prefixed in the build directory.";
473 /* clang-format on */

Calls 7

cmHasPrefixFunction · 0.85
isSubDirectoryFunction · 0.85
strMethod · 0.80
GetLocalGeneratorMethod · 0.45
GetNameMethod · 0.45
IssueMessageMethod · 0.45

Tested by

no test coverage detected