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

buildType variable substitution inconsistency with variants #1366

Closed
njames93 opened this issue Jul 12, 2020 · 4 comments
Closed

buildType variable substitution inconsistency with variants #1366

njames93 opened this issue Jul 12, 2020 · 4 comments
Labels
bug a bug in the product Feature: configure
Milestone

Comments

@njames93
Copy link
Contributor

njames93 commented Jul 12, 2020

Substitution of ${buildType} differs from ${command:cmake.buildType}

Take this cmake_variants.json (contrived for simplicity)

{
  "buildType": {
    "default": "release",
    "choices" : {
      "release": {
        "short": "Release",
        "long": "Fast Shared",
        "buildType": "Release",
        "settings": {
          "BUILD_SHARED_LIBS": true
        }
      },
      "releaseStatic": {
        "short": "Release With Static",
        "long": "Fast Static",
        "buildType": "Release",
        "settings": {
          "BUILD_SHARED_LIBS": false
        }
      }
  }
}

I like to have the global build directory set to
"cmake.buildDirectory": "${workspaceFolder}/build/${buildType}".
for release or releaseStatic this gets expanded to:
${workspaceFolder}/build/Release.
This should be expected as they both specify "buildType": "Release".

When I want to run programs built I use this in my launch.json:
"program": "${workspaceFolder}/build/${command:cmake.buildType}/bin/a.out.
When release config is selected this gets expanded to:
"program": "${workspaceFolder}/build/Release/bin/a.out.
However when releaseStatic is selected this is getting expanded to:
"program": "${workspaceFolder}/build/Release With Static/bin/a.out.

Obviously I could just configre cmake to set the buildDirectory to:
"${workspaceFolder}/build/${command:cmake.buildType}".
But that is not an ideal solution.
What should happen is ${command:cmake.buildType} expands to the same string as ${buildType}, which when using variants should return what the specific variant declares as buildType.
If needs must another variable could be declared that corresponds to a variants 'short' name (Release With Static in this example)

  • Operating System: Ubuntu 20.04
  • CMake Version: 3.7.3
  • VSCode Version: 1.47.0
  • CMake Tools Extension Version: 1.4.1
  • Compiler/Toolchain: clang-10.0.0
@bobbrow
Copy link
Member

bobbrow commented Jul 15, 2020

Thanks for reporting this. There's a minor complication with the status bar text when fixing the command to do the right thing (it expects the "short" text), but it shouldn't be too bad to rework it.

@bobbrow
Copy link
Member

bobbrow commented Jul 15, 2020

I have a fix for this out for PR. It was actually less of a change than I thought it would be. I decided to rename the variables with the inconsistent data in them to avoid this sort of situation in the future.

@bobbrow bobbrow added this to the 1.5.0 milestone Jul 15, 2020
@bobbrow bobbrow modified the milestones: 1.6.0, 1.5.0 Nov 5, 2020
@andreeis
Copy link
Contributor

andreeis commented Nov 5, 2020

This should be fixed in CMake Tools 1.5.0 which was published today.
Let us know if you encounter any issues with this release.

@andreeis andreeis closed this as completed Nov 5, 2020
@njames93
Copy link
Contributor Author

njames93 commented Nov 6, 2020

Seems good, Thanks.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug a bug in the product Feature: configure
Projects
None yet
Development

No branches or pull requests

3 participants