<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>
GitLab
</title>


<style>img {
max-width: 100%; height: auto;
}
</style>
</head>
<body>
<div class="content">
<div>
<p dir="auto">autotools is strong with cross-compilation in a *nix environment and has an interface that users are familiar with, but other than that I dislike autotools:</p>
<ul dir="auto">
<li>Its configure step is slow. A cache might help a bit with incremental runs, but that does not help with new builds.</li>
<li>It requires autoreconf to be run before anything useful can be done. The dist tarball basically includes a binary blob (nobody is going to read the configure and Makefile.in files).</li>
<li>It pollutes the source tree with Makefile.in and other autogenerated files. I am not aware of any solution for this problem.</li>
</ul>
<p dir="auto">I've limited experience with Meson (mostly as user), but with have more experience with CMake (I ported over autotools -> CMake for some projects and also work on Wireshark which supports Linux, macOS and Windows through CMake). Some projects spent the majority in autoreconf + configure, more than the actual compilation O_O.</p>
<p dir="auto">CMake:</p>
<ul dir="auto">
<li>Incremental builds are fast due to a cache (CMakeCache.txt). This file also remembers previous configuration options.</li>
<li>No need for autoreconf, you can run the "configure" equivalent straight away.</li>
<li>Support for out-of-source tree build without polluting the source tree.</li>
<li>The configuration language is different, but should be more readable than shell code for some equivalent functionality.</li>
<li>Support for native build systems like MSVC (would help with CI on Windows, <a href="https://gitlab.com/gnutls/gnutls/issues/638" data-original="#638" data-link="false" data-link-reference="false" data-project="179611" data-issue="16318588" data-reference-type="issue" data-container="body" data-placement="bottom" title="native windows builds" class="gfm gfm-issue has-tooltip">#638</a>).</li>
<li>Supports generating a "compilation database" with <code>cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1</code>, useful for tools like <code>clang-check</code> or editor integration which can use the exact same compile options.</li>
<li>PkgConfig is ubiquitous on Linux for locating packages, but not so much on Windows. CMake supports PkgConfig, but to locate dependencies you would use a "Find" module that locates the library file, header paths and version. This works for all platforms.</li>
<li>I've never tried cross-compiling, but you'd typically use a "toolchain file" and set some other variables (like the root of the target).</li>
</ul>
<p dir="auto">Note that I have not built GnuTLS from git yet. I aborted it after it tried to spend a lot of time retrieving submodules (like openssl). The bootstrap process seems quite complex, couldn't it be simplified?</p>
<p dir="auto">In general this is how autotools and CMake projects could run:</p>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">autoreconf -vifs && mkdir build && cd build &&</span>
<span id="LC2" class="line" lang="plaintext">CFLAGS="-g" ../configure --disable-doc &&</span>
<span id="LC3" class="line" lang="plaintext">make -j$(nproc) &&</span>
<span id="LC4" class="line" lang="plaintext">DESTDIR=$PWD/tmp make install</span>
<span id="LC5" class="line" lang="plaintext"></span>
<span id="LC6" class="line" lang="plaintext">mkdir build && cd build &&</span>
<span id="LC7" class="line" lang="plaintext">cmake -GNinja -DCMAKE_BUIlD_TYPE=Debug -DENABLE_DOC=OFF .. &&</span>
<span id="LC8" class="line" lang="plaintext">ninja &&</span>
<span id="LC9" class="line" lang="plaintext">DESTDIR=$PWD/tmp ninja install</span></code></pre>
<p dir="auto">With meson I believe it will be something like:</p>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext"># set CC to avoid using ccache if installed. Meson does too much magic.</span>
<span id="LC2" class="line" lang="plaintext">CC=gcc meson setup build && cd build &&</span>
<span id="LC3" class="line" lang="plaintext">meson configure -Dbuildtype=debug -Denable_doc=false &&</span>
<span id="LC4" class="line" lang="plaintext">ninja &&</span>
<span id="LC5" class="line" lang="plaintext">DESTDIR=$PWD/tmp ninja install</span></code></pre>
<p dir="auto">Conversion of GnuTLS build system to either might be quite an undertaking since it has quite some custom logic (configure.ac and .mk files). When converting, typically both systems remain next to each other. Eventually one or more older build systems gets dropped when the CMake system is mature enough.</p>
</div>


</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #777777;">

<br>
Reply to this email directly or <a href="https://gitlab.com/gnutls/gnutls/issues/320#note_122487335">view it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.com.
If you'd like to receive fewer emails, you can
<a href="https://gitlab.com/sent_notifications/ccc068a420a64ae4ad06751f0bd64e57/unsubscribe">unsubscribe</a>
from this thread or
adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Issue","url":"https://gitlab.com/gnutls/gnutls/issues/320#note_122487335"}}</script>
</p>
</div>
</body>
</html>