[CMake] Time each target
Michael Ellery
mellery451 at gmail.com
Thu Aug 25 13:57:31 EDT 2016
> On Aug 25, 2016, at 9:58 AM, Moreland, Kenneth <kmorel at sandia.gov> wrote:
>
> Does anyone know of a simple way to get CMake to time how long it takes to compile each target? As it stands now, when compiling a CMake-managed project a status is printed before each target is built. What I am looking for is a way to get CMake to print a second status message after the target finishes building with a note on what the wall time of the build was.
>
> -Ken
>
I don’t know of any built-in support for this. I think Visual Studio projects might have a setting to generate timing info, but I suspect you are not using Visual Studio/MSbuild.
Here is an example of some build timing:
https://github.com/PointCloudLibrary/pcl/blob/master/CMakeLists.txt#L98
https://github.com/PointCloudLibrary/pcl/blob/master/cmake/custom_output.sh
..but I think it is providing timing for each compile command, not at the target level. In any event, this technique of using RULE_LAUNCH_COMPILE seems interesting - perhaps you can adopt it somehow.
The only other thing I can think of is to add custom targets around your real targets where POST depends on REAL which DEPENDS on PRE and the PRE and POST targets just print some timing info. Kludgy to be sure. HTH.
-Mike
More information about the CMake
mailing list