Skip to content
Merged
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 @@ -3,6 +3,7 @@
## 1.23

Features:
- Add support for CMake Presets version 11 (added in CMake 4.3). In test presets, the `execution.jobs` field can now be an empty string, equivalent to passing `--parallel` with no value.
- Automatically add new source files to `CMakeLists.txt` and remove deleted source files from `CMakeLists.txt`. Two new commands (`cmake.addFileToCMakeLists` and `cmake.removeFileFromCMakeLists`) and nine new `cmake.modifyLists.*` settings provide full control over target selection, variable handling, and confirmation behavior. [#2132](https://github.com/microsoft/vscode-cmake-tools/issues/2132) [#4454](https://github.com/microsoft/vscode-cmake-tools/pull/4454) [@malsyned](https://github.com/malsyned)
- Allow specifying a custom debug adapter type in `cmake.debugConfig` via the `type` property. When set, automatic debugger detection is skipped and any debug adapter (e.g., `codelldb`, `lldb`) can be used with arbitrary configuration properties. [#4818](https://github.com/microsoft/vscode-cmake-tools/pull/4818)
- Add `${cmake.testEnvironment}` placeholder for launch.json that resolves to the CTest `ENVIRONMENT` test property, and automatically include CTest environment variables when debugging tests without a launch configuration. [#4572](https://github.com/microsoft/vscode-cmake-tools/issues/4572) [#4821](https://github.com/microsoft/vscode-cmake-tools/pull/4821)
Expand Down
2 changes: 1 addition & 1 deletion docs/cmake-presets.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ We recommend `CMakePresets.json` as an alternative to kits and variants files. T

## Supported CMake and `CMakePresets.json` versions

The CMake Tools extension supports version 2 or later for the `CMakePresets.json` and `CMakeUserPresets.json` files. You can update your file version by incrementing the version field in the root object. For an example and more information, see [`CMakePresets.json`](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html#format).
The CMake Tools extension supports version 2 through 11 for the `CMakePresets.json` and `CMakeUserPresets.json` files. You can update your file version by incrementing the version field in the root object. For an example and more information, see [`CMakePresets.json`](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html#format).

CMake version 3.20 or later is required when you're invoking CMake with `CMakePresets.json` (version 2 or later) from the command line. CMake Tools reads and evaluates `CMakePresets.json` and `CMakeUserPresets.json`. It doesn't invoke CMake directly with the `--preset` option. So, CMake version 3.20 or later isn't strictly required when you're building with `CMakePresets.json` inside Visual Studio Code. We recommend using CMake version 3.14 or later.

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4395,11 +4395,11 @@
},
{
"fileMatch": "CMakePresets.json",
"url": "cmake-tools-schema://schemas/CMakePresets-v10-schema.json"
"url": "cmake-tools-schema://schemas/CMakePresets-v11-schema.json"
},
{
"fileMatch": "CMakeUserPresets.json",
"url": "cmake-tools-schema://schemas/CMakePresets-v10-schema.json"
"url": "cmake-tools-schema://schemas/CMakePresets-v11-schema.json"
}
]
},
Expand Down Expand Up @@ -4476,7 +4476,7 @@
"tsconfig-paths": "^3.11.0",
"tslint": "^6.1.3",
"typescript": "^4.1.5",
"vscode-cmake-tools": "^1.5.0",
"vscode-cmake-tools": "^1.6.0",
"vscode-nls-dev": "^3.3.2",
"webpack": "^5.104.1",
"webpack-cli": "^5.1.4"
Expand Down
1,771 changes: 1,771 additions & 0 deletions schemas/CMakePresets-v11-schema.json

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion src/presets/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2297,7 +2297,16 @@ export function testArgs(preset: TestPreset): string[] {
if (preset.execution) {
preset.execution.stopOnFailure && result.push('--stop-on-failure');
preset.execution.enableFailover && result.push('-F');
(preset.execution.jobs !== undefined) && result.push('--parallel', preset.execution.jobs.toString());
if (preset.execution.jobs !== undefined) {
// v11+: jobs can be an empty string meaning --parallel with no value (auto-detect).
// The API type currently declares jobs as number; will be updated to number | string.
const jobs = preset.execution.jobs as number | string;
if (jobs === '') {
result.push('--parallel');
} else {
result.push('--parallel', jobs.toString());
}
}
preset.execution.resourceSpecFile && result.push('--resource-spec-file', preset.execution.resourceSpecFile);
preset.execution.testLoad && result.push('--test-load', preset.execution.testLoad.toString());
preset.execution.showOnly && result.push('--show-only', preset.execution.showOnly);
Expand Down
7 changes: 5 additions & 2 deletions src/presets/presetsParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export class PresetsParser {
)
);
let schemaFile;
const maxSupportedVersion = 10;
const maxSupportedVersion = 11;
const validationErrorsAreWarnings =
presetsFile.version > maxSupportedVersion &&
allowUnsupportedPresetsVersions;
Expand All @@ -176,8 +176,11 @@ export class PresetsParser {
} else if (presetsFile.version === 8 || presetsFile.version === 9) {
// This can be used for v9 as well, there is no schema difference.
schemaFile = "./schemas/CMakePresets-v8-schema.json";
} else {
} else if (presetsFile.version === 10) {
schemaFile = "./schemas/CMakePresets-v10-schema.json";
} else {
// v11+
schemaFile = "./schemas/CMakePresets-v11-schema.json";
}

const validator = await loadSchema(schemaFile);
Expand Down
139 changes: 139 additions & 0 deletions test/integration-tests/presets/validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,145 @@ suite('Presets validation, inclusion, and expansion tests', () => {
expect(preset.packagePresets(sourceDirectory).length).to.be.equal(1);
expect(preset.workflowPresets(sourceDirectory).length).to.be.equal(1);
}).timeout(100000);

const version10SupportedPresets: any = {
"version": 10,
"$comment": "This is a top-level comment",
"configurePresets": [
{
"$comment": "Comment on configure preset",
"name": "configure",
"hidden": false,
"generator": "Ninja",
"installDir": "${workspaceFolder}/install",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"toolchainFile": "",
"trace": {},
"graphviz": "${sourceDir}/build/deps.dot"
}
],
"buildPresets": [
{
"name": "x64-debug",
"configurePreset": "configure",
"cleanFirst": true,
"resolvePackageReferences": "on"
}
],
"testPresets": [
{
"name": "x64-debug",
"configurePreset": "configure",
"output": {
"testOutputTruncation": "tail"
}
}
],
"packagePresets": [
{
"name": "x64-debug-package"
}
],
"workflowPresets": [
{
"name": "x64-debug-workflow",
"steps": [
{
"type": "configure",
"name": "configure"
}
]
}
]
};

/**
* Validate v10 supports `$comment` at any level and `graphviz` on configure presets.
* Then confirm that `graphviz` is rejected on v9.
*/
test('Validate version 10 CMake Presets', async () => {
fs.writeFileSync(presetsParser.presetsPath,
JSON.stringify(version10SupportedPresets));

await presetsParser.resetPresetsFiles(
new Map<string, PresetsFile>(),
false,
false
);

expect(presetsFileErrors).to.have.lengthOf(0);
expect(preset.configurePresets(sourceDirectory).length).to.be.equal(1);
expect(preset.buildPresets(sourceDirectory).length).to.be.equal(1);
expect(preset.testPresets(sourceDirectory).length).to.be.equal(1);
expect(preset.packagePresets(sourceDirectory).length).to.be.equal(1);
expect(preset.workflowPresets(sourceDirectory).length).to.be.equal(1);

// Confirm graphviz is NOT allowed in v9
const v9WithGraphviz = lodash.cloneDeep(version10SupportedPresets);
v9WithGraphviz.version = 9;
delete v9WithGraphviz["$comment"];
delete v9WithGraphviz.configurePresets[0]["$comment"];

fs.writeFileSync(presetsParser.presetsPath,
JSON.stringify(v9WithGraphviz));

await presetsParser.resetPresetsFiles(
new Map<string, PresetsFile>(),
false,
false
);

expect(presetsFileErrors.length).to.be.greaterThan(0);
expect(presetsFileErrors.filter((e) => e.includes("graphviz"))).to.have.lengthOf(1);
}).timeout(100000);

/**
* Validate v11 supports the `jobs` field as an empty string in test preset execution.
* Then confirm that an empty string `jobs` is rejected on v10.
*/
test('Validate version 11 CMake Presets', async () => {
const v11Presets: any = lodash.cloneDeep(version10SupportedPresets);
v11Presets.version = 11;
v11Presets.testPresets[0].execution = {
"jobs": ""
};

fs.writeFileSync(presetsParser.presetsPath,
JSON.stringify(v11Presets));

await presetsParser.resetPresetsFiles(
new Map<string, PresetsFile>(),
false,
false
);

expect(presetsFileErrors).to.have.lengthOf(0);
expect(preset.configurePresets(sourceDirectory).length).to.be.equal(1);
expect(preset.buildPresets(sourceDirectory).length).to.be.equal(1);
expect(preset.testPresets(sourceDirectory).length).to.be.equal(1);
expect(preset.packagePresets(sourceDirectory).length).to.be.equal(1);
expect(preset.workflowPresets(sourceDirectory).length).to.be.equal(1);

// Confirm that empty string `jobs` is rejected on v10
const v10WithStringJobs: any = lodash.cloneDeep(v11Presets);
v10WithStringJobs.version = 10;

fs.writeFileSync(presetsParser.presetsPath,
JSON.stringify(v10WithStringJobs));

await presetsParser.resetPresetsFiles(
new Map<string, PresetsFile>(),
false,
false
);

expect(presetsFileErrors.length).to.be.greaterThan(0);
expect(presetsFileErrors.filter((e) => e.includes("jobs"))).to.have.lengthOf(1);
}).timeout(100000);
});

suite('Presets include field and CMakePresets+CMakeUserPresets', () => {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7843,10 +7843,10 @@ vinyl@^3.0.0, vinyl@^3.0.1:
replace-ext "^2.0.0"
teex "^1.0.1"

vscode-cmake-tools@^1.5.0:
version "1.5.0"
resolved "https://pkgs.dev.azure.com/azure-public/VisualCpp/_packaging/cpp_PublicPackages/npm/registry/vscode-cmake-tools/-/vscode-cmake-tools-1.5.0.tgz#208d15ab4364861f7bad17282bb4f1d47539248a"
integrity sha1-II0Vq0Nkhh97rRcoK7Tx1HU5JIo=
vscode-cmake-tools@^1.6.0:
version "1.6.0"
resolved "https://pkgs.dev.azure.com/azure-public/VisualCpp/_packaging/cpp_PublicPackages/npm/registry/vscode-cmake-tools/-/vscode-cmake-tools-1.6.0.tgz#cc2d373f54b68e6198f1de6589b1aa4e379f6def"
integrity sha1-zC03P1S2jmGY8d5libGqTjefbe8=

vscode-cpptools@^7.1.1:
version "7.1.1"
Expand Down
Loading