Maven is said to employ a form of Convention over Configuration.

I don't want to draw any wrong comparisons but as far as I understand cmake can fill a similar roll for a C++ project as maven can for a Java project.

So, does cmake have some Conventions over Configuration, or is each project configured uniquely? (Wrt. file layout, test layout, build output, etc.)

有帮助吗?

解决方案

After experiencing the elegance of Maven 3, I also looked for a convention over configuration C maven style system. ...

I also checked out CMAKE, after creating a skeleton a few things stood out.

  1. CMAKE is sometimes declarative, sometimes procedural, and your always going to end up with an ugly mix. AKA, it's ANT for C without brackets.

  2. CMAKE itself IS portable, alas your project will need platform specifics handled and you better know them in advance. CMAKE modules exist to supposedly help with this, unfortunately their re-usability appears more like the promise of Ansible roles... Theoretically possible, but in practice they end up as decent way for you to organize all that complexity required.

In other words, CMAKE is in no shape or form like Maven. It's more like a lower level ANT, that allows you to use the "Cross-platform" DSL to generate platform specific makefiles.

其他提示

The one convention that we strongly encourage is to do "out of source" builds, where the build directory contains ALL build products, and is completely separate from the source tree, usually source and build are siblings:

projects
  proj1-build-x86
  proj1-build-x64
  proj1-src

Two primary reasons we always recommend this strategy are (1) to keep the source tree clean of build products, so it is easy to tell what has changed since your last update from your version control system and (2) so that you may have multiple build trees for any given source tree and not worry about the build products and/or settings from one interfering with the other one.

I recently noticed a project I was working on had inadvertently generated some python files in the source tree. I only noticed it, though, when I tried to build both the x86 and x64 builds simultaneously in different build trees... and suddenly the generated python files had some lines duplicated and intermixed. Changed it to generate into the build tree, and all was well.

This is all just part of CMake good practice, though, and is not strongly enforced by anything other than the common sense and discipline of the smart people running these projects...

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top