[CMake] exporting targets from build tree

Matthew Woehlke mwoehlke.floss at gmail.com
Wed Nov 16 12:50:14 EST 2016


On 2016-07-27 18:49, Michael Legleux wrote:
> I have 2 projects (one built with cmake, one in the process of being
> converted to using it)
> 
> Project A (built with cmake) builds lib_a that Project B requires.
> I'm thinking I'm doing something wrong around here:
> project(lib_a)
> ....
> add_library(lib_a STATIC ${SRC})
>  target_link_libraries(${PROJECT_NAME}
>    PRIVATE lib_b
>    )
> export(TARGETS lib_a FILE lib_a.cmake)
> 
> cmake complains that lib_b is not in the target export set. I do not WANT
> it exported and it is not required by project b.
> I simply want lib_a to be found/used by Project B via find_package(Project
> A)
> 
> I do not want to have to install/ or create a package for this behavior,
> just allow another project to reference the libs in the build tree and
> headers in the source tree.
> 
> I can't seem to find the correct way to express this with cmake despite
> looking at many solutions of near similar functionality.

Did you ever solve this? Offhand, I would guess that lib_a is a static
library. If this is the case, using lib_a requires also linking to
lib_b, because the symbols in lib_a require lib_b, and lib_a is not
actually linked yet.

-- 
Matthew



More information about the CMake mailing list