186 points · by waruqi · 7y ago · 183 comments
When did "Show HN" threads became shark tank? Can people at least check and post about the tool itself instead of discussing CMake vs Ninja vs Meson?
From the 2007 announcement of Dropbox:
https://news.ycombinator.com/item?id=8863
""" 1. For a Linux user, you can already build such a system yourself quite trivially by getting an FTP account, mounting it locally with curlftpfs, and then using SVN or CVS on the mounted filesystem. From Windows or Mac, this FTP account could be accessed through built-in software. """
They tried to sell their 'get public URL' wrappers as the replacement for the functionality, but that only covered a tiny aspect (and OneDrive, Google Drive, etc already offered that stuff) - sharing photos - and even that was slower due to them wrapping the files in some sort of viewer instead of giving the raw file data like the public folder did, while using some sort of hash ID to identify the file instead of the actual filename (this was another convenience lost since with the public folder i could guess the URL to share without copy/pasting).
I never found anything as convenient as Dropbox's public folder while the rest of their offering wasn't anything i cared much about and even then by that time both Google and Microsoft's offers were better (and with Microsoft's available right out of the box in Windows).
People tend to stick to familiar topics ... as shown in the next Meson comment turned to Python2-vs-Python3-compatibility in a whim.
Thanks for trying to improve the ecosystem around native code building tools. I appreciate it a lot.
Large projects such as systemd and gnome[1] have migrated or have been migrating for years
[1] https://wiki.gnome.org/Initiatives/GnomeGoals/MesonPorting
ninja isn't installed on macOS and Windows, and both systems require to first install a package manager before installing ninja, or compile ninja from scratch.
Having everything in a single standalone executable is vastly preferable IMHO.
Meson has no glob support.
Meson does not support any form of remote caching.
add_requires("libuv master", "ffmpeg", "zlib 1.20.*")
add_requires("tbox >1.6.1", {optional = true, debug = true})
target("test")
set_kind("shared")
add_files("src/*.c")
add_packages("libuv", "ffmpeg", "tbox", "zlib")That's not how dependencies are discovered in cmake. Dependencies are added with calls to find_package, and if you have to include dependencies that don't install their cmake or even pkconfig module then you add your own Find<dependency>.cmake file to the project to search for it, set targets, and perform sanity checks.
* No standardization or opinionated design, so you can't share your work easily.
* No sane defaults, so your build system is always fragile, difficult to maintain, and done wrong.
* No best practices, so people keep making the same mistakes over and over.
* Misguided attempt to remain compatible with the steaming pile of legacy they've accumulated over the years.
* Bad documentation, so there's no way to learn how to do things better.
* Steep learning curve with limited payoff, so most people don't bother.
Meson does some of these things better. It's still not pretty, but it's nicer to use than CMake.
You forgot to mention that the language is awful (but that usually doesn't get in the way IME).
The answer is that CMake is mad and full of gotchas. Think of it like the PHP of build systems. Here is a classic example:
https://cmake.org/cmake/help/latest/command/if.html#variable...
CMake actual gotchas I dislike enough to avoid it as much as possible include defaulting to cached information, even after I make changes, and preferring "smart", opaque and even hard to track down scripts to explicit user input. It seems optimized for cleverness and conciseness, at the expense of reliability and required user effort.
You are very fortunate if you import libraries that just work. This is also true for "modern" CMake.
I'm probably biased as I write and maintain Starlark for C++ codebases on a daily basis.
https://github.com/tboox/tbox/blob/master/src/tbox/xmake.lua
That is, I have a bunch of .cpp files which need to be compiled into individual executables in a folder bin/. I also have a folder inc/ which contains some headers (.h) and those headers possibly also have some associated TU (.cpp).
Now g++ can already generate a dependency graph of headers for an executable. It is then (with a standard Makefile and some supporting bash scripts) quite straightforward to mangle that graph into a list of translation units (namely those files whose name matches a depended-on header) which must be compiled and linked into the executable.
That is, I can simply create a new "executable file" .cpp file in bin/, include some headers therein and when I say make, the Makefile automagically figures out which (internal) dependencies it needs to link in when linking the executable.
Now that I have these "relatively straightforward" scripts and the corresponding Makefile, the incentive to move to another (nicer) build system which would require me to rebuild this infrastructure to fit into this other build system's view of the world is quite low – unless there is some way to do this directly?
Xmake as shown here (and also Meson linked in a sister comment) appear to still require manual selection of dependencies.
Actually, it cannot; and this should be well known. It emits in practice less than half of the information that it knows from path lookup, that a build system really needs to know.
And when it comes to creating a library, it's difficult to infer which TUs should be pulled in or left out since you'd need to see at least representative samples of the use of that library to be able to infer that.
I.e. you just have to put all the source files from which you generate object files that will go in the same libray in a set of directories which does not contain files that will not go there.
Similarly, all the source files for the object files required for an executable, except those that are in libraries, should be in a set of directories.
The sets of directories need not be disjoint, just a given set must not contain files that must be excluded for linking a certain target, as that will make the building process more complex.
Given this constraints, it is possible to write a universal GNU makefile usable for any project, which will generate automatically all dependencies.
For any executable or library you want to build, it is enough to write an extremely small makefile, containing 4 lists (of defined symbols, of source files, of directories with header files and of libraries) and the name of the generated file and its type (excutable, shared library, static library).
At the end you need to include a makefile that is good for any project targetting a certain CPU + operating system combination.
The makefiles per CPU/OS must define a few things, e.g. the compiler used and other utilities, option flags for all, locations of the tools and so on, then you include a unique makefile for all architectures and operating systems.
I have started using this method more than twenty years ago and I have never ever needed to write manually any dependency information.
Whenever I see the huge and intricate and impossible to maintain makefiles that are too frequently encountered in many software projects, I wonder how one is willing to waste so much time with a non-essential part of the project.
From my point of view, building easily any large software project is a problem solved a long time ago by gcc & GNU make, but for reasons that I cannot understand most people choose to not do it in the right way.
Of course having to use in 2019 a programming language which does not implement modules by any better method than including header files is something even more difficult to understand, but I still must use C/C++ in my work, as there is no alternative for most embedded computers.
However, one typo can lead to a confusion because an entire word is missing. In the 4 lists that must be written in the makefile, the most important list, as the other lists can be omitted, is the list of directories with source files (not a list of source files).
For simple projects the list will be reduced to a single source directory. Whenever you add, delete or rename source files, there is no need to edit the makefile of the project.
All changes can be taken automatically into account by GNU make, which can be instructed to scan the source directories for source files for all the programming languages that you use.
This will hopefully change with the introduction of C++ modules in C++20 but until them the best option available to C++ programmers is either manually managing third-party libraries or employing dependency management tools such as Conan.
However, just because it is (like most build system questions) outside the scope of the standard does not mean that it isn’t possible to define some project-internal rules about what gets compiled and linked into what and that the build system cannot apply those rules to take work away from users.
The few external dependencies my project has are installed semiautomatically before any compilation starts.
If you are writing an open source C++ library, even if you support some other C++ build system, chances are you will also have CMake support as well.
While I have no doubt, xmake is easier to use than CMake (just having Lua over CMake's abomination of a language is a great improvement), the fact that so many libraries and tools already support CMake is going to make adoption an uphill battle.
As user, I find the experience with autotools to be much nicer as well. For whatever reason, the interface just seems more intuitive. I mean, ./configure --help will tell you basically all you need to know. An underappreciated bonus is that you don't have to install more stuff just to __build__ some program you might not even want. I've run into more than one project that required a specific version of cmake, which as luck would have it, was not the version packaged with my distro. This leaves you either building another cmake first or finding a tool/library that isn't so persnickety.
Given the choice between trying a project that uses CMake or or autools, I'll choose the autotools based project every time.
sorry what ? I remember hours in my younger years searching which Debian package provided autowhateverflavoroftheday.sh so that I could build $random internet project
They would disagree with you.
* Borland Makefiles
* MSYS Makefiles
* MinGW Makefiles
* NMake Makefiles
* Unix Makefiles
* Watcom WMake
* Ninja
* Visual Studio projects
* Green Hills MULTI
* Xcode projects
And more: https://cmake.org/cmake/help/latest/manual/cmake-generators....
"generate native makefiles" (I prefer Ninja myself) - this is what used to build software
Kind of like a container for building? I had to look it up myself.
Unless remote dependencies are used, this is optional.
target("test")
set_kind("binary")
add_files("src/*.c", "src/*.cpp")
add_cflags("-fPIC", "-Dxxx")
add_cxxflags("-fPIC", "-Dxxx")
The command line arguments just give you a quick and easy way to modify cflags.The people behind cmake already learned that lesson with their modern cmake approach, but it seems the xmake people didn't do a proper review of the state of the art.
Or scons? https://scons.org
I wouldn't find having many build system such an issue if they'd just add a makefile (and maybe ./configure) to call that build system, giving devs a consistent interface and not having to lookup up how to do a simple build.
That's the whole point of cmake. Instead of running autotool's ./configure (which in fact is a whole dance involving autoconf, autoreconf, automake, and whatnot) just run cmake . to get yourself a fancy makefile.
Well most instructions I've seen start of with "mkdir build && cd build && cmake ../src", which is a bit more complicated than just "make" with a default build dir. I'm not sure why they're all like this, I would have though supplying a default build directory is something cmake could handle.
My last and only big project with cmake we ended up with a makefile anyway to drive all the things cmake couldn't do, or that we couldn't do with cmake due to inexperience or some combination of the two. So we ended up with make calling cmake calling make, all because it apparently made it easier for IDE users (it didn't but that was definetly our fault).
To be fair, cmake was at a time the n+1 build system but nowadays it's pretty much the only option in C/C++ land.
Conan and Meson seem so much better in that regard.
You can see https://xmake.io/#/home?id=cross-compilation and https://xmake.io/#/home?id=mingw
What would it take beyond https and a well-known site to make you comfortable doing this?
Most package manager use an offline signature mechanism done at build time (rpm, dpkg, nix) and do not rely on HTTPS security for anything else than eyes-dropping reasons.
Relying purely on HTTPS is insecure. Nothing guarantee you that your source / script / package did not get hacked / modified between the time you uploaded it and the time your user downloaded it.
This is not hypothetical scenario, it already happened in the past with sites like sourceforge.
Normally the packager and developer are different people so there is a second set of eyes to at least give a cursory glance to the changes. It takes more than a single compromised account to publish malicious changes. There are of course a million exceptions and caveats to this and it's not perfect, but it's better than allowing developers to push code directly.
The vast majority of users would trust Homebrew (for example) to not do something like that.