microsoft / vscode-cmake-tools

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

cmake kits do not accept shell scripts #3719

Closed audetto closed 2 months ago

audetto commented 2 months ago

Brief Issue Summary

If I specify the the path of a shell script as compiler in cmake-kits.json, this fails with

[proc] The command: my-script -v failed with error: Error: spawn my-script ENOENT

The same shell script works if I pass it in the kits via a toolchain file where I have set CMAKE_CXX_COMPILER to the exact same path.

The problem only happens for scripts, executables work in both modes.

CMake Tools Diagnostics

This happens on a machine from which I cannot access github, so I cannot do this.

Debug Log

No response

Additional Information

This is an example of a cmake-kits.json which fails

[{
    "name": "my script",
    "compilers": {
        "C": "/path/to/my-script",
        "CXX": "/path/to/my-script"
    }
}]

Version involved

vscode 1.87.2 cmake 3.22.1 cmake-tools 1.17.17

v-frankwang commented 2 months ago

@audetto In order to better solve your problem, we need more information from you, such as a project that can reproduce this issue and some screenshots? Thank you!

audetto commented 2 months ago

Unfortunately I cannot replicate (I was trying here https://github.com/audetto/cmake-kits) But I have learnt 2 things

1) it is prefixed with [proc] which I had originally omitted 2) it is harmless. I always thought it was a fatal error, but it is not

maybe it is something the extension does to guess the version (-v). cmake handles it properly, and I see as soon as I err (permission or other), a real fatal error comes prefixed with [cmake].

So, probably, not worth investing more time.

audetto commented 2 months ago

Actually yes. Found (look at the repo https://github.com/audetto/cmake-kits)

If I rename the compiler to clang-opt.sh, then I can reproduce. I suspect, it tries to guess something and in this case, not being an executable it fails.

I guess it is totally harmless.

[main] Configuring project: cmake-kits 
[proc] Executing command: /usr/bin/cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_CXX_COMPILER:FILEPATH=/home/andrea/projects/cvs/cmake-kits/clang-opt.sh -S/home/andrea/projects/cvs/cmake-kits -B/home/andrea/projects/cvs/cmake-kits/build/Debug-bad -G Ninja
[cmake] Not searching for unused variables given on the command line.
[cmake] -- Configuring done (0.0s)
[cmake] -- Generating done (0.0s)
[cmake] -- Build files have been written to: /home/andrea/projects/cvs/cmake-kits/build/Debug-bad
[proc] The command: clang-opt -v failed with error: Error: spawn clang-opt ENOENT

but the message could be silenced.

v-frankwang commented 2 months ago

@gcampbell-msft I can reproduce the problem based on the project provided by the client, but the client feels that it is possible that this is not a serious bug or not a bug, and I was hoping you could give me some advice.

Repro steps recording:

  1. Download the project: https://github.com/audetto/cmake-kits provided by the customer and open it in vscode.
  2. Run the CMake:config command.
  3. Configured the kit to be bad.

image

Actual results:

image

audetto commented 2 months ago

The last line of the output is the same as mine, but since my project is linux based, you have as well some real cmake errors where the compiler is broken. If you run this in linux, you will have a less confusing output.

v-frankwang commented 2 months ago

@audetto Thank you very much for your reply, we will close this issue, it is a mini-feature that allows the suite of scripts to fully support it, if you guys want this to be a feature that explicitly supports shell scripts as a "compiler", please create a specific issue for this.