Best practice for cpp projects using CMake

This page summarizes the projects mentioned and recommended in the original post on /r/cpp

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • cmake-init

    The missing CMake project initializer

  • Just use cmake-init which sets you up with a variation of the pitchfork layout.

  • moderncpp-project-template

    A Modern C++ cross-platform Project Template with CMake, conan (optional), cppcheck (optional) and clang-format (optional)

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • chromium

    The official GitHub mirror of the Chromium source

  • I don't think the arguments presented in the proposal are a matter of opinion. Not sure I understand exactly what you mean by "searching only headers" or "only test" (though I'm assuming you don't mean something akin to grepping in which case it's very easy to filter by extension), but having the source and header files next to each other makes reading the code base significantly easier. This may not be apparent in small projects, but from personal experience it becomes extremely helpful in large code bases. Take the Chromium project for example (e.g., the networking library https://github.com/chromium/chromium/tree/main/net/base). In a project of this scale, having the header and the source files placed together (and the tests) makes it extremely easy to jump between the declaration of a class for instance, and its implementation or related unit tests (which I believe is an important process). I rarely find myself wanting to look at only the header files of a given project. I do, however, often jump between the declaration of a class in a header file and its implementation in the corresponding source file, and having them next to each other makes it very easy.

  • pitchfork

    Pitchfork is a Set of C++ Project Conventions

  • Just use cmake-init which sets you up with a variation of the pitchfork layout.

  • (source project on gitlab is https://gitlab.com/CLIUtils/modern-cmake)

  • cmake_conan_boilerplate_template

    Discontinued Minimized version of cpp_starter_project

  • cmkr

    Modern build system based on CMake and TOML.

  • I would like to counter with a project I’ve been working on: https://cmkr.build. Unfortunately writing good CMake is extremely repetitive and there is definitely room for a generator that has sane defaults.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • platform_system_core

  • As far as scientific studies go, I'm not sure if there are any that support the arguments of the linked proposal, but if you take a look at some of the most complex, large scale projects out there, you'll notice that they follow to a large extent the same structure as the one outlined in the above proposal. For instance, checkout the Google Chromium project, the AOSP projects, abseil, folly and many others. Of course, there will be exceptions so this is not a foolproof argument but I think it's interesting that projects of this scale have been designed this way.

  • abseil-cpp

    Abseil Common Libraries (C++)

  • As far as scientific studies go, I'm not sure if there are any that support the arguments of the linked proposal, but if you take a look at some of the most complex, large scale projects out there, you'll notice that they follow to a large extent the same structure as the one outlined in the above proposal. For instance, checkout the Google Chromium project, the AOSP projects, abseil, folly and many others. Of course, there will be exceptions so this is not a foolproof argument but I think it's interesting that projects of this scale have been designed this way.

  • Folly

    An open-source C++ library developed and used at Facebook.

  • As far as scientific studies go, I'm not sure if there are any that support the arguments of the linked proposal, but if you take a look at some of the most complex, large scale projects out there, you'll notice that they follow to a large extent the same structure as the one outlined in the above proposal. For instance, checkout the Google Chromium project, the AOSP projects, abseil, folly and many others. Of course, there will be exceptions so this is not a foolproof argument but I think it's interesting that projects of this scale have been designed this way.

  • fixed-size-string-buffer

    A pre-allocated ring buffer for std::string messages

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts