diff options
author | Brad King <brad.king@kitware.com> | 2022-05-20 13:12:49 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-05-20 13:12:57 (GMT) |
commit | 918e98e1313173b25dda662a447f9c0754990f31 (patch) | |
tree | 5ea9e1106bf20898ea5e53fd2df261a82240c9db /Source/cmVisualStudio10TargetGenerator.cxx | |
parent | 88ed9355f51d29d3aec9c6197217e7bf6c1c4bbb (diff) | |
parent | 7a2496daad2ed9d16c54ce7cb64694caaafc7f70 (diff) | |
download | CMake-918e98e1313173b25dda662a447f9c0754990f31.zip CMake-918e98e1313173b25dda662a447f9c0754990f31.tar.gz CMake-918e98e1313173b25dda662a447f9c0754990f31.tar.bz2 |
Merge topic 'vs-system-include'
7a2496daad VS: Add support for SYSTEM include directories
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7238
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 1739b5a..60b89df 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -3356,6 +3356,43 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( } } + // Get includes for this target + if (!this->LangForClCompile.empty()) { + auto includeList = this->GetIncludes(configName, this->LangForClCompile); + + auto sysIncludeFlag = this->Makefile->GetDefinition( + cmStrCat("CMAKE_INCLUDE_SYSTEM_FLAG_", this->LangForClCompile)); + + if (sysIncludeFlag) { + bool gotOneSys = false; + for (auto i : includeList) { + cmSystemTools::ConvertToUnixSlashes(i); + if (this->GeneratorTarget->IsSystemIncludeDirectory( + i, configName, this->LangForClCompile)) { + auto flag = cmTrimWhitespace(*sysIncludeFlag); + if (this->MSTools) { + cmSystemTools::ReplaceString(flag, "-external:I", "/external:I"); + } + clOptions.AppendFlagString("AdditionalOptions", + cmStrCat(flag, " \"", i, '"')); + gotOneSys = true; + } else { + clOptions.AddInclude(i); + } + } + + if (gotOneSys) { + if (auto sysIncludeFlagWarning = this->Makefile->GetDefinition( + cmStrCat("_CMAKE_INCLUDE_SYSTEM_FLAG_", this->LangForClCompile, + "_WARNING"))) { + flags = cmStrCat(flags, ' ', *sysIncludeFlagWarning); + } + } + } else { + clOptions.AddIncludes(includeList); + } + } + clOptions.Parse(flags); clOptions.Parse(defineFlags); std::vector<std::string> targetDefines; @@ -3382,12 +3419,6 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( clOptions.AppendFlag("DefineConstants", targetDefines); } - // Get includes for this target - if (!this->LangForClCompile.empty()) { - clOptions.AddIncludes( - this->GetIncludes(configName, this->LangForClCompile)); - } - if (this->MSTools) { clOptions.SetVerboseMakefile( this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); |