r/cpp • • Sep 10 '16

Recommend a build system

I'm curious what people are currently recommending as build systems for C++ based projects. Specifically I'm after the following features:

  • Cross-Platform, supporting at the very least OSX and Linux

  • Easy to support C++14, preferably without needing to do per-platform/per-compiler configuration

  • Easy support for multiple libraries/executables as one project, and dependencies between libraries/executables in the project - especially regarding finding include files if the different modules are in different areas of the source tree.

  • Decent support for external dependencies. I'm ok with needing to have installed the dependency libraries first though

  • Support for dynamically finding source files if possible. (I'm used in Java, and most of the Java build tools just use every single file in the source directory for a given module)

  • Support for building and executing tests

  • Support for static checks

  • Support for generating documentation, and generally running other tools as part of the build

  • Ideally, support for being able to execute tooling before and after test execution - to be able to start up externally required services such as databases.

Is there anything that supports this entire list? (I'm assuming not) Or what would people recommend for use that at least comes close. I'm perfectly happy with tools that are opinionated about how the source tree should be laid out, if that fits the bill better.

60 Upvotes

189 comments sorted by

View all comments

Show parent comments

7

u/[deleted] Sep 11 '16

No, because when you add the file to CMakeLists.txt the build system sees that it is out of date and runs the correct bits for you automatically. You just type ninja or make and you get correct incremental behavior.

0

u/render787 Sep 11 '16

Hmm well maybe I did it wrong sometime in the past, but even so, if that's how it's supposed to work, that's even better than what streu seemed to say.

In many projects running cmake is trivial and takes no time, I often just build using a shell script which nukes the build directory, and reruns cmake and make. If you are using ccache it's not slower than an incremental build.

2

u/streu Sep 12 '16

Throwing huge amounts of caching to solve a problem that shouldn't exist doesn't sound like sensible use of technology.

That aside, the CMake projects I work with sometimes take minutes just to generate the Makefiles, and often take hours to build from scratch. "In many projects running cmake takes no time" just says you have not seen huge projects yet.

1

u/render787 Sep 19 '16

I see, forgive my ignorance then. But I still think that manually specifying the list of files in a directory rather than globbing it seems like a bad thing. Do people working on large projects use a tool or something to keep such lists up to date, that exists outside of cmake? Otherwise it seems like a needless maintanence burden.

1

u/streu Sep 19 '16

How often do you add or remove files that this is an issue?

It is a level of redundancy that helps detecting errors like "I forgot to check this file into SVN" or "I forgot to remove this test file".

Arguably, the right level of redundancy differs from person to person. For someone doing Java, C++ is totally redundant with its split into ".hpp" and ".cpp" files. I like it because it specifies the interface separately, although it means I have to change function signatures at two places.

→ More replies (0)