In general is it a good idea to use install components defined inside a project consumed via FetchContent?, should that project even define those components when it isn’t the top level project?
(Context: All libraries are internally managed)
This seems tempting at first, as you can reuse install logic from your dependencies instead of having to specify them again and again. Allowing you to have applications where all dependencies are fully embedded.
However I suspect you would run into trouble if one of those dependencies switches to a find_package
approach, as those install components would no longer be available.
You could check in an if statement whether a target is imported or not, but it seems like less of a hassle to always use the imported branch of that if-statement as it would likely be more general anyway. Perhaps you could define a function to define the install component in both the project itself and the ProjectConfig.cmake, but this seems cursed in its own way.
This does not touch on the situation of dependencies of dependencies, where now the top most project most see what needs installing, regardless of whether install components are reused. Whilst what needs install will likely match the applications link targets (in the context of internally managed libraries).
As a note,
Certain aspects can be somewhat resolved using install(IMPORTED_RUNTIME_ARTIFACTS)
and others, but this does not work for non build, runtime requirements, such as a data file read by a library in order to function (i.e. the stuff which would be placed in the Resources folder in a macosx framework).