5 ms·
CMake suffers from a lack of conventions. If you want to follow some set of conventions and have one directory for your headers and another for your sources and
by ryanianian 8y ago
CMake suffers from a lack of conventions. If you want to follow some set of conventions and have one directory for your headers and another for your sources and another for your tests etc you still end up having to write a hundred lines or more of error-proned CMake.
As ugly as things like Maven and Gradle are, if you follow all of their conventions they get out of your way.
In addition:
- no cross-platform way to require a compiler version or way to set compiler flags
- linkers are not abstracted from you (good luck trying to get cross-platform support for relocatable binaries; cmake really bungles up rpath etc)
- also good luck trying to link both static and dynamic libraries and targets
- third-party libraries aren't really a first-class thing
- no simple way to specify "build all these things into the target directory with a conventional file layout"
80% of projects need to deal with these and not a lot else. Why is there not a list of "follow these conventions and you don't really need to write or look at cmake file"?
(To be fair: compilers, linkers, and OSes share some blame in not being more consistent but the goal of a competent build-system is to handle these things for the 80% case.)
It doesn't really matter how terrible the syntax and internal implementation are if most reasonable use-cases don't need to look at it.
- SAHChandler 8y agoAuthor of the post here. The compiler version thing is definitely an issue. That said, if you're worried about having to litter `if/endif` calls all over the place, I recommend you look into CMake's generator expressions. relative rpath support was added very recently and will be in the CMake 3.14 release. It's a shame it took this long to make it in. third party libraries can be imported via add_library, and then setting the imported location. This allows, I should note, the ability to link against both static and dynamic libraries. IXM is being developed to make it easier to do the layout system as well as make the 80% you've mentioned here basically a non-issue, and comes with a fairly decent (in my opinion) default layout. Because it's not even in an alpha state I've not had time to document it. (Also, I am working on a build system replacement for CMake, which includes a compiler frontend translator so you can solve the cross platform compiler flag issue. CMake is simply being used to "brute"strap the project until it is self hosting)
- stefan_ 8y agoThey recently added a convention: target-based CMake! Now, because they are switching to what every sane build system was 5 years ago, but over the course of 10s of 3.x versions, your CMake buildfiles are about to explode in complexity and frankly, stupidity. Lots of "does this target exist already because I need to support some older version alongside bleeding edge" and usually, if not, just copy that stuff over from their HEAD. Everything they touch goes terrible. We just need to stop with like version 3.10, pretend CMake is dead and slap a DEPRECATED warning at the beginning. It's the only way out.