-
Notifications
You must be signed in to change notification settings - Fork 461
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
do not parse cmake.preferredGenerators, instead just hand it over to cmake via -G option #33
Comments
Part of the reason to parse it is because of the "Preferred" idea. If one generator is unavailable, try the next one in the list. I tried to determine the availability myself, but it seems I can't quite get it right (See #1). If I delegate to CMake to try each generator, it would be more reliable, but it could significantly slow down the ability to configure the first time in the case that one or more generators in For example, the default first generator is Ninja because if a user has it installed, they definitely want to use it; but for users that don't have it installed, they will fall back to using the Makefile generator for their platform, and most users never even need to know that the "preferred generators" setting is even a thing. |
That's right. But by hardcoding the generator check, you tie your plugin to only work with certain cmake versions, and not with others. For example, the generator "Visual Studio 10" recently has been changed to become "Visual Studio 10 2010", and the destination platform suffices (32bit vs 64bit build) only recently were added. Thus, if you rely on some generator name syntax, you lose compatibility of your plugin. |
I agree. Preferred feature is not needed at all. What generally developers want is just to set generator per project basis. So a cmake.Generator field for the project settings with valid generators is the only thing needed. Which should be passed directly with -G to cmake |
Important thing first: That's a really useful VS Code extension you've written there. Thanks a lot for that! However, I'd also like to join and argue against the current parsing approach, although I understand the rationale behind. Unfortunately, this restricts the vast range of possible cmake generator configurations far too much. Best example is in fact the Visual Studio generators, to which the extension currently defaults on Windows. However, the full configuration not only requires the For myself, it's also not possible to switch to Unix Makefiles using Cygwin or MSYS2 on Windows since the Unix Makefile generator is not accepted. See also #40. Thus, I'd suggest to keep the current possibility of trying to figure out a default with the |
Ah! I didn't even consider the I'll probably go the route of allowing the user specify their generator explicitly, and falling back to the current logic if it is unspecified. I'll also add options specifically for the toolchain and platform, and something generic like Does that sound good to everyone? |
I'm gonna push it a little bit further if I may. Integrated terminal does it this way:
That would completely let the user customize cmake generators and toolchains for every OS in a single settings file. |
As a first step, that's probably too much. A future way after the simple additional arguments could be then to enable build-configuration-configurations ;-) Something like all the settings that you would pass to cmake, the shell to use, debugger settings, build type, etc. and then choose from those similarly as choosing between Debug and Release. But that's certainly way more effort to implement in a really user-friendly way. |
Thanks for all the suggestions! I have a pretty common use case where I want to be able to flip back and forth between a few sets of configuration settings, so that may be something coming soon. I'll take a look at this some more later when I get some time. |
+1 for the ability to pass any flags, but that would also mean we'd need custom build command. |
@grisevg: The build command is handled already for Visual Studio solutions. For this extension, it uses CMake also lets you pass options to the underlying build tool using the |
@vector-of-bool oh sweet, didn't know about that! No reason then not to support any generator passed as string, right? Or even better, just allow any custom flags. |
The 0.5.4 release should address most of the concerns mentioned in this thread. Any feedback/comments/complaints/questions are welcome. If this particular issue is solved for everyone, I'll close it. I've opened up this issue to track build variants, as discussed above. |
Now support forcing generator based on platform. Should fix most concerns. I'll close this unless anyone else would like to bring up more concerns |
Great news: next cmake version will support explicitly asking for capabilities, including what generators are supported. I feel that the upcoming vscode and cmake updates will really open up the door to some great opportunities regarding what can be done with this extension. Stay tuned... |
I couldn't make cmake to believe it was in a mingw environement. When I run cmake from MSYS2 shell (command line of mingw-w64) it works OK but when vscode-cmake-tools runs it, it can't see gcc, libs, include etc... Which is of course not the fault of vscode-cmake-tools but is there something that can be done to overcome this? |
It's possible it is an environment issue. Have you tried running vscode using the msys2 shell? |
@tapir: it certainly is a environment issue. the MSYS2 shell sets up the path correctly for the MSYS2 provided CMake to be able to find your compilers. For all other readers a quick tip as a starting point: To be able to use CMake Tools mostly seamlessly with MSYS2/MinGW64 or Cygwin64 on Windows: Launch your MSYS2 or Cygwin shell (e.g. bash), and start Visual Studio Code from in there by simply typing:
On Cygwin you might need to prepend Still, setting the generator to "Unix Makefiles" or "Ninja" might be necessary either by giving the CMake Tools setting in your projects |
I just tried to set an invalid value in my user settings:
"cmake.preferredGenerators": [ "xxxVisual Studio 14 2015"]
and did a "CMake: Configure" step.
I wanted to see if the plugin is agnostic to the contents of that variable
and just properly passes it to cmake (in case that the cmake developers
add new generators).
This led to the strange effect that
That's different from what I expected the tool to do:
The text was updated successfully, but these errors were encountered: