targetOne : header/headerAB.h source/sourceA.cpp source/sourceB.cpp source/main.cpp
g++ -Wall header/headerAB.h source/sourceA.cpp source/sourceB.cpp source/main.cpp
为什么我应该在多个目标中打破它而不是将它保持为一个?
在什么情况下我们需要有单独的目标而不是 Makefile 中的目标?
最佳答案
引用 http://mrbook.org/tutorials/make/
Using dependencies. Sometimes is useful to use different targets. This is because if you modify a single file in your project, you don't have to recompile everything, only what you modified.
因此在部分源更新后您将获得更快的重新编译。对于大型项目来说,这是“必须实现的”,其中任何更改都非常小(与整个 > 1M LOC 项目相比)。
此外,多个目标允许您为项目的不同部分设置不同的规则。
关于c++ - 在哪些情况下我应该在 Makefile 中保留多个目标而不是一个目标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11293301/