Setting "cmake.exportCompileCommandsFile": true does not work with CMake Presets
See original GitHub issueBrief Issue Summary
Setting "cmake.exportCompileCommandsFile": true does not work with CMake Presets.
Expected:
- Set
"cmake.exportCompileCommandsFile": true -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ONis added to the CMake configure call even when on the presets path
Platform and Versions
- Operating System: Ubuntu
- CMake Version: 3.20.2
- VSCode Version: 1.55.0
- CMake Tools Extension Version: 1.7.1
- Compiler/Toolchain: GCC 9.3.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
CMAKE_EXPORT_COMPILE_C...
It seems that CMAKE_EXPORT_COMPILE_COMMANDS is not added to the command line during CMake configuration stage when CMake Presets are used ...
Read more >CMAKE_EXPORT_COMPILE_C...
This is initialized by the CMAKE_EXPORT_COMPILE_COMMANDS environment variable, and initializes the EXPORT_COMPILE_COMMANDS target property for all targets. Note.
Read more >Not able to build when using CMakePresets.json
Open a large CMake project using CMakePresets; Configure project; Once done configuring, check to see if the build menu is populated. If it...
Read more >vscode-cmake-tools - Bountysource
I have a test project using CMake. It builds fine if there is no CMakePresets.json file in the directory. But if the file...
Read more >"Fossies" - the Fresh Open Source Software Archive
60 * 61 * CMake drivers are separated because different CMake version ... if the user did not define already 540 // in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Ok, so this is by design. I can understand this as you want Cmake yield the same result regardless if launched from VS Code or command line. I think for users familiar with the variant/kit system transitioning to the preset system this is something with must be expressed very clearly in the documentation.
And yes, setting CMAKE_EXPORT_COMPILE_COMMANDS in the preset environment works, this is what we are presently doing:
But I still think that
exportCompileCommandsFileis a setting not for cmake itself but for the IDE controlling it so I believecmake.exportCompileCommandsFileshould flow through as it does not affect the build but allows VS Code to parse it and offer compile command for single C files.Thank you for opening this report. You can specify this in the preset as well. I just verified that it works. “cacheVariables”: { “CMAKE_EXPORT_COMPILE_COMMANDS”: “ON” }
@xisui-MSFT, I don’t see any reason why presets wouldn’t pick up from regular settings but I am not sure, please confirm if this behavior is by design or we should fix something in CMake Tools. Is the user supposed to define the above when wanting compile_commands.json or the usual setting we had should have effect even with presets on?