Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Improvements:
- Improve CMake syntax highlighting with command-scoped keyword rules, expanded variable recognition, and better generator-expression support. Remove obsolete deprecated-keyword entries that caused false positives on user-defined names. [#4709](https://github.com/microsoft/vscode-cmake-tools/issues/4709) [#4508](https://github.com/microsoft/vscode-cmake-tools/issues/4508) [#4613](https://github.com/microsoft/vscode-cmake-tools/issues/4613)
- Add MSVC linker error problem matching to the Problems pane. [#4675](https://github.com/microsoft/vscode-cmake-tools/pull/4675) [@bradphelan](https://github.com/bradphelan)
- Use environment variables from `cmake.environment` and `cmake.configureEnvironment` when expanding `$penv{}` macros in CMake Presets `include` paths. [#3578](https://github.com/microsoft/vscode-cmake-tools/issues/3578)
- Provide CMAKE_LANG_IMPLICIT_INCLUDE_DIRECTORIES as system includes. [#4718](https://github.com/microsoft/vscode-cmake-tools/pull/4718)
- Allow preset modification commands to target CMakeUserPresets.json. The target file is determined by the focused editor, or by prompting the user when both files exist. [#4564](https://github.com/microsoft/vscode-cmake-tools/issues/4564)

Bug Fixes:
Expand Down
26 changes: 24 additions & 2 deletions src/cpptools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,10 @@ export class CppConfigurationProvider implements cpptools.CustomConfigurationPro

const targetFromToolchains = compilerToolchains?.target;
const targetArchFromToolchains = targetFromToolchains ? parseTargetArch(targetFromToolchains) : undefined;
const compilerImplicitIncludes = compilerToolchains?.implicitIncludes?.map(util.platformNormalizePath) || [];

const normalizedCompilerPath = util.platformNormalizePath(compilerPath);
let compileCommandFragments = useFragments ? (fileGroup.compileCommandFragments || target.compileCommandFragments) : [];
const compileCommandFragments = useFragments ? (fileGroup.compileCommandFragments || target.compileCommandFragments).slice(0) : [];
const getAsFlags = (fragments?: string[]) => {
if (!fragments) {
return [];
Expand Down Expand Up @@ -512,12 +513,33 @@ export class CppConfigurationProvider implements cpptools.CustomConfigurationPro
}
if (targetFromToolchains) {
if (useFragments) {
compileCommandFragments = compileCommandFragments.slice(0);
compileCommandFragments.push(`--target=${targetFromToolchains}`);
} else {
flags.push(`--target=${targetFromToolchains}`);
}
}
if (compilerImplicitIncludes.length > 0) {
// Extract the stem from compiler path.
const compilerId = compilerPath.toLocaleLowerCase()
.match(/(?:^|[-\/\\])(cl|clang-cl|clang\+\+|clang|g\+\+|gcc)(?:$|[-.])/)?.[1] || "";

const includeFlag = {
"cl": "/external:I",
"clang-cl": "-imsvc",
"clang++": "-isystem",
"clang": "-isystem",
"g++": "-isystem",
"gcc": "-isystem"
}[compilerId] || "-I";

for (const implicitInclude of compilerImplicitIncludes) {
if (useFragments) {
compileCommandFragments.push(`${includeFlag}${shlex.quote(implicitInclude)}`);
} else {
flags.push(`${includeFlag}${implicitInclude}`);
}
}
}

this.workspaceBrowseConfiguration = {
browsePath: newBrowsePath,
Expand Down
10 changes: 5 additions & 5 deletions src/drivers/cmakeFileApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,11 +594,11 @@ export async function loadToolchains(filename: string): Promise<Map<string, Code

return toolchains.toolchains.reduce((acc, el) => {
if (el.compiler.path) {
if (el.compiler.target) {
acc.set(el.language, { path: el.compiler.path, target: el.compiler.target });
} else {
acc.set(el.language, { path: el.compiler.path });
}
acc.set(el.language, {
path: el.compiler.path,
target: el.compiler.target,
implicitIncludes: el.compiler.implicit.includeDirectories
});
}
return acc;
}, new Map<string, CodeModelToolchain>());
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/codeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type CodeModelFileGroup = api.CodeModel.FileGroup & { frameworks?: { path
export type CodeModelProject = api.CodeModel.Project;
// TODO: If requested, move folder, dependencies, and isGeneratorProvided definition to the public API repo to avoid this intersection type.
export type CodeModelTarget = api.CodeModel.Target & { folder?: { name: string }; dependencies?: { backtrace: number; id: string }[]; isGeneratorProvided?: boolean; install?: {destinations: {path: string}[]; prefix: {path: string}}};
export type CodeModelToolchain = api.CodeModel.Toolchain;
export type CodeModelToolchain = api.CodeModel.Toolchain & { implicitIncludes?: string[] };
export type TargetTypeString = api.CodeModel.TargetType;

/**
Expand Down
Loading