What are the implications of / possible reasons for calling project()
from subdirectories' CMakeLists
?
i.e.
├── CMakeLists.txt <-- top-level project() call
├── proj1
| ├── CMakeLists.txt <-- project()
├── proj2
| └── CMakeLists.txt <-- project()
└── proj3
└── CMakeLists.txt <-- project()
I have seen this in codebases before, usually after a refactor.
Is this ever useful? Couldn't you just define targets with add_library
/add_executable
instead?
Is this actually harmful, or innocuous?
The docs only really talk about the special case of the top-level project()
call, but don't get into reasons for calling it in subdirectories.
question from:
https://stackoverflow.com/questions/65945378/cmake-multiple-calls-to-project 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…