question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting "cmake.exportCompileCommandsFile": true does not work with CMake Presets

See original GitHub issue

Brief Issue Summary

Setting "cmake.exportCompileCommandsFile": true does not work with CMake Presets.

Expected:

  1. Set "cmake.exportCompileCommandsFile": true
  2. -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON is 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:open
  • Created 2 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
hwmaiercommented, Oct 26, 2021

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:

    "configurePresets": [
        {
...
            "environment": {
                "CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
            },

But I still think that exportCompileCommandsFile is a setting not for cmake itself but for the IDE controlling it so I believe cmake.exportCompileCommandsFile should flow through as it does not affect the build but allows VS Code to parse it and offer compile command for single C files.

1reaction
andreeiscommented, May 5, 2021

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found