Installing a dependent program created by custom command with EXCLUDE_FROM_ALL active

This scenario has a target (static lib in the example) that acquires a dependent file via a custom command.
The lib is not required by the “all” target, so that part of the source tree is brought in with EXCLUDE_FROM_ALL (which could be many layers deep, along with other targets).
The lib target presents an install step for the output created via the custom command.
The problem is that even though the lib target is referenced (by the example exe) and so is built, the EXCLUDE_FROM_ALL results in the install step being skipped.
The link between the install and the target’s sources is not resolved.

Is there an alternative/better approach?

Example:
CMakeLists.txt (982 Bytes)