microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.46k stars 449 forks source link

CMake build is failing with versions above v1.17.15 #3657

Closed kerimbavcic closed 6 months ago

kerimbavcic commented 6 months ago

Brief Issue Summary

When using CMake Tools extention, the build is failing. Our log output indicates that CMake presets are not parsed properly (from CMakePresets.json) and are not "taken into account". When we run our build from terminal, everything works as expected.

Issues started occuring after the update to v1.17.16 and our temporary solution was to roll back to v1.17.15. We expected the problem to be fixed with the next update to v1.17.17, but the problem is still present.

CMake Tools Diagnostics

No response

Debug Log

No response

Additional Information

Example of our error message is:

"VxWorks compiler sysroot not found. Please set WIND_CCSYSROOT"

and this variable(WIND_CCSYSROOT) is being set in CMake presets.

gcampbell-msft commented 6 months ago

@kerimbavcic In order to best investigate this, could you please provide a minimal repro project that we can use to repro and investigate this bug with?

Without a reproduction project or at least a copy of the CMakeLists.txt and CMakePresets that you are using, it's very difficult to determine what might be the issue. Thank you!

kerimbavcic commented 6 months ago

Certainly, have a look at our minimized CMakeLists.txt, CMakePresets.json and build_output.txt.

Also one more thing, as I said this is just happening with using your tool (we can build successfully using the terminal where we manually add the wanted preset). We started getting this error with update to v1.17.16 and the build_output.txt indicates that the values from CMakePresets.json are not parsed for some reason.

I hope this will give you a better insight in the problem we are having.

build_output.txt CMakeLists.txt CMakePresets.json

gcampbell-msft commented 6 months ago

Since there is lots of dependencies and items in your CMakeLists.txt, is there a way to zip up your entire project so that I can attempt to reproduce? Thanks!

I'd like to be able to investigate this as soon as I can in case it's a regression. However, the build_output.txt file you sent doesn't currently give me any indication that it is caused by our recent changes. It's possible, but nothing specific jumps out at me yet.

kerimbavcic commented 6 months ago

I will have to speak with my team leader about the entire project.

When we revert the version back to .15 there is no error of this type, so the CMakePresets.json is read. But when we update it to .16 or .17 this starts happening (we didn't change anything in our code) so it indicates that it is caused by your recent changes.

kerimbavcic commented 6 months ago

Just had a discussion with my team leader and he said that the option of zipping the whole project is not possible but I will try to create a minimal project where I reproduce the error and send you this one. Probably in the next few days, not today.

gcampbell-msft commented 6 months ago

@kerimbavcic I would agree, it definitely seems like a regression if there are no project changes and updating breaks it, so I'm definitely interested in investigating and getting a fix into pre-release (and the next release) for you all. I was only saying that nothing immediately pops out as obvious to what the bug is, I would greatly appreciate you getting together a minimal project to reproduce the error.

Thank you!

kerimbavcic commented 6 months ago

@gcampbell-msft thank you for the support. While I'm preparing the project here are a couple of infos how we prepare our project for CMake, maybe this can help you understand the project better:

  1. executing a powershell script, where we set environment variables, e.g. {VSB_PATH} (see CMakePresets.json line 39 where we set "WIND_CCSYSROOT" to this value).
  2. at the end of powershell script we start VS Code.
  3. project build which fails with specified error.

It seems that the problem is caused with this line (line 39):

"environment": { "WIND_CC_SYSROOT": "$env{VSB_PATH}" }

kerimbavcic commented 6 months ago

@gcampbell-msft here is the minimal repro project, if you need anything else please let me know.

Thank you. minimal_repro_project.zip

gcampbell-msft commented 6 months ago

What error are you seeing in the minimal repro project? I was not able to reproduce, I was able to build successfully when I opened VS Code in an environment that contains ninja and compilers on path.

Thanks

kerimbavcic commented 6 months ago

It will build successfully, because nothing is being done. See the images below:

Here you see we set the env variable in line 7: image

Here you see that PRESET_VAR should have the value of the env variable set in startvsCode.ps1 image

In line 5 you see we print out the value of PRESET_VAR; image

And in output we don't see the value we set: image

This is happening as well in the original project, but since the variable is used somewhere in the code, the build of original project is failing.

I hope it is clear now what the exact problem is.

gcampbell-msft commented 6 months ago

@kerimbavcic AH, thank you for the clarification, it's clear that I didn't fully understand the minimal repro. I will investigate. Thanks

gcampbell-msft commented 6 months ago

@kerimbavcic Ah, I've found the issue. Thanks for pointing this out! I have a PR opened here: #3664. Once it merges, please update to the pre-release version and it will be available the business day after the PR merges.

kerimbavcic commented 6 months ago

@gcampbell-msft No problem, thank you for your quick response and effort :)