Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

launch.json parameters do not fully support cmake settings #1165

Closed
matthewdhunt opened this issue Apr 9, 2020 · 3 comments
Closed

launch.json parameters do not fully support cmake settings #1165

matthewdhunt opened this issue Apr 9, 2020 · 3 comments

Comments

@matthewdhunt
Copy link

Brief Issue Summary

Although you can refer to various CMake (vector-of-bool plugin) settings in launch.json, they cannot contain any variables. For example, in a launch.json, it is valid to write:

 {
    "name": "MFDApp Launch",
    "type": "cppvsdbg",
    "request": "launch",
    "program": "${config:cmake.buildDirectory}/MFDApp/MFDApp.exe",
    <etc...>
},

However, if the cmake.buildDirectory contains any variables itself, this will not work. For example:

 "cmake.buildDirectory": "../SomeDir/${buildKit}/${buildType}"

If this is done, when you attempt to launch the program, it will look for folders literally named ${buildKit}/${buildType} without substitution, which will of course fail. This means you can't use any relative paths in the cmake variables if they appear in the launch.json.

Expected:

When launching an application, VSCode would properly substitude paths for variables such as ${buildKit} or ${buildType}

Apparent Behavior:

When launching an application, VSCode treats cmake variables as string literals.

Platform and Versions

  • Operating System: Windows 10 or Ubuntu 18.04
  • CMake Version: 3.12 or 3.14
  • VSCode Version: 1.44.0
  • CMake Tools Extension Version: 1.3.1
@bobbrow
Copy link
Member

bobbrow commented Apr 9, 2020

Does it work if you use:

"cmake.buildDirectory": "../SomeDir/${command:cmake.buildKit}/${command:cmake.buildType}"

@bobbrow
Copy link
Member

bobbrow commented Apr 9, 2020

Though looking past the specific details of the question, you may also be interested to know that you can update your launch.json to use:

  "program": "${command:cmake.launchTargetPath}"

which will point to the target selected through the status bar UI or the "Set Debug Target" command.

@matthewdhunt
Copy link
Author

No, I'm not sure exactly what it does if you use ${command:cmake.buildKit}/${command:cmake.buildType}. It seems to replace the entire contents of what is in " " with an absolute path of just "build" or something like that. It definitely doesn't just substitute the variables. I'll see if I can figure out what it's doing in a test project without messing with the build folder of the main project.

But, the tip of command:cmake.launchTargetPath is very helpful! That might resolve my use case although not really this bug.

@bobbrow bobbrow closed this as completed Aug 17, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants