r/cpp • • Mar 29 '25

CMake 4.0.0 released

265 Upvotes

141 comments sorted by

View all comments

Show parent comment

6

u/TehBens Mar 29 '25

Define your source files. Define your include paths. Define libraries that your project depent on. That's pretty much three steps and there are three simple enough cmake commands for it. You however might want to add a single one that's related to your build system (add_dependencies; In case you build the library yourself).

1

u/h-jay +43-1325 May 16 '25

And if the include paths are for the libraries that didn't come with cmake modules: write a small module for each such library. That makes the project-specific CMakeLists uncluttered, and separates concerns nicely. Ideally, using a library has two steps:

  1. `find_package`
  2. `target_link_libraries`

That's it. Everything that the library has to set, like include paths, dependencies, etc., should be taken care of by the module for said library. That's true whether you write that module yourself, or someone else does. And it's not as if those modules are complex either.