I am trying to build a c++ project on windows with visual studio code and cmake-tools extension.
My versions are
cmake: 3.18.0-rc1
cmake tools (vscode extension): 1.4.1
When I build, I get this annoying message about codemodel version.
[cmakefileapi-parser] Code model version (2.1) of cmake-file-api is unexpected. Expecting (2.0). IntelliSense configuration may be incorrect.
[cmakefileapi-parser] Code model version (2.1) of cmake-file-api is unexpected. Expecting (2.0). IntelliSense configuration may be incorrect.
This messages appear at configuration, and also when I build.
It is the exact same problem mentionned by someone else in this stackoverflow question : https://stackoverflow.com/questions/62445673/cmakefileapi-parser-warning-message-about-cmake-in-windows-vscode
One of the comments on stackoverflow suggests to edit the file
\build\.cmake\api\v1\reply\codemodel-v2-[???].json and edit the minor version at the bottom of the file from '1' to '0'.
It does make the messages disappear for build after this changes, but as this file is generated at configuration, the warning comes back everytime you want to run cmake again...
Also I don't know if this modification breaks anything or not.
UPDATE: when writing this issue and checking my version of cmake, I figured out I was using a release candidate (for some reason it is the first displayed on cmake website and I did not pay attention when I downloaded it). I installed the latest cmake release (3.17.3) instead, and the problem "disappeared".
Thank you for reporting this issue. I saw it on another developer's machine this week and forgot to open a ticket to fix this. I looked for documentation from the CMake team about this revision but didn't find any. I posted a question on their forum to ask about the changes and we'll see what they say.
https://discourse.cmake.org/t/cmake-file-api-code-model-version-2-1/1465
Please note that the log message is just a warning and if the code model hasn't changed substantially in revision 2.1, the message can be safely ignored.
if the code model hasn't changed substantially in revision 2.1, the message can be safely ignored.
CMake upstream here, this is a minor update which only adds new fields to the File API output - it won't break older clients. The warning is safe to ignore.
I've opened #1343 to suppress the warning for newer versions.
1.4.2 has this fix and is now available. Sorry for such a long delay, our work on another extension project has been taking much longer than anticipated.
I'm on vscode-cmake-tools 1.4.2 and CMake 1.38.2 and this message still appears.
I'm on vscode-cmake-tools 1.4.2 and CMake 1.38.2 and this message still appears.
D'oh! Looks like I implemented the fix for the cache model but not the code model. I'll fix it.
I have vscode-cmake-tools 1.4.2 and CMake version 3.18.2 and encounter with this error
The remaining message will be fixed in 1.5
I found a way to walkthrough the issue. edit ~/.vscode/extensions/ms-vscode.cmake-tools-1.4.2/dist/main.js, find the loadCodeModelContent function.
async function loadCodeModelContent(filename) {
const file_content = await pr_1.fs.readFile(filename);
const codemodel = JSON.parse(file_content.toString());
const expected_version = { major: 2, minor: 0 };
const detected_version = codemodel.version;
if (detected_version.major != expected_version.major || detected_version.minor != expected_version.minor) {
log.warning(localize(3, null, detected_version.major, detected_version.minor, expected_version.major, expected_version.minor));
}
return codemodel;
}
replace it with the code below:
async function loadCodeModelContent(filename) {
const file_content = await pr_1.fs.readFile(filename);
const codemodel = JSON.parse(file_content.toString());
const expected_version = { major: 2, minor: 0 };
const detected_version = codemodel.version;
if (detected_version.major != expected_version.major || detected_version.minor < expected_version.minor) {
log.warning(localize(3, null, detected_version.major, detected_version.minor, expected_version.major, expected_version.minor));
}
return codemodel;
}
Yes, just do as the PR did.
@jeremyxu2010 The file ended up in ~/.vscode-server/extensions/ms-vscode.cmake-tools-1.4.2/dist/main.js on my machine.
Getting this message when trying to configure a C project in VS Code:
[cmakefileapi-parser] Code model version (2.2) of cmake-file-api is unexpected. Expecting (2.0). IntelliSense configuration may be incorrect.
[cmakefileapi-parser] Code model version (2.2) of cmake-file-api is unexpected. Expecting (2.0). IntelliSense configuration may be incorrect.
cmake version 3.19.0-rc1
VS Code version 1.50.1
CMake for Visual Studio Code v0.0.17
CMake Tools v1.4.2
Most helpful comment
CMake upstream here, this is a minor update which only adds new fields to the File API output - it won't break older clients. The warning is safe to ignore.
I've opened #1343 to suppress the warning for newer versions.