Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How build systems keep track of change in the source files?

When building my C++ projects I would use a bash file where there is all the instructions needed.
It didn’t present a problem because all the projects that I did were relatively small.

In my last project the build time would take around 4-6 mins so I switched to Cmake.
The first build was slow but the all the next ones were relatively fast.

My question is:Is compiling only the changed files the only optimization made by Cmake to improve build time?
Also: How does Cmake keep track of changes within files? How does it decide whether to recompile a file or not?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I thought that maybe it saves the time of the last build and so checks last modification time of a file and compares it with the saved time. However I want to know the exact answer of it.

>Solution :

Cmake is a shell that sits on top of the make utility. make compares file dates and times. If the object file is newer than the source file and headers that it was created from make does nothing; if the object file is older, then the source file or a header has been modified since the last time it was compiled, and the source file needs to be compiled again. No rocket science.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading