Fix EXPORT issue for shared library with dependencies

I am trying to build two libraries (say A and B) from one project. I use add_subdirectorycmake in the root cmake file. B depends on A.

When i try to add

INSTALL (TARGETS B EXPORT B
    PUBLIC_HEADER DESTINATION "include/B"
    LIBRARY DESTINATION "lib"
    ARCHIVE DESTINATION "lib")

INSTALL (EXPORT B DESTINATION "./")

CMake warns me of an error according to INSTALL (EXPORT...He prints:

CMake Error: INSTALL (EXPORT "B" ...) includes target "B", which requires target "A", which is not in the export set.

+3
source share
1 answer

, , . - . CMakeLists.txt,

install( TARGETS A B ... )

, , , CMakeLists.txt ( add_subdirectory). , "MyInstall".

...

install( TARGETS A EXPORT MyInstall ... )

B, "MyInstall" CMakeLists.txt :

install( EXPORT MyInstall ... )
+4

All Articles