Search code examples
c++compilationcmakebuild-tools

cmake: compilation statistics per transation unit


I need to figure out which translation units need to be restructured to improve compile times, How do I get hold of the compilation time, using cmake, for my translation units ?


Solution

  • I would expect to replace the compiler (and/or linker) with 'time original-cmd'. Using plain 'make', I'd say:

    make CC="time gcc"
    

    The 'time' program would run the command and report on the time it took. The equivalent mechanism would work with 'cmake'. If you need to capture the command as well as the time, then you can write your own command analogous to time (a shell script would do) that records the data you want in the way you want.