diff --git a/Source/cmTargetCompileDefinitionsCommand.cxx b/Source/cmTargetCompileDefinitionsCommand.cxx index ba0ad5986..46c9666ef 100644 --- a/Source/cmTargetCompileDefinitionsCommand.cxx +++ b/Source/cmTargetCompileDefinitionsCommand.cxx @@ -60,7 +60,7 @@ std::string cmTargetCompileDefinitionsCommand //---------------------------------------------------------------------------- void cmTargetCompileDefinitionsCommand ::HandleDirectContent(cmTarget *tgt, const std::vector &content, - bool) + bool, bool) { tgt->AppendProperty("COMPILE_DEFINITIONS", this->Join(content).c_str()); } diff --git a/Source/cmTargetCompileDefinitionsCommand.h b/Source/cmTargetCompileDefinitionsCommand.h index 22d8fa8e9..bc58b3174 100644 --- a/Source/cmTargetCompileDefinitionsCommand.h +++ b/Source/cmTargetCompileDefinitionsCommand.h @@ -82,7 +82,7 @@ private: virtual void HandleDirectContent(cmTarget *tgt, const std::vector &content, - bool prepend); + bool prepend, bool system); virtual std::string Join(const std::vector &content); }; diff --git a/Source/cmTargetCompileOptionsCommand.cxx b/Source/cmTargetCompileOptionsCommand.cxx index e80c8456b..254acc73d 100644 --- a/Source/cmTargetCompileOptionsCommand.cxx +++ b/Source/cmTargetCompileOptionsCommand.cxx @@ -53,7 +53,7 @@ std::string cmTargetCompileOptionsCommand //---------------------------------------------------------------------------- void cmTargetCompileOptionsCommand ::HandleDirectContent(cmTarget *tgt, const std::vector &content, - bool) + bool, bool) { cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); diff --git a/Source/cmTargetCompileOptionsCommand.h b/Source/cmTargetCompileOptionsCommand.h index 87fa1a720..b9afd7169 100644 --- a/Source/cmTargetCompileOptionsCommand.h +++ b/Source/cmTargetCompileOptionsCommand.h @@ -83,7 +83,7 @@ private: virtual void HandleDirectContent(cmTarget *tgt, const std::vector &content, - bool prepend); + bool prepend, bool system); virtual std::string Join(const std::vector &content); }; diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index 12d0a515f..ee915212c 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/Source/cmTargetIncludeDirectoriesCommand.cxx @@ -15,7 +15,8 @@ bool cmTargetIncludeDirectoriesCommand ::InitialPass(std::vector 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 ::HandleDirectContent(cmTarget *tgt, const std::vector &content, - bool prepend) + bool prepend, bool system) { cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); cmValueWithOrigin entry(this->Join(content), lfbt); tgt->InsertInclude(entry, prepend); + if (system) + { + tgt->AddSystemIncludeDirectories(content); + } +} + +//---------------------------------------------------------------------------- +void cmTargetIncludeDirectoriesCommand +::HandleInterfaceContent(cmTarget *tgt, + const std::vector &content, + bool prepend, bool system) +{ + if (system) + { + // Error. + } + cmTargetPropCommandBase::HandleInterfaceContent(tgt, content, + prepend, system); } diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h index 4a1a4df34..a84ddd0cd 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.h +++ b/Source/cmTargetIncludeDirectoriesCommand.h @@ -54,7 +54,7 @@ public: virtual const char* GetFullDocumentation() const { return - " target_include_directories( [BEFORE] " + " target_include_directories( [SYSTEM] [BEFORE] " " [items1...]\n" " [ [items2...] ...])\n" "Specify include directories or targets to use when compiling a given " @@ -87,7 +87,11 @@ private: virtual void HandleDirectContent(cmTarget *tgt, const std::vector &content, - bool prepend); + bool prepend, bool system); + virtual void HandleInterfaceContent(cmTarget *tgt, + const std::vector &content, + bool prepend, bool system); + virtual std::string Join(const std::vector &content); }; diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index 64f40d6b3..287ce46a2 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -48,8 +48,20 @@ bool cmTargetPropCommandBase return false; } + bool system = false; 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; if ((flags & PROCESS_BEFORE) && args[argIndex] == "BEFORE") { @@ -66,7 +78,7 @@ bool cmTargetPropCommandBase while (argIndex < args.size()) { - if (!this->ProcessContentArgs(args, argIndex, prepend)) + if (!this->ProcessContentArgs(args, argIndex, prepend, system)) { return false; } @@ -77,7 +89,7 @@ bool cmTargetPropCommandBase //---------------------------------------------------------------------------- bool cmTargetPropCommandBase ::ProcessContentArgs(std::vector const& args, - unsigned int &argIndex, bool prepend) + unsigned int &argIndex, bool prepend, bool system) { const std::string scope = args[argIndex]; @@ -105,12 +117,12 @@ bool cmTargetPropCommandBase || args[i] == "PRIVATE" || args[i] == "INTERFACE" ) { - this->PopulateTargetProperies(scope, content, prepend); + this->PopulateTargetProperies(scope, content, prepend, system); return true; } content.push_back(args[i]); } - this->PopulateTargetProperies(scope, content, prepend); + this->PopulateTargetProperies(scope, content, prepend, system); return true; } @@ -118,22 +130,22 @@ bool cmTargetPropCommandBase void cmTargetPropCommandBase ::PopulateTargetProperies(const std::string &scope, const std::vector &content, - bool prepend) + bool prepend, bool system) { if (scope == "PRIVATE" || scope == "PUBLIC") { - this->HandleDirectContent(this->Target, content, prepend); + this->HandleDirectContent(this->Target, content, prepend, system); } if (scope == "INTERFACE" || scope == "PUBLIC") { - this->HandleInterfaceContent(this->Target, content, prepend); + this->HandleInterfaceContent(this->Target, content, prepend, system); } } //---------------------------------------------------------------------------- void cmTargetPropCommandBase::HandleInterfaceContent(cmTarget *tgt, const std::vector &content, - bool prepend) + bool prepend, bool) { if (prepend) { diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h index 9db7581fd..690582fdd 100644 --- a/Source/cmTargetPropCommandBase.h +++ b/Source/cmTargetPropCommandBase.h @@ -25,7 +25,8 @@ public: enum ArgumentFlags { NO_FLAGS = 0, - PROCESS_BEFORE = 1 + PROCESS_BEFORE = 1, + PROCESS_SYSTEM = 2 }; bool HandleArguments(std::vector const& args, @@ -38,21 +39,22 @@ protected: virtual void HandleInterfaceContent(cmTarget *tgt, const std::vector &content, - bool prepend); + bool prepend, bool system); private: virtual void HandleImportedTarget(const std::string &tgt) = 0; virtual void HandleMissingTarget(const std::string &name) = 0; virtual void HandleDirectContent(cmTarget *tgt, const std::vector &content, - bool prepend) = 0; + bool prepend, bool system) = 0; + virtual std::string Join(const std::vector &content) = 0; bool ProcessContentArgs(std::vector const& args, - unsigned int &argIndex, bool prepend); + unsigned int &argIndex, bool prepend, bool system); void PopulateTargetProperies(const std::string &scope, const std::vector &content, - bool prepend); + bool prepend, bool system); }; #endif