I rambled about this recently: https://news.ycombinator.com/item?id=24203172
I rambled about this recently: https://news.ycombinator.com/item?id=24203172
This a language an evil genius might come up with while trying to do good.
Of course it sucks when you actually need something nontrivial.
Saying this as a heavy CMake user with a strong love and stronger hate relationship with it.
Doesn’t CMake not even have a concept of arrays? I remember reading that functions to generate arrays were really just fancy string concatenaters with quote escaping.
All this is just a gentle slap on the wrist for programming in your build system. Or doing something weird like optimizing a CMake-language JSON parser for performance [2].
1: https://cmake.org/cmake/help/v3.16/module/ExternalProject.ht...
That's an awfully polite way of saying Yes, the CMake scripting language is indeed terrible.
It's meant to be used for complex package-detection logic. CMake Find modules can run hundreds of lines. It's not unreasonable to expect proper support for arrays, proper functions that can return values, a sane syntax, etc.
I've been using CMake for around a decade and I have to say I never experienced anything remotely similar to what you described.
Do you mind sharing a real-world example of something that you struggled with while working with CMake?
I gave up. CMake is just too frustrating to work with. Hard to debug, different API versions, many different ways to do the same thing, hard to understand the abstraction of CMake itself. Total time sink. I will never use that again.
This is a huge problem with too many things - CMake included. Backwards compatibility is often being praised too highly.
CMake you run to generate files that will build your thing in a single configuration (platform, runtime settings, etc).
Visual Studio wants to have a solution where you can switch between many configurations (platforms, runtime etc).
Yes, I have looked into latest Visual Studio CMake integration but it doesn't suit my needs because it puts the build files in some arbitrary hidden random location on disk.
add_custom_command(TARGET project POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
some.dll
$<TARGET_FILE_DIR:project>)What's hard about that? You have a subproject per folder, in each subproject you specify the build targets and dependencies, and then you just specify build precedence in downstream libraries when need.
Exactly which problems did you experienced getting this to work?
The issue you linked to was changing the environment after running the "configure" step, but the availability of the header that had been newly installed was cached to "not available", so re-running cmake used the cached "not available" instead of checking the system again. Or something like that. Seems like a classic trade off of speed vs correctness. Something like SCons would always check everything and ran super slow, whereas CMake opts for not checking things that are less likely to change and caching the result. That shouldn't be used as a reason to throw away all the other good stuff CMake has :-)
To revisit the points I made in the old thread [0]:
We pay a price for fragmentation; it's better we all agree on one system. (Although I think it's fair to say that autotools has had its time in the sun at this point, I don't see a big problem in using it for Unix-only projects.) CMake can work very well, with impressive portability, if a project's CMake scripts are rock-solid. I plan to continue to use CMake, despite its considerable shortcomings.
If CMake did the following things, I could probably forgive the atrocious scripting language:
1. Overhaul the documentation. Every unit of documentation should be accompanied by an illustrative example; dry rambling essays are not the right format. Do what Microsoft do with their .Net documentation.
2. Official design-patterns for common tasks like Find modules. They shouldn't each have a character of their own. These scripts ought to be very consistent, very boilerplate-driven, and very boring.
3. Rework the officially bundled CMake scripts so that they all follow the current best-practices to the letter. As it stands, there's nowhere to go to see what real CMake scripts are meant to look like.
I would suggest a linter/improved errors and warnings, but I don't know if that's practical. I would suggest replacing the entire scripting language with something less awful, but it wouldn't do to throw out compatibility. Stability is a must-have for this kind of thing.
https://doc.qt.io/qbs/index.html
(Unfortunately it has been deprecated)