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

Different build directories for different build types #559

Closed
Sarna555 opened this issue Oct 10, 2018 · 13 comments
Closed

Different build directories for different build types #559

Sarna555 opened this issue Oct 10, 2018 · 13 comments

Comments

@Sarna555
Copy link

Brief Issue Summary

Different build directory for different build type

Expected:

For instance,
I got Debug and Release build types.
I want to build Debug in "Build-Debug" and Release in "Build-Release" directories.
Of course I want it preconfigured without having to change this every time I change build type.

Other Notes/Information

Sorry if it's possible and I haven't found it.

@vector-of-bool
Copy link
Contributor

Check here. Set cmake.buildDirectory using ${buildType}.

@Sarna555
Copy link
Author

Thanks for the quick response!

It partially solves my problem because I got two Debug and two Release configurations and I wanted to have it all in separate build directories if possible.
The most natural way (at least for me) would be to have additional option in Variants, buildDirectory
For instance

buildType:
  default: debug
  choices:
    debug:
      short: Debug
      long: Emit debug information
      buildType: Debug
      buildDirectory: ${workspaceRoot}/build-debug
    release:
      short: Release
      long: Optimize generated code
      buildType: Release
      buildDirectory: ${workspaceRoot}/build-release
    asan:
      short: Asan
      long: Instrument with Address Sanitizer
      buildType: Asan
      buildDirectory: ${workspaceRoot}/build-asan
    tsan:
      short: Tsan
      long: Instrument with Thread Sanitizer
      buildType: Tsan
      buildDirectory: ${workspaceRoot}/build-tsan

@vector-of-bool
Copy link
Contributor

That is also supported, but using this ${variant:something} syntax.

@nsubtil
Copy link

nsubtil commented Oct 12, 2018

I was about to file a similar issue, this is really helpful.

I'm having trouble figuring out how this interacts with launch.json, however. Is it possible to get the path to the current CMake build directory in launch.json via variable substitution somehow? Is there some documentation on the list of vscode-cmake-tools commands that can be used with the ${command:} syntax in launch.json?

@vector-of-bool
Copy link
Contributor

In general any palette command works with ${command:} syntax, but the only useful one CMake Tools provides is cmake.launchTargetPath. Support for additional substitution commands is possible, and worthy of a separate GitHub feature request ticket.

The variable substitutions supported by CMake Tools in settings.json and what is in launch.json may have similar syntax, but they are almost entirely disjoint and implemented completely separately.

@Sarna555
Copy link
Author

Sarna555 commented Oct 15, 2018

That is also supported, but using this ${variant:something} syntax.

Sorry for being a pain but I have no idea how to use it 😄

@nsubtil
Copy link

nsubtil commented Oct 15, 2018

Filed #564 requesting variable substitution for cmake.buildDirectory.

As a follow-on dumb question:

In general any palette command works with ${command:} syntax

I've always had trouble figuring out the appropriate ${command:} syntax for a palette command. Is there a list somewhere?

@bobbrow
Copy link
Member

bobbrow commented Jul 22, 2019

@Sarna555, ${variant:something} should just be ${variant:buildType} in the case of the yaml you posted above.

Another example:

image

Using ${variant:testVariant} resolves to foo when "Foo" is selected

@xgdgsc
Copy link
Contributor

xgdgsc commented Aug 28, 2019

Is it possible to set "${workspaceRoot}/build-${buildType}" by default? This is the only thing that I find inconvenient switching from other IDE.

@bobbrow
Copy link
Member

bobbrow commented Aug 28, 2019

Do you mean you want that to be the default for all workspaces? You should be able to set it as the default by editing the "User" setting for it:
image

@xgdgsc
Copy link
Contributor

xgdgsc commented Aug 28, 2019

Thanks. I know that. I just think it might be worth considering to make it the default option after install this extension.

@dmsteck
Copy link

dmsteck commented May 13, 2020

@xgdgsc Agree. This is such a basic feature and it should really be the default behaviour of the extension.

For example, CLion uses cmake-build-${buildType}, where the build type is also lowercased.

@bobbrow
Copy link
Member

bobbrow commented May 13, 2020

The trouble is that some generators only need a single configure step because they generate all variants up front. If the default were based on the buildType, then those generators would have to generate their build rules in N different places even though they are all basically copies of each other.

VS Code doesn't give us an way to have conditional defaults, so this is the least disruptive default.

@bobbrow bobbrow closed this as completed Aug 17, 2020
@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.
Projects
None yet
Development

No branches or pull requests

6 participants