In our company, we use the first option with CMakeLists.txt in each subdirectory and create a tree from the root-CMakeLists.txt file using the add_subdirectory .
This is a modular approach in which each subcomponent (think that the project has different parts, such as boost, is divided into the system, stream, time_date, etc.) has its own build file. If the user wants him to just build a subcomponent or build an entire project.
We additionally use this as an easy way to include additional subcomponents in the project. The user can then set the Bool value to BUILD_SUBFOO , and add_subdirectory will be executed if this Bool is TRUE .
Well-known projects also use this approach. Here is a link to the root CMakeLists.txt from KDevelop (see lines 52-62).
source share