The Makefile lists only .cpp files as prerequisites of the executable, so a change to a header under src/ is not noticed by make. Facts read directly from the Makefile:
SOURCES = $(wildcard src/*.cpp)
...
$(TARGET): $(SOURCES)
No .h or .hpp file is part of the prerequisite list, and no dependency information is generated by the compiler invocation (g++ $(CXXFLAGS) $(SOURCES) -o $(TARGET)).
Reproduction, performed on master at f6d4369 with a scratch header that was removed afterwards:
src/greeting.h was created containing #define GREETING "Hello World!", and src/testing.cpp was changed to #include "greeting.h" and to pass GREETING to log.
make run compiled and printed [LOG] Hello World! as expected.
- Only the header was then edited, to
#define GREETING "Hello from the header!".
make run printed no Compiling line and ran the previous executable:
---
Running testing
./testing
[LOG] Hello World!
[DEBUG] debugFlag is true, so this message is shown.
Finished running testing
The stale output is the consequence: a project generated from this template that adds a header (the normal way a C++ project grows past one file) will run an out-of-date executable after a header-only edit, and make run will report nothing wrong. README.md reinforces the gap by describing only .cpp handling in the Repository layout table ("Any .cpp file added here is compiled.").
Suggested resolution, in keeping with the template's single-target build: add a HEADERS = $(wildcard src/*.h src/*.hpp) variable and list it alongside $(SOURCES) as a prerequisite of $(TARGET), then note in README.md that header changes trigger a rebuild. Full per-object dependency tracking (-MMD -MP) is deliberately not suggested, since it would require moving to per-object compilation and is heavier than a starter template needs.
This issue was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson
The
Makefilelists only.cppfiles as prerequisites of the executable, so a change to a header undersrc/is not noticed bymake. Facts read directly from theMakefile:No
.hor.hppfile is part of the prerequisite list, and no dependency information is generated by the compiler invocation (g++ $(CXXFLAGS) $(SOURCES) -o $(TARGET)).Reproduction, performed on
masteratf6d4369with a scratch header that was removed afterwards:src/greeting.hwas created containing#define GREETING "Hello World!", andsrc/testing.cppwas changed to#include "greeting.h"and to passGREETINGtolog.make runcompiled and printed[LOG] Hello World!as expected.#define GREETING "Hello from the header!".make runprinted noCompilingline and ran the previous executable:The stale output is the consequence: a project generated from this template that adds a header (the normal way a C++ project grows past one file) will run an out-of-date executable after a header-only edit, and
make runwill report nothing wrong.README.mdreinforces the gap by describing only.cpphandling in theRepository layouttable ("Any.cppfile added here is compiled.").Suggested resolution, in keeping with the template's single-target build: add a
HEADERS = $(wildcard src/*.h src/*.hpp)variable and list it alongside$(SOURCES)as a prerequisite of$(TARGET), then note inREADME.mdthat header changes trigger a rebuild. Full per-object dependency tracking (-MMD -MP) is deliberately not suggested, since it would require moving to per-object compilation and is heavier than a starter template needs.This issue was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson