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.

Should create correct intelli Sense config based on toolchain file

See original GitHub issue

Brief Issue Summary

I am using toolchain file for CMake, which I added in the cmake_tools.json, this specifies a custom compiler and custom include paths (and custom defines).

Expected:

On Project configuration and clicking “Yes” when being asked “Would you like to use ${workspaceFolder}/build/compile_commands.json to auto-configure IntelliSense for this folder?” should generate a compile_commands.json based on the values set in the toolchain file.

Apparent Behavior:

The following code is generated:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/clang",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "clang-x64",
            "compileCommands": "${workspaceFolder}/build/compile_commands.json"
        }
    ],
    "version": 4
}

while the compile_commands seem to be correct, the content of defines and includePath is not.

Developer Tools Log

[Extension Host] [CMakeTools] 2018-09-21T13:54:38.848Z [debug] [rollbar] Updated Rollbar payload {"environment":"production","packageJSON":{"name":"cmake-tools","version":"1.1.1"},"client":{"code_version":"1.1.1"},"platform":"linux"}
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] activating extension
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] starting language server
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:38.951Z [debug] [kit] Reading kits file /home/ll/.local/share/CMakeTools/cmake-tools.json
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:38.952Z [debug] [kit] Not reading non-existent kits file: /home/ll/git/dhcpc/.vscode/cmake-kits.json
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.106Z [info] [kit] Successfully loaded 7 kits from /home/ll/.local/share/CMakeTools/cmake-tools.json
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.107Z [debug] [main] Safe constructing new CMakeTools instance
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.108Z [debug] [variant] Constructing VariantManager
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.109Z [debug] [main] Constructing new CMakeTools instance
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.110Z [debug] [main] Starting CMakeTools second-phase init
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.110Z [debug] [rollbar] Checking Rollbar permissions
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.110Z [debug] [rollbar] Rollbar enabled?  false
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.179Z [info] [variant] Loaded new set of variants
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.182Z [debug] [main] CMakeTools instance initialization complete.
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.183Z [debug] [main] Injecting new Kit into CMake driver
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.185Z [debug] [kit] Reading kits file /home/ll/.local/share/CMakeTools/cmake-tools.json
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.193Z [info] [kit] Successfully loaded 7 kits from /home/ll/.local/share/CMakeTools/cmake-tools.json
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.193Z [debug] [kit] Not reading non-existent kits file: /home/ll/git/dhcpc/.vscode/cmake-kits.json
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.194Z [debug] [rollbar] Updated Rollbar payload {"kit":{"name":"GCC armv7 (W&T)","toolchainFile":"~/cmake-toolchains/wut-armv7"}}
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.195Z [debug] [main] Injecting new Kit into CMake driver
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.200Z [debug] [extension] Configuring workspace on open  file:///home/ll/git/dhcpc
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.201Z [debug] [main] Run configure  
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.201Z [debug] [main] Saving open files before configure/build
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] cmake-tools-helper.cmake_download_path:/home/ll/.vscode/extensions/maddouri.cmake-tools-helper-0.2.1/cmake_download
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] Fehler beim Aktivieren der Erweiterung "maddouri.cmake-tools-helper": Cannot read property 'reconfigured' of undefined.
t.log @ /usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] Activating extension `maddouri.cmake-tools-helper` failed:  Cannot read property 'reconfigured' of undefined
t.log @ /usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] Here is the error stack:  TypeError: Cannot read property 'reconfigured' of undefined
	at new CMakeToolsHelper (/home/ll/.vscode/extensions/maddouri.cmake-tools-helper-0.2.1/out/src/state.js:13:33)
	at activate (/home/ll/.vscode/extensions/maddouri.cmake-tools-helper-0.2.1/out/src/extension.js:10:28)
	at Function.t._callActivateOptional (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:808:839)
	at Function.t._callActivate (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:808:518)
	at /usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:807:572
	at Object.g [as _notify] (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:77:971)
	at Object.enter (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:81:277)
	at n.Class.derive._oncancel._run (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:83:100)
	at n.Class.derive._oncancel._completed (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:82:559)
	at c (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:85:1011)
	at $.then.o.(anonymous function) (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:86:205)
	at Object.g [as _notify] (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:77:971)
	at Object.enter (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:81:277)
	at n.Class.derive._oncancel._run (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:83:100)
	at n.Class.derive._oncancel._completed (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:82:559)
	at c (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:85:1011)
	at $.then.o.(anonymous function) (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:86:205)
	at Object.g [as _notify] (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:77:971)
	at Object.enter (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:81:277)
	at n.Class.derive._oncancel._run (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:83:100)
	at n.Class.derive._oncancel._completed (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:82:559)
	at e.resolveOk (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:573:721)
	at e._receiveReply (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:671:316)
	at e._receiveOneMessage (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:670:609)
	at /usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:669:452
	at /usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:672:575
	at /usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:96:903
	at e.fire (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:98:218)
	at a (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:162:713)
	at Socket._socketDataListener (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:162:932)
	at emitOne (events.js:116:13)
	at Socket.emit (events.js:211:7)
	at addChunk (_stream_readable.js:263:12)
	at readableAddChunk (_stream_readable.js:250:11)
	at Socket.Readable.push (_stream_readable.js:208:10)
	at Pipe.onread (net.js:594:20)
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:3225 Fehler beim Aktivieren der Erweiterung "maddouri.cmake-tools-helper": Cannot read property 'reconfigured' of undefined.
w._logMessageInConsole @ /usr/share/code/resources/app/out/vs/workbench/workbench.main.js:3225
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.560Z [debug] [main] Starting new CMake driver
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.560Z [debug] [main] Starting CMake driver
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.561Z [debug] [driver] CMakeDriver Kit set to GCC armv7 (W&T)
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.562Z [debug] [driver] Run _refreshExpansions
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.562Z [debug] [cms-driver] Run doRefreshExpansions
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.563Z [debug] [driver] Run _refreshExpansions cb
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:39.575Z [debug] [cms-client] Started new CMake Server instance with PID 10604
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:40.579Z [debug] [cache] Reading CMake cache file /home/ll/git/dhcpc/build/CMakeCache.txt
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:40.580Z [debug] [cache] Parsing CMake cache string
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:40.601Z [debug] [driver] Setting new variant , Emit debug information without performing optimizations
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:40.601Z [debug] [driver] Run _refreshExpansions
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:40.602Z [debug] [cms-driver] Run doRefreshExpansions
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:40.602Z [debug] [driver] Run _refreshExpansions cb
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:40.625Z [debug] [cms-client] Started new CMake Server instance with PID 10606
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:41.627Z [debug] [cache] Reading CMake cache file /home/ll/git/dhcpc/build/CMakeCache.txt
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:41.629Z [debug] [cache] Parsing CMake cache string
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:41.693Z [debug] [driver] Start configure  
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:41.693Z [debug] [driver] Runnnig pre-configure checks and steps
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:41.694Z [debug] [driver] Using CMake toolchain GCC armv7 (W&T) for configuring
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:41.695Z [debug] [driver] Run _refreshExpansions
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:41.695Z [debug] [cms-driver] Run doRefreshExpansions
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:41.695Z [debug] [driver] Run _refreshExpansions cb
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:41.699Z [info] [cmake] BUILD_TYPE was set to Release since, nothing else was specified. Pass -DBUILD_TYPE=Debug to get a debug build.
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:41.700Z [info] [cmake] BUILD_TYPE was set to Release since, nothing else was specified. Pass -DBUILD_TYPE=Debug to get a debug build.
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:41.700Z [info] [cmake] /home/ll/svn/operation
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:41.703Z [info] [cmake] Configuring done
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:41.717Z [info] [cmake] Generating done
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:41.775Z [debug] [cache] Reading CMake cache file /home/ll/git/dhcpc/build/CMakeCache.txt
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:42.217Z [debug] [cache] Parsing CMake cache string
/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:42.235Z [error] [rollbar] Unable to automatically determine compiler {"lang":"C","fileGroup":{"compileFlags":"-fmessage-length=0 -mtune=marvell-pj4 -march=armv7-a -mfloat-abi=softfp -DSYSTEMD -Os -DRELEASE   -std=gnu90","defines":["USE_MYSQL"],"includePath":[{"path":"/usr/local/arm-pkg_v7/include"},{"path":"/usr/local/arm-pkg_v7/usr/include"},{"path":"/home/ll/git/dhcpc/."},{"path":"/home/ll/git/dhcpc/wut_include"}],"isGenerated":false,"language":"C","sources":["dhcpclient_wut.c"]}}
t.log @ /usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272
2/usr/share/code/resources/app/out/vs/workbench/workbench.main.js:272 [Extension Host] [CMakeTools] 2018-09-21T13:54:42.237Z [error] [rollbar] Unable to automatically determine compiler {"lang":"C","fileGroup":{"compileFlags":"-fmessage-length=0 -mtune=marvell-pj4 -march=armv7-a -mfloat-abi=softfp -DSYSTEMD -Os -DRELEASE -fPIC   -std=gnu90","defines":["USE_MYSQL","wut_util_EXPORTS"],"includePath":[{"path":"/usr/local/arm-pkg_v7/include"},{"path":"/usr/local/arm-pkg_v7/usr/include"},{"path":"/home/ll/git/dhcpc/."},{"path":"/home/ll/git/dhcpc/wut_include"},{"path":"/home/ll/git/dhcpc/wut_include/."}],"isGenerated":false,"language":"C","sources":["db_init.c","gpio_helper.c","mysql_query.c","wbm_io.c","webio_com.c","wt_gis_20.c","wt_log.c"]}}

Platform and Versions

  • Operating System: Debian
  • CMake Version: 3.7.2
  • VSCode Version: 1.26.1
  • CMake Tools Extension Version: 1.1.1
  • Compiler/Toolchain: arm-linux-gcc 6.3.0 (from buildroot)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
bobbrowcommented, Jul 22, 2019

Hi there,

I work on the cpptools extension (and now we maintain this extension too). If you are still having trouble with this, please share the entry from your compile_commands.json file that is not working for you. (e.g. if foo.cpp is not being configured properly, please share the corresponding entry for foo.cpp from your compile_commands.json file)

When the compileCommands property is used in the c_cpp_properties.json file, we do not look at the includePath and define properties because we expect compile_commands.json to be the source of truth for configuration.

Thank you.

0reactions
bobbrowcommented, Nov 19, 2019

@zrno, ok? ms-vscode.cmake-tools only works with cpptools@0.26.2-insiders as of right now. My guess is that you installed the Insiders version of cpptools and that fixed your problem.

I’m going to close this issue now, because I think all points have now been addressed. If you have any further feedback for the extension, please open a new issue and we can start from there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configure IntelliSense with CMake Toolchain Files in Visual ...
Visual Studio can now configure IntelliSense in CMake projects based on the value of CMake variables set by CMake toolchain files.
Read more >
Configure IntelliSense for C++ cross-compilation
The article is about configuring the C/C++ extension to provide proper IntelliSense (code completions) in Visual Studio Code when you compile ...
Read more >
Topic: CMake project + Intellisense + Yocto toolchain | Sysprogs
This I can see is correctly set in the IntelliSense.props file, so I'm guessing this isn't consulted by the new CMake-based IntelliSense parser?...
Read more >
cmake-toolchains(7) — CMake 3.25.1 Documentation
In cross-compiling scenarios, a toolchain file may be specified with ... on the CMake command line will ensure that the appropriate build settings...
Read more >
Settings | JetBrains Fleet Documentation
This is done by creating .fleet/settings.json in a subdirectory. When you are working with files inside the subdirectory, these settings will ...
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