Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not crash with cmake 3.7-3.13 with CMakePresets.json present #2026

Closed
linquize opened this issue Jul 31, 2021 · 7 comments
Closed

Do not crash with cmake 3.7-3.13 with CMakePresets.json present #2026

linquize opened this issue Jul 31, 2021 · 7 comments
Assignees
Labels
bug a bug in the product Feature: presets
Milestone

Comments

@linquize
Copy link

linquize commented Jul 31, 2021

Brief Issue Summary

Do not crash with cmake 3.7-3.13 with CMakePresets.json present.
If I start VScode directly (cmake auto-detected version is 3.12), or start VSCode in VS2017 command prompt (cmake version is 3.12), this problem exists.
If I start VSCode in Ubuntu 18.04 (cmake from ubuntu bionic is 3.10), this problem exists.

If I start VSCode in VS2019 command prompt (cmake version is 3.20), there is no problem.
If I start VSCode in Ubuntu 20.04 (cmake from focal is 3.16), there is no problem.

Open a workspace with CMakePresets.json present.

CMakePresets.json

{
  "version": 2,
  "cmakeMinimumRequired": { "major": 3, "minor": 20, "patch": 0 },
  "configurePresets": [
    {
      "name": "default",
      "generator": "Ninja",
      "binaryDir": "${sourceDir}/build/default"
    }
  ],
  "buildPresets": [ { "name": "default", "configurePreset": "default" }
  ]
}

Expected:

No Configure Preset Selected is available for choosing configure preset.

Apparent Behavior:

Configure Presets list is not available.
If No Configure Preset Selected clicked, a toast shows command 'cmake.selectConfigurePreset' not found

CMake Tools Log

[variant] Loaded new set of variants
[kit] Successfully loaded 16 kits from C:\Users\User\AppData\Local\CMakeTools\cmake-tools-kits.json
[presetController] Successfully validated presets in c:\project\cmaketest\CMakePresets.json
[rollbar] CMake version 3.12.18081601 may not be supported. Minimum version required is 3.20.0. {}
[main] Unable to determine what CMake generator to use. Please install or configure a preferred generator, or update settings.json, your Kit configuration or PATH variable. Error: No usable generator found.
[expand] Invalid variable reference ${sourceDir} in string: ${sourceDir}/build/default

Platform and Versions

  • Operating System: Windows
  • CMake Version: 3.12 (auto detected from VS2017)
  • VSCode Version: 1.58
  • CMake Tools Extension Version: 1.7.3
  • Compiler/Toolchain: Both Visual C++ 2017 and 2019 installed

Platform and Versions

  • Operating System: Linux
  • CMake Version: 3.10 (from Ubuntu bionic)
  • VSCode Version: 1.58
  • CMake Tools Extension Version: 1.7.3
  • Compiler/Toolchain: gcc 7.5, ninja 1.8.2

Other Notes/Information

@linquize
Copy link
Author

linquize commented Jul 31, 2021

Possible fix:

get sourceDir() {
const drv = this.getCMakeDriverInstance();
return drv.then(d => {
if (!d) {
return '';
}
return d.sourceDir;
});
}

Since the instance drv is used once only, do not start cmake server if the implementation is CMakeServerClientDriver which is serverapi mode that targets cmake 3.7-3.13

@bobbrow
Copy link
Member

bobbrow commented Aug 2, 2021

@xisui-MSFT could you take a look at this?

@bobbrow bobbrow added the bug a bug in the product label Aug 2, 2021
@bobbrow bobbrow added this to the On Deck milestone Aug 2, 2021
@xisui-MSFT
Copy link
Collaborator

xisui-MSFT commented Aug 3, 2021

This issue can be reproed using setting "cmake.cmakeCommunicationMode": "serverApi" with later version of CMake. Source dir is required to evaluate presets. Presets contain generator info. Generator info is required for server api. Source dir currently requires driver. So this becomes a circular dependency, and I'll change cmake-tools.sourceDir to use config.sourceDir instead.

@bobbrow
Copy link
Member

bobbrow commented Aug 26, 2021

A build with this fix is available for you to test. Could you download the VSIX from here: https://github.com/microsoft/vscode-cmake-tools/suites/3599000085/artifacts/86773353

then unzip the file and run the "Install from VSIX..." command in VS Code to install it and try it out?

@linquize
Copy link
Author

@bobbrow The VSIX download link is not found.

@bobbrow
Copy link
Member

bobbrow commented Aug 27, 2021

Hmm... it works for me. Can you try this one instead?
cmake-tools.vsix.zip

@bobbrow
Copy link
Member

bobbrow commented Sep 2, 2021

The fix for this was released today in version 1.8.1

@bobbrow bobbrow closed this as completed Sep 2, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug a bug in the product Feature: presets
Projects
None yet
Development

No branches or pull requests

3 participants