I'm dabbling with cmake, and it seems that it generates recursive makefiles. Which means that in a big project, empty build can take about 5 seconds, which is really unacceptable.
I haven't found way to generate non-recur开发者_Python百科sive makefiles with cmake. Is it possible?
It is not possible with CMake, as is.
It may be possible by modifying the source of CMake... but I'm not sure how small or large, simple or complex such a task would be.
Pretty sure it would take longer than 5 seconds, though. Even multiplied across all the empty builds you'll do in the next couple of years.
If 5 seconds is unacceptable for your empty build, what threshold is acceptable? 1 second? 0.25 second? Just curious -- there's been much work to minimize as much as possible the empty build time for large projects.
While the answer remains the same for Makefiles, recent versions (CMake 2.8.9 released August 09, 2012) include the Ninja generators enabled by default. On a relatively large C++ code base (Torque3D - roughly 40M of source files across roughly 241 directories1) it takes Ninja on average (from ten runs) 0.14 seconds to decide there's nothing left to do and it takes make on average (again, from ten runs) 2.55 seconds (times based on a project that's already been fully built with nothing left to do.)
So, CMake & Ninja might be a good option for you if you find Make to be too slow. You mention Tup in a reply. Ninja seems to have similar goals to Tup.
- Best guess based on
find Torque3D/Engine -iname ".c" -or -iname ".cpp" -or -iname "*.h" | xargs dirname | sort -u | wc -l
CMake uses recursive make because it has to. CMake is a general tool and has to generate depend information on the fly. To be compatible with make (not just gmake), you have to use recursive make to be able to do that. CMake also supports multiple levels of code generators. One could potentially write a tup generator for CMake. There is some working being done for CMake and ninja. However, with the plain make generator there is no way to do what CMake does without some level of recursive make.
"I don't believe CMake 'had to' use recursive" If you can create a makefile that is non-recursive and works with more than gmake, and can compute depend information on the fly, then it would prove it wrong. We did spend quite a bit of time trying to make it not be recursive. It is "less" recursive that it used to be.
Brad King has created a FAQ entry that describes the way make is used in CMake.
精彩评论