Install EXPORT requires target from subproject : <p>I'm trying to write a cmake script for installing a project I'm working on. Part of this is the necessary <code>install(EXPORT LIB_EXPORTS ...)</code> where <code>LIB_EXPORTS</code> is what I've been using for the EXPORT property in my various <code>install(TARGETS ...)</code>.</p>

<p>I have a superbuild structure that uses <code>add_subdirectory</code> to build some projects (SDL2, CivetWeb) that my project depends on.</p>

<p>My problem is that when I use <code>target_link_libraries</code> to add a link from a subproject  (SDL2-static from SDL2, c-library from CivetWeb) cmake complains that these dependencies aren't in the export set.</p>

<pre><code>CMake Error: install(EXPORT "LIB_EXPORTS" ...) includes target "sc2api" which requires target "c-library" that is not in the export set.
CMake Error: install(EXPORT "LIB_EXPORTS" ...) includes target "sc2renderer" which requires target "SDL2-static" that is not in the export set.
</code></pre>

<p>The only way I know to add targets to an export set is by using <code>install(TARGETS ... EXPORT LIB_EXPORTS)</code> but we can't install a target that this subdirectory hasn't created. I could <code>install(FILES ... EXPORT LIB_EXPORTS)</code> if I could find for sure where that library file's been generated but I have a feeling that this would install it twice (once by the CMakeLists.txt in the project subdirectory, once here). Frankly, I'm not sure why including these are necessary, since the libraries should be statically linked into the targets in my project.</p>

<p>My questions:</p>

<ol>
<li>How should I include these external targets in the export set?</li>
<li>If I shouldn't, what is the correct way to install the export set?</li>
<li>Bonus question: These subprojects automatically add their install targets to my project's install target. Is this necessary? If it isn't, how do I disable this?</li>
</ol>
