Please take the discussion of CPM and EXCLUDE_FROM_ALL to a separate thread. FetchContent does not add EXCLUDE_FROM_ALL anywhere. Let’s keep this discussion here focused on the original poster’s topic, which has more to do with the EXCLUDE_FROM_ALL target property and the same keyword with the install()
command.
Regarding the overarching theme of excluding things from the ALL target and then installing them, the thing to remember is that if a target is excluded from ALL, then you the user are responsible for ensuring it is built if you then do something that wants to install that target. The documentation for the install()
command calls this undefined behavior, but that’s perhaps a bit strong. In reality, my preceding sentence is the real constraint, as far as I’m aware (but I haven’t checked how export sets affect the picture).