diff options
6 files changed, 52 insertions, 5 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 61d4ce2..b4fdcd5 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -131,11 +131,13 @@ public: SourceEntriesType SourceEntries; struct IncludeDirectoriesEntry { - IncludeDirectoriesEntry(cmsys::auto_ptr<cmCompiledGeneratorExpression> cge) - : ge(cge) + IncludeDirectoriesEntry(cmsys::auto_ptr<cmCompiledGeneratorExpression> cge, + const std::string &targetName = std::string()) + : ge(cge), TargetName(targetName) {} const cmsys::auto_ptr<cmCompiledGeneratorExpression> ge; std::vector<std::string> CachedIncludes; + const std::string TargetName; }; std::vector<IncludeDirectoriesEntry*> IncludeDirectoriesEntries; std::vector<cmValueWithOrigin> LinkInterfaceIncludeDirectoriesEntries; @@ -2818,6 +2820,28 @@ static void processIncludeDirectories(cmTarget *tgt, for(std::vector<std::string>::iterator li = entryIncludes.begin(); li != entryIncludes.end(); ++li) { + cmTarget *dependentTarget = + mf->FindTargetToUse((*it)->TargetName.c_str()); + + const bool fromImported = dependentTarget + && dependentTarget->IsImported(); + + if (fromImported && !cmSystemTools::FileExists(li->c_str())) + { + cmOStringStream e; + e << "Imported target \"" << (*it)->TargetName << "\" includes " + "non-existent path\n \"" << *li << "\"\nin its " + "INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n" + "* The path was deleted, renamed, or moved to another " + "location.\n" + "* An install or uninstall procedure did not complete " + "successfully.\n" + "* The installation package was faulty and references files it " + "does not provide.\n"; + tgt->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + return; + } + if (testIsOff && !cmSystemTools::IsOff(li->c_str())) { cmSystemTools::ConvertToUnixSlashes(*li); @@ -2913,7 +2937,8 @@ std::vector<std::string> cmTarget::GetIncludeDirectories(const char *config) it->Value + ",INTERFACE_INCLUDE_DIRECTORIES>"); this->Internal->CachedLinkInterfaceIncludeDirectoriesEntries.push_back( - new cmTargetInternals::IncludeDirectoriesEntry(cge)); + new cmTargetInternals::IncludeDirectoriesEntry(cge, + it->Value)); } } diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop.cmake b/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop.cmake index 5221a12..5772856 100644 --- a/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop.cmake +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop.cmake @@ -3,8 +3,6 @@ add_library(foo UNKNOWN IMPORTED) add_library(bar UNKNOWN IMPORTED) set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_STRING INCLUDE_DIRECTORIES) -set_property(TARGET foo PROPERTY INTERFACE_INCLUDE_DIRECTORIES foo_inc) -set_property(TARGET bar PROPERTY INTERFACE_INCLUDE_DIRECTORIES bar_inc) add_executable(user main.cpp) set_property(TARGET user PROPERTY INCLUDE_DIRECTORIES bar_inc) diff --git a/Tests/RunCMake/include_directories/ImportedTarget-result.txt b/Tests/RunCMake/include_directories/ImportedTarget-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/include_directories/ImportedTarget-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/include_directories/ImportedTarget-stderr.txt b/Tests/RunCMake/include_directories/ImportedTarget-stderr.txt new file mode 100644 index 0000000..da26052 --- /dev/null +++ b/Tests/RunCMake/include_directories/ImportedTarget-stderr.txt @@ -0,0 +1,13 @@ +CMake Error in CMakeLists.txt: + Imported target "imported" includes non-existent path + + "/does/not/exist" + + in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include: + + \* The path was deleted, renamed, or moved to another location. + + \* An install or uninstall procedure did not complete successfully. + + \* The installation package was faulty and references files it does not + provide. diff --git a/Tests/RunCMake/include_directories/ImportedTarget.cmake b/Tests/RunCMake/include_directories/ImportedTarget.cmake new file mode 100644 index 0000000..e1a20b1 --- /dev/null +++ b/Tests/RunCMake/include_directories/ImportedTarget.cmake @@ -0,0 +1,9 @@ + +project(ImportedTarget) + +add_library(testTarget "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp") + +add_library(imported UNKNOWN IMPORTED) +set_property(TARGET imported PROPERTY INTERFACE_INCLUDE_DIRECTORIES "/does/not/exist") + +target_link_libraries(testTarget imported) diff --git a/Tests/RunCMake/include_directories/RunCMakeTest.cmake b/Tests/RunCMake/include_directories/RunCMakeTest.cmake index bd299fc..1caae5c 100644 --- a/Tests/RunCMake/include_directories/RunCMakeTest.cmake +++ b/Tests/RunCMake/include_directories/RunCMakeTest.cmake @@ -6,3 +6,4 @@ run_cmake(TID-bad-target) run_cmake(SourceDirectoryInInterface) run_cmake(BinaryDirectoryInInterface) run_cmake(RelativePathInInterface) +run_cmake(ImportedTarget) |