relan / exfat

Free exFAT file system implementation
GNU General Public License v2.0
789 stars 179 forks source link

Initial CMake build system support #87

Closed Lekensteyn closed 6 years ago

Lekensteyn commented 6 years ago

Supports out-of-tree builds without cluttering the source tree (as is the case with autotools) and enable faster builds with Ninja.

The only missing "feature" from autotools is an uninstall target. To mimic this after the install target: xargs rm < install_manifest.txt

Note that header files are not listed in the sources list, CMake automatically discovers what headers are needed.


Main advantage is support for out-of-source-tree builds without cluttering the source tree. Nice side-effect is that a fresh build is 7x faster than autotools. The dependencies autoconf + automake + pkg-config + make can be replaced by cmake + ninja (optional, but recommended).

Build time (n=10, tmpfs):

autotools

command time remark
autoreconf -i 2.55s
mkdir build && cd build && ../configure 1.52s
make 1.70s make -j10 time: 0.84s
DESTDIR=$PWD/fs make install 0.20s make -j10 install time: 0.15s
total 5.97s with parallel make: 5.06
make 0.075s incremental build with no changes; make -j10 time: 0.065s

cmake + Ninja

command time remark
mkdir build && cd build && cmake -GNinja .. 0.366s no need for autoreconf, corresponds to configure
ninja 0.468s
DESTDIR=$PWD/fs ninja install 0.012s
total 0.846s
ninja 0.003s incremental build with no changes
relan commented 6 years ago

Thanks for your proposal and especially measurements! They're pretty interesting.

I have nothing against CMake (I actually use it in another tool of mine); faster out-of-source-tree building is nice. But I don't think those benefits are worth making all package maintainers change their build recipes.

P.S. autotools somewhat support out-of-source-tree builds:

mkdir build
cd build
../configure
make
Lekensteyn commented 6 years ago

Both autotools and cmake can co-exist. I have added/maintained support for both build systems in various projects (some even have both), the only reason why autotools remains would be for cross-compiling and because some people are more familiar with it.

I really dislike having additional junk files in the source tree (Makefile.in, configure, config.status, etc.), autotools is inferior imo. Could you reconsider it, please? :)

relan commented 6 years ago

I'm still not convinced that having two build systems is a good idea, but let CMake live in a feature branch. We might need it in future.