2

Choosing a Modern C++ stack

 1 year ago
source link: https://carlosvin.github.io/langs/en/posts/choosing-modern-cpp-stack/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Choosing Build System (Meson)

I have used before Make, Maven, Scons, Gradle and Autotools, but I have some reasons to try find something else:

Autotools

It is not easy to configure and maintain. There are several configuration files and several configuration steps.

Gradle

C feature is still incubating. Not very fast. You can check a similar example project at link:/posts/gradle-cpp/[Build C project with Gradle].

Make

I don’t love the syntax. Files tends to get messy as project grows.

Scons

It is just slower and not as easy to understand than Meson.

Maven

It is slow and you might end up "Javatizing" your C++ project structure.

I’ve listed just things I don’t like, those projects have other great features.

CMake vs Meson

After discarding previous ones, I’m considering Meson or CMake. Both are fast build systems:

Although Meson is written in Python, it generates a Ninja build project. First time you configure the project you have to run Meson, but for building or testing you are actually running Ninja.

CMake

It has a big advantage over Meson, it is mature and widely used in many projects, which means there are many examples and it will fulfill your C++ project building needs.

Meson

It is a young project compared with CMake, but it is growing quite fast and it has been adopted in other big projects like Gnome, they have an initiative to port from Autotools to Meson.

Finally I’ve chosen Meson because syntax is really clear to me, when I read meson.build file I can quickly understand what is happening during build process.

Steps to compile and test a project
  1. First time you configure the project

  2. Each time you build it

  3. Each time you run tests

Other build systems comparisons

I’ve found two interesting comparisons about available C++ build systems, they might be a little be biased because those comparisons come from Meson and Scons.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK