AHTERIX5000 5 days ago

Is there an open source project which uses CMake well and could be used as a reference for good CMake practices?

I've been using CMake for years and it's definitely not the worst solution for building multiplatform C++ projects. But I've never read a CMake script and thought what a clean solution, it's always a bit gnarly.

6
ndiddy 5 days ago

I don't know about "could be used as a reference for good practices", but here's a CMake file for a game project I've worked on if you're interested looking at how someone might use CMake for a smaller codebase (everything large I've used it for has been a work for hire unfortunately). It compiles on Linux with GCC, Mac OS X with Apple Clang, and Windows with MSVC, and supports multiple platform backends (currently SDL2 and SDL3). I've done development work on it with CLion, Xcode, and Visual Studio.

https://github.com/nfroggy/openmadoola/blob/master/CMakeList...

> But I've never read a CMake script and thought what a clean solution, it's always a bit gnarly.

I think using CMake for a cross-platform project that supports multiple compilers will always be a bit gnarly, mainly due to the differences between Windows and Unix-like platforms. MSVC is configured very differently to GCC and Clang so you have to list all your compiler flags twice, and there's no good option for doing system-wide installation of libraries (there's vcpkg, but a lot of stuff on there is missing or outdated) so you have to support both system-wide libraries on Unix-like platforms and user-provided DLLs on Windows.

zX41ZdbW 5 days ago

https://github.com/ClickHouse/ClickHouse

We are trying to use CMake in a very limited fashion.

For example, any build time environment checks are forbidden (no "try_compile" scripts), and all configuration for all platforms is fixed.

We don't use it for installation and packaging; it is only used for builds. The builds have to be self-contained.

We also forbid using CMake files from third-party libraries. For every library, a new, clean CMake file is written, which contains the list of source files and nothing else.

From this standpoint, there should be no big difference between CMake, Bazel, Buck, GYP, GN, etc.

OneOffAsk 5 days ago

ParaView [0] and VTK [1] are big projects from the same shop that does CMake.

[0] https://github.com/Kitware/ParaView

[1] https://github.com/Kitware/VTK

ridiculous_fish 5 days ago

LLVM's CMake build has had lots of love poured into it.

sho_hn 5 days ago

KDE's stuff (which is the original reason CMake became popular and adopted) remains updated and fairly clean.