Add a SYSTEM parameter to target_include_directories (#14180)
This is similar to the include_directories(SYSTEM) signature in that it allows telling the compiler to ignore warnings from such headers.
This commit is contained in:
parent
286f227709
commit
1925cffa08
|
@ -60,7 +60,7 @@ std::string cmTargetCompileDefinitionsCommand
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmTargetCompileDefinitionsCommand
|
void cmTargetCompileDefinitionsCommand
|
||||||
::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
|
::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
|
||||||
bool)
|
bool, bool)
|
||||||
{
|
{
|
||||||
tgt->AppendProperty("COMPILE_DEFINITIONS", this->Join(content).c_str());
|
tgt->AppendProperty("COMPILE_DEFINITIONS", this->Join(content).c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ private:
|
||||||
|
|
||||||
virtual void HandleDirectContent(cmTarget *tgt,
|
virtual void HandleDirectContent(cmTarget *tgt,
|
||||||
const std::vector<std::string> &content,
|
const std::vector<std::string> &content,
|
||||||
bool prepend);
|
bool prepend, bool system);
|
||||||
virtual std::string Join(const std::vector<std::string> &content);
|
virtual std::string Join(const std::vector<std::string> &content);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ std::string cmTargetCompileOptionsCommand
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmTargetCompileOptionsCommand
|
void cmTargetCompileOptionsCommand
|
||||||
::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
|
::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
|
||||||
bool)
|
bool, bool)
|
||||||
{
|
{
|
||||||
cmListFileBacktrace lfbt;
|
cmListFileBacktrace lfbt;
|
||||||
this->Makefile->GetBacktrace(lfbt);
|
this->Makefile->GetBacktrace(lfbt);
|
||||||
|
|
|
@ -83,7 +83,7 @@ private:
|
||||||
|
|
||||||
virtual void HandleDirectContent(cmTarget *tgt,
|
virtual void HandleDirectContent(cmTarget *tgt,
|
||||||
const std::vector<std::string> &content,
|
const std::vector<std::string> &content,
|
||||||
bool prepend);
|
bool prepend, bool system);
|
||||||
virtual std::string Join(const std::vector<std::string> &content);
|
virtual std::string Join(const std::vector<std::string> &content);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
bool cmTargetIncludeDirectoriesCommand
|
bool cmTargetIncludeDirectoriesCommand
|
||||||
::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
|
::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
|
||||||
{
|
{
|
||||||
return this->HandleArguments(args, "INCLUDE_DIRECTORIES", PROCESS_BEFORE);
|
return this->HandleArguments(args, "INCLUDE_DIRECTORIES",
|
||||||
|
ArgumentFlags(PROCESS_BEFORE | PROCESS_SYSTEM));
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -65,10 +66,28 @@ std::string cmTargetIncludeDirectoriesCommand
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmTargetIncludeDirectoriesCommand
|
void cmTargetIncludeDirectoriesCommand
|
||||||
::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
|
::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
|
||||||
bool prepend)
|
bool prepend, bool system)
|
||||||
{
|
{
|
||||||
cmListFileBacktrace lfbt;
|
cmListFileBacktrace lfbt;
|
||||||
this->Makefile->GetBacktrace(lfbt);
|
this->Makefile->GetBacktrace(lfbt);
|
||||||
cmValueWithOrigin entry(this->Join(content), lfbt);
|
cmValueWithOrigin entry(this->Join(content), lfbt);
|
||||||
tgt->InsertInclude(entry, prepend);
|
tgt->InsertInclude(entry, prepend);
|
||||||
|
if (system)
|
||||||
|
{
|
||||||
|
tgt->AddSystemIncludeDirectories(content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmTargetIncludeDirectoriesCommand
|
||||||
|
::HandleInterfaceContent(cmTarget *tgt,
|
||||||
|
const std::vector<std::string> &content,
|
||||||
|
bool prepend, bool system)
|
||||||
|
{
|
||||||
|
if (system)
|
||||||
|
{
|
||||||
|
// Error.
|
||||||
|
}
|
||||||
|
cmTargetPropCommandBase::HandleInterfaceContent(tgt, content,
|
||||||
|
prepend, system);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ public:
|
||||||
virtual const char* GetFullDocumentation() const
|
virtual const char* GetFullDocumentation() const
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
" target_include_directories(<target> [BEFORE] "
|
" target_include_directories(<target> [SYSTEM] [BEFORE] "
|
||||||
"<INTERFACE|PUBLIC|PRIVATE> [items1...]\n"
|
"<INTERFACE|PUBLIC|PRIVATE> [items1...]\n"
|
||||||
" [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])\n"
|
" [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])\n"
|
||||||
"Specify include directories or targets to use when compiling a given "
|
"Specify include directories or targets to use when compiling a given "
|
||||||
|
@ -87,7 +87,11 @@ private:
|
||||||
|
|
||||||
virtual void HandleDirectContent(cmTarget *tgt,
|
virtual void HandleDirectContent(cmTarget *tgt,
|
||||||
const std::vector<std::string> &content,
|
const std::vector<std::string> &content,
|
||||||
bool prepend);
|
bool prepend, bool system);
|
||||||
|
virtual void HandleInterfaceContent(cmTarget *tgt,
|
||||||
|
const std::vector<std::string> &content,
|
||||||
|
bool prepend, bool system);
|
||||||
|
|
||||||
virtual std::string Join(const std::vector<std::string> &content);
|
virtual std::string Join(const std::vector<std::string> &content);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,20 @@ bool cmTargetPropCommandBase
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool system = false;
|
||||||
unsigned int argIndex = 1;
|
unsigned int argIndex = 1;
|
||||||
|
|
||||||
|
if ((flags & PROCESS_SYSTEM) && args[argIndex] == "SYSTEM")
|
||||||
|
{
|
||||||
|
if (args.size() < 4)
|
||||||
|
{
|
||||||
|
this->SetError("called with incorrect number of arguments");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
system = true;
|
||||||
|
++argIndex;
|
||||||
|
}
|
||||||
|
|
||||||
bool prepend = false;
|
bool prepend = false;
|
||||||
if ((flags & PROCESS_BEFORE) && args[argIndex] == "BEFORE")
|
if ((flags & PROCESS_BEFORE) && args[argIndex] == "BEFORE")
|
||||||
{
|
{
|
||||||
|
@ -66,7 +78,7 @@ bool cmTargetPropCommandBase
|
||||||
|
|
||||||
while (argIndex < args.size())
|
while (argIndex < args.size())
|
||||||
{
|
{
|
||||||
if (!this->ProcessContentArgs(args, argIndex, prepend))
|
if (!this->ProcessContentArgs(args, argIndex, prepend, system))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +89,7 @@ bool cmTargetPropCommandBase
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool cmTargetPropCommandBase
|
bool cmTargetPropCommandBase
|
||||||
::ProcessContentArgs(std::vector<std::string> const& args,
|
::ProcessContentArgs(std::vector<std::string> const& args,
|
||||||
unsigned int &argIndex, bool prepend)
|
unsigned int &argIndex, bool prepend, bool system)
|
||||||
{
|
{
|
||||||
const std::string scope = args[argIndex];
|
const std::string scope = args[argIndex];
|
||||||
|
|
||||||
|
@ -105,12 +117,12 @@ bool cmTargetPropCommandBase
|
||||||
|| args[i] == "PRIVATE"
|
|| args[i] == "PRIVATE"
|
||||||
|| args[i] == "INTERFACE" )
|
|| args[i] == "INTERFACE" )
|
||||||
{
|
{
|
||||||
this->PopulateTargetProperies(scope, content, prepend);
|
this->PopulateTargetProperies(scope, content, prepend, system);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
content.push_back(args[i]);
|
content.push_back(args[i]);
|
||||||
}
|
}
|
||||||
this->PopulateTargetProperies(scope, content, prepend);
|
this->PopulateTargetProperies(scope, content, prepend, system);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,22 +130,22 @@ bool cmTargetPropCommandBase
|
||||||
void cmTargetPropCommandBase
|
void cmTargetPropCommandBase
|
||||||
::PopulateTargetProperies(const std::string &scope,
|
::PopulateTargetProperies(const std::string &scope,
|
||||||
const std::vector<std::string> &content,
|
const std::vector<std::string> &content,
|
||||||
bool prepend)
|
bool prepend, bool system)
|
||||||
{
|
{
|
||||||
if (scope == "PRIVATE" || scope == "PUBLIC")
|
if (scope == "PRIVATE" || scope == "PUBLIC")
|
||||||
{
|
{
|
||||||
this->HandleDirectContent(this->Target, content, prepend);
|
this->HandleDirectContent(this->Target, content, prepend, system);
|
||||||
}
|
}
|
||||||
if (scope == "INTERFACE" || scope == "PUBLIC")
|
if (scope == "INTERFACE" || scope == "PUBLIC")
|
||||||
{
|
{
|
||||||
this->HandleInterfaceContent(this->Target, content, prepend);
|
this->HandleInterfaceContent(this->Target, content, prepend, system);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmTargetPropCommandBase::HandleInterfaceContent(cmTarget *tgt,
|
void cmTargetPropCommandBase::HandleInterfaceContent(cmTarget *tgt,
|
||||||
const std::vector<std::string> &content,
|
const std::vector<std::string> &content,
|
||||||
bool prepend)
|
bool prepend, bool)
|
||||||
{
|
{
|
||||||
if (prepend)
|
if (prepend)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,7 +25,8 @@ public:
|
||||||
|
|
||||||
enum ArgumentFlags {
|
enum ArgumentFlags {
|
||||||
NO_FLAGS = 0,
|
NO_FLAGS = 0,
|
||||||
PROCESS_BEFORE = 1
|
PROCESS_BEFORE = 1,
|
||||||
|
PROCESS_SYSTEM = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
bool HandleArguments(std::vector<std::string> const& args,
|
bool HandleArguments(std::vector<std::string> const& args,
|
||||||
|
@ -38,21 +39,22 @@ protected:
|
||||||
|
|
||||||
virtual void HandleInterfaceContent(cmTarget *tgt,
|
virtual void HandleInterfaceContent(cmTarget *tgt,
|
||||||
const std::vector<std::string> &content,
|
const std::vector<std::string> &content,
|
||||||
bool prepend);
|
bool prepend, bool system);
|
||||||
private:
|
private:
|
||||||
virtual void HandleImportedTarget(const std::string &tgt) = 0;
|
virtual void HandleImportedTarget(const std::string &tgt) = 0;
|
||||||
virtual void HandleMissingTarget(const std::string &name) = 0;
|
virtual void HandleMissingTarget(const std::string &name) = 0;
|
||||||
|
|
||||||
virtual void HandleDirectContent(cmTarget *tgt,
|
virtual void HandleDirectContent(cmTarget *tgt,
|
||||||
const std::vector<std::string> &content,
|
const std::vector<std::string> &content,
|
||||||
bool prepend) = 0;
|
bool prepend, bool system) = 0;
|
||||||
|
|
||||||
virtual std::string Join(const std::vector<std::string> &content) = 0;
|
virtual std::string Join(const std::vector<std::string> &content) = 0;
|
||||||
|
|
||||||
bool ProcessContentArgs(std::vector<std::string> const& args,
|
bool ProcessContentArgs(std::vector<std::string> const& args,
|
||||||
unsigned int &argIndex, bool prepend);
|
unsigned int &argIndex, bool prepend, bool system);
|
||||||
void PopulateTargetProperies(const std::string &scope,
|
void PopulateTargetProperies(const std::string &scope,
|
||||||
const std::vector<std::string> &content,
|
const std::vector<std::string> &content,
|
||||||
bool prepend);
|
bool prepend, bool system);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue