From c62daf9cda6a36d5434dfbcd6ca3dbb3537a935b Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Sun, 10 Jun 2018 08:24:49 +0300 Subject: CppTools: Do not use -isystem for header paths in the repository Clang uses mmap for system headers. This locks the header files on Windows. If the project file is not in the root directory of the repository, and it uses header files that are outside its directory, but in the repository, Git operations like checkout, rebase etc. can fail because the header files are locked. Change-Id: If8a258234479fc70ca0a8384bf24c68d767dbeaa Reviewed-by: Nikolai Kosjar --- src/plugins/cpptools/compileroptionsbuilder.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/plugins/cpptools/compileroptionsbuilder.cpp b/src/plugins/cpptools/compileroptionsbuilder.cpp index a2ed615894..1188075a2a 100644 --- a/src/plugins/cpptools/compileroptionsbuilder.cpp +++ b/src/plugins/cpptools/compileroptionsbuilder.cpp @@ -26,6 +26,7 @@ #include "compileroptionsbuilder.h" #include +#include #include #include @@ -137,7 +138,12 @@ static Utils::FileName projectTopLevelDirectory(const ProjectPart &projectPart) { if (!projectPart.project) return Utils::FileName(); - return projectPart.project->projectDirectory(); + const Utils::FileName result = projectPart.project->projectDirectory(); + const Utils::FileName vcsTopLevel = Utils::FileName::fromString( + Core::VcsManager::findTopLevelForDirectory(result.toString())); + if (result.isChildOf(vcsTopLevel)) + return vcsTopLevel; + return result; } void CompilerOptionsBuilder::addHeaderPathOptions() @@ -165,10 +171,13 @@ void CompilerOptionsBuilder::addHeaderPathOptions() // intentional fall-through: case HeaderPath::IncludePath: path = absoluteDirectory(headerPath.path); - if (path == projectDirectory || path.isChildOf(projectDirectory)) + if (projectDirectory.isEmpty() + || path == projectDirectory + || path.isChildOf(projectDirectory)) { prefix = defaultPrefix; - else + } else { prefix = SYSTEM_INCLUDE_PREFIX; + } break; } -- cgit v1.2.1