Merge topic 'target_include_directories-relative-SYSTEM-dirs'

8c076a8b cmTarget: Remove unused AddSystemIncludeDirectories overload
5790aca4 target_include_directories: Support relative SYSTEM include dirs (#15464)
This commit is contained in:
Brad King 2015-08-12 09:30:27 -04:00 committed by CMake Topic Stage
commit 7216742ea6
4 changed files with 28 additions and 10 deletions

View File

@ -1350,13 +1350,6 @@ cmTarget::AddSystemIncludeDirectories(const std::set<std::string> &incs)
this->SystemIncludeDirectories.insert(incs.begin(), incs.end());
}
//----------------------------------------------------------------------------
void
cmTarget::AddSystemIncludeDirectories(const std::vector<std::string> &incs)
{
this->SystemIncludeDirectories.insert(incs.begin(), incs.end());
}
#if defined(_WIN32) && !defined(__CYGWIN__)
//----------------------------------------------------------------------------
void

View File

@ -427,7 +427,6 @@ public:
cmTarget::LinkLibraryType llt) const;
void AddSystemIncludeDirectories(const std::set<std::string> &incs);
void AddSystemIncludeDirectories(const std::vector<std::string> &incs);
std::set<std::string> const & GetSystemIncludeDirectories() const
{ return this->SystemIncludeDirectories; }

View File

@ -75,7 +75,23 @@ bool cmTargetIncludeDirectoriesCommand
tgt->InsertInclude(this->Join(content), lfbt, prepend);
if (system)
{
tgt->AddSystemIncludeDirectories(content);
std::string prefix =
this->Makefile->GetCurrentSourceDirectory() + std::string("/");
std::set<std::string> sdirs;
for (std::vector<std::string>::const_iterator it = content.begin();
it != content.end(); ++it)
{
if (cmSystemTools::FileIsFullPath(it->c_str())
|| cmGeneratorExpression::Find(*it) == 0)
{
sdirs.insert(*it);
}
else
{
sdirs.insert(prefix + *it);
}
}
tgt->AddSystemIncludeDirectories(sdirs);
}
return true;
}
@ -91,7 +107,7 @@ void cmTargetIncludeDirectoriesCommand
if (system)
{
std::string joined = cmJoin(content, ";");
std::string joined = this->Join(content);
tgt->AppendProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES",
joined.c_str());
}

View File

@ -35,6 +35,16 @@ add_library(imported_consumer2 imported_consumer.cpp)
target_link_libraries(imported_consumer2 imported_consumer)
target_compile_options(imported_consumer2 PRIVATE -Werror=unused-variable)
# add a target which has a relative system include
add_library(somelib imported_consumer.cpp)
target_include_directories(somelib SYSTEM PUBLIC "systemlib_header_only")
target_compile_options(somelib PRIVATE -Werror=unused-variable)
# add a target which consumes a relative system include
add_library(otherlib upstream.cpp)
target_link_libraries(otherlib PUBLIC somelib)
target_compile_options(somelib PRIVATE -Werror=unused-variable)
macro(do_try_compile error_option)
set(TC_ARGS
IFACE_TRY_COMPILE_${error_option}