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

cmakeExecutable doesn't check condition #4178

Open
JVApen opened this issue Nov 18, 2024 · 3 comments
Open

cmakeExecutable doesn't check condition #4178

JVApen opened this issue Nov 18, 2024 · 3 comments
Labels
more info needed More info is needed from the community for us to properly triage and investigate.

Comments

@JVApen
Copy link

JVApen commented Nov 18, 2024

Brief Issue Summary

{
    "version": 6,
    "configurePresets": [
        {
            "name": "Windows",
            "cmakeExecutable": "C:/Program Files/cmake/3.30.2/bin/cmake.exe",
            "condition": {
                "type": "equals",
                "lhs": "${hostSystemName}",
                "rhs": "Windows"
            }
        },
        {
            "name": "Linux",
            "cmakeExecutable": "/opt/cmake/3.30.2/bin/cmake.exe",
            "condition": {
                "type": "equals",
                "lhs": "${hostSystemName}",
                "rhs": "Linux"
            }
        }
    ]
}

When using 1 CMakePresets.json with the above content in it, 1 of the systems fails to use the right cmake executable.

In this case, I'm using a windows machine to remote SSH into a linux device.

CMake Tools Diagnostics

`
{
  "os": "linux",
  "vscodeVersion": "1.95.3",
  "cmtVersion": "1.19.52",
  "configurations": [
    {
      "folder": "/home/project/main",
      "cmakeVersion": "unknown",
      "configured": false,
      "generator": "unknown",
      "usesPresets": false,
      "compilers": {}
    }
  ],
  "cpptoolsIntegration": {
    "isReady": false,
    "hasCodeModel": false,
    "activeBuildType": "",
    "buildTypesSeen": [],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 0,
    "executablesCount": 0,
    "librariesCount": 0,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}
``

Debug Log

`
[cmakeExecutable] CMake executable not found in cache. Checking again.
[proc] Executing command: C:\Program Files\cmake\3.30.2\bin\cmake.exe --version
[proc] The command: C:\Program Files\cmake\3.30.2\bin\cmake.exe --version failed with error: Error: spawn C:\Program Files\cmake\3.30.2\bin\cmake.exe ENOENT
[proc] Executing command: C:\Program Files\cmake\3.30.2\bin\cmake.exe -E capabilities
[proc] The command: C:\Program Files\cmake\3.30.2\bin\cmake.exe -E capabilities failed with error: Error: spawn C:\Program Files\cmake\3.30.2\bin\cmake.exe ENOENT
...
`

Additional Information

It looks like the parsing of the presets takes the first occurrence of cmakeExecutable it finds without considering the condition.

@Yingzi1234
Copy link
Collaborator

@gcampbell-msft When there are Windows and Linux options in the CMakePresets.json file, typing the command cmake: select configure preset will only bring up one option: Linux and the Windows option will not appear We cannot reproduce this problem. Could you provide us with some help?

@JVApen Could you give us some additional information? For example, screenshots or reproduced items that will facilitate our investigation of your issue. Thank you very much for your help, please let us know if you have any concerns!

@Yingzi1234 Yingzi1234 added more info needed More info is needed from the community for us to properly triage and investigate. and removed triage labels Nov 20, 2024
@JVApen
Copy link
Author

JVApen commented Nov 20, 2024

@Yingzi1234 : In the real use-case, I am making use of includes. I'll see if I can create a working reproduction. I do have holidays coming up, so it might take a while before I have this.

@gcampbell-msft
Copy link
Collaborator

@Yingzi1234 You are correct, and this is expected, only those presets that are available on the machine that is being used should be populated. In order to repro with certain presets, the condition should be made to be true, either by opening the project on the correct OS, or by removing the condition as a way to test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more info needed More info is needed from the community for us to properly triage and investigate.
Projects
Status: Blocked
Development

No branches or pull requests

3 participants