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.

Environment variable substituion: Kit environment and buildDirectory

See original GitHub issue

Brief Issue Summary

"cmake.buildDirectory" : "${env.VARNAME}" does not work if VARNAME is set in active kit’s "environmentVariables". Empty string is used instead. Ditto for "cmake.installPrefix".

Although, the following works fine:

  1. "cmake.buildDirectory" : "${buildKit}"
  2. "cmake.configureSettings: { "SOME_SETTING" : "${env.VARNAME}" }
  3. "cmake.buildDirectory" : "${env.VARNAME}" - if VARNAME is set in environment before running vscode, instead of the kit.

Expected:

Values of variables set in active kit’s "environmentVariables" to be used in ${env.XXX} substitution for "cmake.buildDirectory" and "cmake.installPrefix".

Apparent Behavior:

1: .vscode/cmake-kits.json:

[
   {
      "name": "TEST_KIT",
      "environmentVariables": {"TEST_VAR": "TEST"}
   }
]

2: .vscode/settings.json:

   "cmake.configureSettings": {
      "TEST_SETTING": "${env.TEST_VAR}"
   },
   "cmake.buildDirectory": "${workspaceFolder}/__build/${env.TEST_VAR}-${buildKit}-${buildType}",
  1. CMake: Select Kit => TEST_KIT

  2. CMake: Delete Cache and Reconfigure

  3. Output: CMake/Build see below

CMake Tools Log

[proc] Executing command: /usr/local/bin/cmake --no-warn-unused-cli -DTEST_SETTING:STRING=TEST ... -B/home/user/project/__build/-TEST_KIT-Debug ...

Platform and Versions

  • Operating System: VSCode UI: Windows 10 1903, VSCode Server: Ubuntu 16 64bit
  • CMake Version: 3.17.2
  • VSCode Version: 1.45.1
  • CMake Tools Extension Version: 1.3.1
  • Compiler/Toolchain: GCC 5.4.0

Other Notes/Information

Is it expected bahaviour, am I doing something wrong, or is it a bug?

BTW, thanks for the great extension!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
andreeiscommented, Apr 22, 2021

CMake Tools 1.7.1 was released today and it contains a fix for this issue. Upgrade the extension in VSCode and let us know if you encounter any other problems.

0reactions
Fuzzy67commented, Nov 15, 2021

I want to use this “feature” inside cmake.cmakePath in settings.json (in workspace). But it does not work. Neither with version 1.7.1 nor with the current version 1.9.1 od cmake-tools extension. The environment variable is always empty. VScode is version 1.62.2

In cmake.tools-kits.json …

{ “name”: “Ipetronik-Logger (Develop)”, “environmentVariables”: { “IpeBuildPath”: “/home/fabrice/embeddedLinux/Develop/x86_build_develop” }, “toolchainFile”: “/home/fabrice/embeddedLinux/Develop/x86_build_develop/host/usr/share/buildroot/toolchainfile.cmake” },

in settings.json …

“cmake.configureOnOpen”: true, “cmake.cmakePath”: “${env:IpeBuildPath}/host/bin/cmake”, “cmake.generator”:“Ninja”,

Result :

 Bad CMake executable "/host/bin/cmake". Is it installed or settings contain the correct path (cmake.cmakePath)?
Read more comments on GitHub >

github_iconTop Results From Across the Web

Use predefined variables - Azure Pipelines - Microsoft Learn
In YAML pipelines, you can reference predefined variables as environment variables. For example, the variable Build.
Read more >
Environment Variables - The Cargo Book
Environment variables Cargo sets for build scripts. Cargo sets several environment variables when build scripts are run. Because these variables are not yet...
Read more >
Variables - Gentoo Development Guide
There are a number of special variables which must be set in ebuilds, and many more ... In a cross compiling environment, ebuilds...
Read more >
Environment - Esy
Some packages need to set environment variables in the environment of the ... where esy "variables" can be used which will automatically be...
Read more >
Configuring CMake Tools - vector Of bool
An object containing key : value pairs of environment variables, which will be passed ONLY onto the compiler. Default: null (Unspecified). Supports substitution...
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