I'm trying to write a cmake script for installing a project I'm working on. Part of this is the necessary install(EXPORT LIB_EXPORTS ...)
where LIB_EXPORTS
is what I've been using for the EXPORT property in my various install(TARGETS ...)
.
I have a superbuild structure that uses add_subdirectory
to build some projects (SDL2, CivetWeb) that my project depends on.
My problem is that when I use target_link_libraries
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.
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.
The only way I know to add targets to an export set is by using install(TARGETS ... EXPORT LIB_EXPORTS)
but we can't install a target that this subdirectory hasn't created. I could install(FILES ... EXPORT LIB_EXPORTS)
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.
My questions:
- How should I include these external targets in the export set?
- If I shouldn't, what is the correct way to install the export set?
- 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?