elguerrero
elguerrero

Reputation: 79

How to calculate the build time of C Project using CMake

I am working in a C-Project and for building the software I am using CMake. Unfortunately the building of the software needs a lot of time. For analysing the build time, I want to:

into a text file.

How can I do it using CMake?

Upvotes: 4

Views: 2890

Answers (1)

I am working in a C-Project and for building the software I am using CMake.

Not really; CMake doesn't build anything, it's not a build tool. CMake is used to generate the buildsystem (such as makefiles or Visual Studio solutions) and then the normal build tools are used for building. Even invoking cmake --build is just a wrapper which launches the proper build tool.

This means build timing is outside CMake control. You will have to inspect your build toolchain (gcc, cl, etc.) for its timing features. If these require command-line options for the compiler etc., you can of course then set these up in your CMakeLists using normal CMake mechanisms (target_compile_options() etc.).

As for timing the whole build, you can use CMake's built-in timing feature cmake -E time command args..., but that is again nothing build-specific; it's just a cross-platform way of timing the run of an arbitrary command.

Upvotes: 5

Related Questions