<div dir="ltr"><div>My project consists of a lot of "module" style targets (static libraries, more or less), but only a few top-level targets that a user would actually want to build. The "all" target is empty, that is, every target has "EXCLUDE_FROM_ALL" set. The user will, at compile time, decide to build whichever target they need. A single target may depend on a couple of others, so the end result of a single target being built might be eg. an exe file plus a dll plus a couple of other things.<br></div><div><br></div><div>But I also want to provide installation capabilities, so users don't have to hunt down exes and libs scattered throughout CMake's build tree. I might want to create installers using CPack at some point too.</div><div><br></div><div>How do I do this if all of my targets are EXCLUDE_FROM_ALL? According to the documentation, even if I use the OPTIONAL flag in install(), the behaviour is undefined. Better not do that.</div><div><br></div><div>The only other option I see is to create custom commands (POST_BUILD style) for every target that copies it to some designated output directory. But then I can't take advantage of CMake's other installation capabilities, and I think that would be invisible to CPack.</div><div><br></div><div>Is there some other way?</div><div><br></div><div>I'm using CMake 3.12 on Windows 10/Ubuntu 18.04, if that's relevant.</div><div><br></div><div>Cheers,</div><div>Jason</div></div>