Wrong percentage status when building one of many targets

Hello. There is this annoying problem, that when a package comes with a ton of targets (like llvm), invoking make on just a few targets makes the progress not show the actual percentage of built code, but looks more or less like that:

[ 66%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/DFAEmitter.cpp.o
[ 66%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/DFAPacketizerEmitter.cpp.o
[ 66%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/DirectiveEmitter.cpp.o
[ 66%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/DisassemblerEmitter.cpp.o
[ 66%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/ExegesisEmitter.cpp.o
[ 66%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/FastISelEmitter.cpp.o
[ 66%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/FixedLenDecoderEmitter.cpp.o
[ 66%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/GICombinerEmitter.cpp.o
[ 66%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/GlobalISelEmitter.cpp.o
[ 66%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/InfoByHwMode.cpp.o
[ 66%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/InstrInfoEmitter.cpp.o
[ 66%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/InstrDocsEmitter.cpp.o
[ 66%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/IntrinsicEmitter.cpp.o
[ 66%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/OptEmitter.cpp.o
[ 66%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/OptParserEmitter.cpp.o
[100%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/OptRSTEmitter.cpp.o
[100%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/PredicateExpander.cpp.o
[100%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/PseudoLoweringEmitter.cpp.o
[100%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/RISCVCompressInstEmitter.cpp.o
[100%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/RegisterBankEmitter.cpp.o
[100%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/RegisterInfoEmitter.cpp.o
[100%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/SDNodeProperties.cpp.o
[100%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/SearchableTableEmitter.cpp.o
[100%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/SubtargetEmitter.cpp.o

Why is the progress 66% literally forever and then it jumps to 100% right away (which also lasts long time)?

I think the progress is generated from the Makefiles and has the target granularity. If you want a better progress report try the Ninja generator, if you can, which has a better granularity.

What generator and version of cmake are you using?

The Makefiles progress report is really a best-effort thing. There are known issues with it. I’d either use it with the knowledge that it is not exactly accurate in terms of time (ever) or command count when using it in parallel. If you really want something better for at least command count progress, the Ninja generator is the way to go.

I want to ask you how can make Cmake display percentage progress report?
Look forward you reply!

CMake just drops files into a directory and counts them versus the expected number. It’s pretty primitive, but works as long as things go as expected (filesystems are weird, so things go sideways sometimes).