vscode-cmake-tools
vscode-cmake-tools copied to clipboard
Why are certain flags hardcoded?
Brief Issue Summary
Some flags like --no-warn-unused-cli are hardcoded.
Occasionally it could be useful to be able to see what CLI arguments are unused by looking at the Output view. Because this flag is currently hardcoded, this is not possible.
Here: https://github.com/microsoft/vscode-cmake-tools/blob/6adc289df3d10861005e7baf0011ea8702e58cbe/src/drivers/driver.ts#L620
Expected:
Don't hardcode certain flags that cannot be overridden even with configuration options.
Apparent Behavior:
It is not possible in anyway to run cmake from VSCode without certain flags, like --no-warn-unused-cli
CMake Tools Log
Not relevant
Developer Tools Log
Not relevant
Platform and Versions
- Operating System: Ubuntu 18.04
- CMake Version: 3.16.4
- VSCode Version: 1.42.1
- CMake Tools Extension Version: 1.3.0
- Compiler/Toolchain: Any
Other Notes/Information
I noticed that -j 4 was also appended to make when building (I am not sure if this is hardcoded or if it was autodetected). In this case, this is ok: make says -j can be supplied multiple times, and only the last one will take effect, allowing the user to override any hardcoded/auto-detected values in the extension config (note: the fact that buildToolArgs is (correctly) appended last is what also makes it possible).
This line has been there prior to us maintaining the extension. I suspect it was added for cases such as the one you mentioned as well as for always setting EXPORT_COMPILE_COMMANDS even for build systems that don't support it.
To remove it, I think we'll have to audit the commands currently being added and ensure that they are always valid.
Tried adding "cmake.configureArgs": ["--warn-unused-cli"] but it is ignored by cmake.
Best workaround I found is copy and pasting the cmake invokation from output to terminal and then running without the no-warn-unused-cli.
I am not using the extension for configuring because of these unnecessary flags (have disabled all options to auto-configure). I have my source code on a nfs mount and with --no-warn-unused-cli flag, for some reason it doesn't print the full path of the files. So it prints this:
/home/vk/share/ns/ns1/infrastructure/common/src/sockformat.c
instead of this:
/misc/sjcinfrafiler/home/vk/share/ns/ns1/infrastructure/common/src/sockformat.c
(Note that while opening the workspace, I give the full path as other extensions like clangd work properly with that.)
Without the full path, Errors, Warnings etc don't get marked in the editor upon running the build. As a workaround, always configuring from terminal.
This issue is now marked as 'stale-old' due to there being no activity on it for the past 720 days. Unless the 'stale-old' label is removed or the issue is commented on, this will be remain open for at least 14 days and then it may be closed. If you would like to make this issue exempt from getting stale, please add the 'stale-exempt' label.
A suggestion would be add these hardcoded things by default in settings.json file and let user decide to stay with those or modify them. The more customizable we make it. The more people would love it. Also, I have set EXPORT_COMPILE_COMMANDS "True" in a toolchain file which would be used by default from windows env variable (CMAKE_TOOLCHAIN_FILE). This would ensure me less interference of extensions in different IDE's. Because end of the day, it's the command/terminal that would be invoked for running any tool.
@VjayMathad I think this is a good suggestion, and @FranciscoPombal a good call-out for certain flags being hardcode, this should be a relatively easy fix, so I put it in the 1.18 milestone in hopes to fix it for that release. Thanks.
Hello,
Thank you for the fix but I am struggling to get it working.
In my setting.json I added "cmake.configureArgs": [ "--warn-unused-cli" ],
This in fact removes the --no-warn-unused-cli flag but it generates the following configuration command: /usr/local/bin/cmake --warn-unused-cli
But the option --warn-unused-cli does not exist and exit with an error code.
Am I doing something wrong or the fix does not work as expected?
Using cmake 3.22.5
cc: @gcampbell-msft
@vlockhead This is a great call-out, I will reopen this and put it in our next release for us to target. We should either support the idea of the --warn-unused-cli argument that removes the default insertion of --no-warn-unused-cli, or we should modify the hardcoded insertion and leave it to users to include --no-warn-unused-cli in their setting.
@bobbrow FYI since we discussed this back when I did the PR
@vlockhead This issue should be fixed pre-release. the '--warn-unused-cli' flag now removes the default '--no-warn-unused-cli' flag only and doesn't append itself to the flags. Let me know if it works for you :)
@snehara99 Thank you it works!
Thank you very much for your reply, I verified the issue on latest pre-release: v1.19.21 (pre-release) and it was fixed.
ENV: CMake Tools: v1.19.21 (pre-release) vscode: 1.19.1 (user setup) C/C++:v1.21.1(pre-release)