Top project/ master project : vocabulary
Just like Design patterns gives us vocabulary to identify the same thing,pattern. I would like to request a similar thing for cmake, and request that cmake itself provide an implementation.
Thanks to FetchContent “other” libraries can now be source consumed, which is great. This requires off course some discipline of the library writers, they no longer should assume they are in charge of everything, and the first thing they need to know if they are in charge or not is to determine if they are the top/master project, yes or no.
If have already seen 2 mechanisms to detect that:
compare CMAKE_CURRENT_SOURCE_DIR and CMAKE_SOURCE_DIR compare CMAKE_PROJECT_NAME and PROJECT_NAME
In order to avoid that everyone is writing his/her own version of this boilerplate, it would be nice that cmake provides a function that can be called and gives this as an outcome. That way all use the same implementation, and it has a fixed name (vocabulary).
See also the discussion on discourse (even a 3rd mechanism is presented there) : https://discourse.cmake.org/t/top-project-master-project-vocabulary/412