I am trying to write a cmake script to install the project I'm working on. Part of this is necessary install(EXPORT LIB_EXPORTS ...), where LIB_EXPORTSis what I used for the EXPORT property in different install(TARGETS ...).
I have a superbuild structure that uses add_subdirectoryto create some of the projects (SDL2, CivetWeb) that my project depends on.
My problem is that when I use target_link_librariesto add links from a subproject (SDL2-static from SDL2, c-libraries from CivetWeb), cmake complains that these dependencies are not 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 thing I know for adding goals to the export set is use install(TARGETS ... EXPORT LIB_EXPORTS), but we cannot set a goal that this subdirectory did not create. I could install(FILES ... EXPORT LIB_EXPORTS), if I could find out exactly where this library file was created, but I have a feeling that it will install it twice (once CMakeLists.txt in the project subdirectory, once here). Honestly, I'm not sure why this is necessary as well, since libraries should be statically linked to targets in my project.
My questions:
- How to include these external objects in an export set?
- If I shouldn't, what's the right way to install an export set?
- Bonus question: These subprojects automatically add installation goals to my project installation target. It's necessary? If this is not the case, how to disable it?