r/cpp • u/IsDaouda_Games • Feb 18 '21
Now announcing: Makefile support in Visual Studio Code!
https://devblogs.microsoft.com/cppblog/now-announcing-makefile-support-in-visual-studio-code/27
Feb 18 '21
Is anybody here writing cross-platform Makefiles manually? Why and what's your experience with it?
35
u/Plazmatic Feb 18 '21
Isn't CMake made expressly for your situation?
48
u/zzzoom Feb 18 '21
CMake is made expressly for developer misery.
9
u/helloiamsomeone Feb 19 '21
Having seen the kinds of CMLs most people write, the misery is always self inflicted.
8
u/AlexReinkingYale Feb 19 '21
Maybe in the 2.8.12 days. Modern CMake is pretty darn simple.
7
u/zzzoom Feb 19 '21
In my experience, CMake is simple (you wouldn't start using it otherwise) until you need to do something that isn't boilerplate, and then it becomes a nightmare to use. In my case the tipping point was a project with mixed C++, CUDA and Fortran code.
3
u/helloiamsomeone Feb 19 '21
project with mixed C++, CUDA and Fortran code
The only difference that makes is you have to enable 3 languages instead of one in your
project()call.5
1
-8
0
Feb 18 '21
[deleted]
8
u/Plazmatic Feb 18 '21
I've never run into a situation where tuning a library or program specifically ever required touching a make file when using cmake. Can you specify exactly what kind of situation would call for this?
0
Feb 18 '21
[deleted]
8
u/Plazmatic Feb 18 '21
Those are just compile args AFAIK, that has nothing to do with make, which is itself not intrinsically tied to C. There's no reason I can see that this situation can't be handled from CMake.
10
u/chugga_fan Feb 18 '21 edited Feb 18 '21
I've seen them, the reason why? The project predates cmake and autotool's existence on windows for a mostly windows project is.... questionable at best, especially in the pre-mingw days.
The experience? Lots of having to figure out how to change path separator handling and finangling between... mingw-make, gnu-make, a custom make software in the actual project(!!!!), and Borland's make solution.
I am forever thankful that I mostly do edits on this project instead of having designed it from scratch, as the amount of effort needed to set up such a system is monumental.
Edit: For the project itself, if you want to see the misery, take a gander:
https://github.com/LADSoft/OrangeC/blob/master/src/pathext2.mak for the path separator handling, https://github.com/LADSoft/OrangeC/blob/master/src/makefile for the main makefile for compiling the thing, and there's https://github.com/LADSoft/OrangeC/blob/master/src/treetop.mak for where magic happens.
Fun times
1
u/tden4774 Mar 06 '21
That looks ASSY.
1
u/chugga_fan Mar 06 '21
It's actually very fun to work with, honestly, as many people as possible should work on it so that 2 guys who have other things being done in their life have work to do.
5
u/infectedapricot Feb 19 '21
The problem with this idea is that Makefiles say how you're going to do something, not what you're going to do. So you don't say "please make these source files into a library" you say "please invoke the compiler on these source files, then invoke the linker on the object files". That makes it very hard to be cross platform because Makefiles will almost always hardcode platform-specific details to some extent, such as the extension of object files being
.o(rather than.objon Windows), or the compiler switch for optimisation being-O3(rather than/O2on Windows), etc. And those are just the things that are textual replacements; if anything needs processes to be run in fundamentally different order then it's basically hopeless to make a cross-platform Makefile for it.2
u/livrem Feb 19 '21
Have worked in some large projects where that is done. Android make system used to be based on regular make (and, I believe, to a large extent still is?) for instance. Those systems have had layers of magic macros and stuff to the extent that the Makefiles barely look like Makefiles anymore to handle all the trickery needed to support all target and build platforms. Guess someone at some point in time had a good reason for doing that instead of just using something like cmake or scons.
3
u/zsaleeba Feb 19 '21 edited Feb 19 '21
I prefer makefiles over cmake because cmake is pain. It's possible to write neat, concise makefiles which are shorter and more readable than cmake as long as you keep things simple. Not because makefiles are great but because cmake is an exercise in pure horror.
Having said that I usually use meson these days. It's pretty sweet.
6
u/GlitchedMirror Feb 18 '21
How does the intellisense work? Is it like bear? https://github.com/rizsotto/Bear
Are there many projects that use make without autoconf, cmake, etc?
All I think is the linux kernel.
2
u/zaywolfe Mar 05 '21
As a cpp beginner I'm finding make is easier to learn than cmake. Making a nice automated build process in make is super satisfying and I'm learning how to use the compiler command directly which is really helpful to understand how the compiler and linker work.
12
u/aWildElectron Feb 18 '21
Heres to hoping it won't be as bloated and bug-ridden as their cmake tools extension
16
u/GunZinn Feb 18 '21
I wish they’d give the CMake extension more love. Adding syntax highlighting and language service would be nice.
12
u/CrazyJoe221 Feb 18 '21
Which wasn't created by them initially, to be fair. They just took over maintenance.
4
u/marian_l MS C++ Group Product Mgr Feb 19 '21
Hey, what issues are you seeing with the CMake Tools extension? My team would definitely like to make sure that these issues are tracked here Issues · microsoft/vscode-cmake-tools (github.com). We'll get to them as soon as we can to make sure folks have a great experience with Code regardless of the build system they're on.
0
u/bici96 Feb 19 '21
True programmers only use Emacs :)
5
-2
u/waruqi Feb 18 '21
we can use xmake + vscode to write and build c/c++ projects.
3
Feb 19 '21
You can also use MSBuild. You can also use cmake. There’s no best solution. Everything has its faults.
92
u/[deleted] Feb 18 '21
The best success I've had with VSC is using the remote ssh extension to access a linux server. Makes coding c++ 100x easier (in VSC).