Re:Advice to my younger self: become allergic to the churn
by deng on Thursday August 08, 2019 @10:29AM
(#20644904)
> and forget to add new header files to the list of headers
This is why gcc/clang have the option to generate Makefiles for the header dependencies for you. Maintaining these yourself is a hopeless effort.
Re:Advice to my younger self: become allergic to the churn
by kd5bjo on Thursday August 08, 2019 @10:00AM
(#20644630)
That makes a lot of sense. Setting up automatic dependency detection is what finally made Make click for me, and it’s not the most straightforward process to get right. How does CMake detect the files that a given product depends on; does it have language-specific dependency detection or something else?
Re:Advice to my younger self: become allergic to the churn
by umvi on Thursday August 08, 2019 @10:29AM
(#20644911)
> How does CMake detect the files that a given product depends on; does it have language-specific dependency detection or something else?
Well actually, CMake is a build system generator - and the default build system it generates is Unix Makefiles. So I assume CMake generates Makefiles with the appropriate automatic dependency detection baked in, I'm not sure.
The important part was that it eliminated human error on our team and we haven't had dependency graph problems since.
Re:Advice to my younger self: become allergic to the churn
by deng on Thursday August 08, 2019 @10:50AM
(#20645091)
CMake has its own dependency scanner for C/C++. Look for a file 'depend.make' and you'll see the header dependencies that CMake has detected, minus the headers that CMake thinks are system headers.
The main problem that kept burning me was that I'd have a "dirty" build when I thought I had a clean one or an incorrect one when I thought I had a correct one. It was super hard to get the dependency graph correct because developers were creating files left and right but would only update the Makefile just enough to get it building (and forget to add new header files to the list of headers, etc) so I had little confidence in incremental builds and was always building from the ground up.
CMake's generated build systems always have correct dependency graphs (i.e. it will only rebuild the bare minimum when you touch a given file) and I've always had complete confidence that my build is clean (since I just created a fresh directory) and that my incremental builds are correct.