CMake checks that compiles support features by compiling source files with your compiler, and it's slow. I just pulled SDL's source, and it's 16 seconds to run on my i9, most of that time is compiling to check if my compiler supports a variety of features. It's stupid.
as you said those checks take a lot time I they they use the compiler to compile each individual file so that is why it takes alot it could be parralelized
They’re checks that have to be written by the projects. CMake doesn’t know what you might be checking for. SDL has a ton of checks because it supports an incredibly diverse set of targets and toolchains.
The biggest issue imo is that CMake forces these to be done serially. You can’t give it a bunch of checks at once for it to multithreaded for you.
This is a problem that is on the issue tracker of CMake. Looks like someone started tackling it in the last month, but these kinds of problems require someone to sit down, design the feature, communicate with Kitware then implement it.
It’s good that it’s being tracked. At some point I looked into it a year or so ago and it seemed like it’d be a bear, though doable. I believe it ties into the machinery to run arbitrary tools at configure time (though I could be misremembering) and it’d probably be good to expose that as an operation that can run multiple things at once as well.
People put a whole lot of garbage (like figuring out compiler flags for warnings/errors, where clang-format is, docs building, test building, etc) that has nothing to do with describing their project's build and usage requirements, so you can thank project maintainers for wasting your time. If you have tight control over your toolchain, you can preload cache variables with -C/a toolchain file and save CMake some time figuring out what the toolchain is and whether it actually works.
In my experience most of the wait time is spent after all that stuff has already run though, during the part where CMake generates the new build scripts.
I have built Google projects before where the most time was in fact spent in configure and not generation. Generation also involves graph solving, so it's a little more understandable and those are usually harder problems.
View all comments
Show parent comment
5
u/_Noreturn Aug 05 '26
Why isn't cmake faster. I had configs take up to like 3 minutes although I feel like they shouldn't