-
Notifications
You must be signed in to change notification settings - Fork 458
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
Allow building in different directories per build type #151
Comments
I'd like that too. |
I need that too. Also, it would be great to have ability to have different CMake build "kits", each preconfigured with specific environment and default CMake parameters and then having separate build directory for each variant-kit combination. This is how QtCreator manages CMake-based projects (I am actually using it for everyday work, but since VS code appears to have more advanced editor, I am considering a switch, but so far QtCreator has much better CMake-based project build and debug support - maybe take some ideas from them?). |
OK, I just found out that this is already possible. Simply put For example:
|
@DoDoENT Great! Is it also possible to specify the generator and and the compiler/toolchain ? |
@maddouri, you can specify generator with |
Awesome, that trick totally solves this use case. Perhaps this can be put in the readme since it seems popular. Closing the issue as I don't think adding a new variable is necessary. |
Sorry to bump an older thread, but using this method, is there any way to get compile_commands to work? ${buildType} doesn't seem to apply to the c_cpp_properties.json file. |
The Even then, if you are using CMake Tools, the |
Sorry to comment old thread, but to me this trick does not seem to cover all cases. How do you handle the case when you have multiple combinations of variants like the example here? How can I specify a different build directory for each combination? (Following the example: |
@gentooise, I use this:
in global I prefer having all my cmake builds folder in one single folder, excluded from backup, but you can also use something like this:
|
@DoDoENT I know I can use build kit and build type, but unfortunately that doesn't solve my issue. I try to explain it better. Consider the following cmake-variants.json:
What I need is to have different build directories for each variant combination (i.e. Right now I'm forced to have multiple It would be nice to have a way to combine variants' names into the buildDirectory, e.g.:
where NB: I named the variant Is there a way to achieve that with the current implementation of CMake Tools? |
Aha, I see the problem. Unfortunately, I don't know the solution. I actually have a similar problem and didn't find a solution. I am currently deleting the build folder each time I need to switch between different variants of the same build type. |
The problem is that I need all build folders to exist at the same time because some builds are complex and depend on other simpler builds, so I cannot delete build folders every time. The only solution I found is to define multiple .code-workspace files with different build directories, but that defeats the purpose of having cmake-variants, because at this point I could simply define different builds for each workspace and abandon the cmake-variants feature (which was quite comfortable). |
@gentooise, did you try |
It works like a charm! That's great, thank you :) |
Currently, it is only possible to build in one directory (default to
build
) no matter which variant you choose. This results in unnecessary rebuilds when switching between debug and release, for example.Recommend adding a configuration variable similar to the following:
Any undefined variants would result in using the default value or the value set in
cmake.buildDirectory
.The text was updated successfully, but these errors were encountered: