[CMake] Super builds and export with Namespace
Miller Henry
MillerHenry at JohnDeere.com
Thu Aug 11 11:20:12 EDT 2016
I have a few different cmake based projects that depend on each other (as a tree, no circular dependencies). Mostly this works great, but a few people have expressed interested in a superbuild which builds everything together for various purposes. I can make this work with ExternalProject, but that isn't a useful solution for IDE users. I'm trying to use add_subdirectory and running into a problem with namespaces in my export files
Currently projectA has
EXPORT(projectA NameSpace ProjectA_)
Which works great, when projectB wants to link to a library in projectA it is just FIND_PACKAGE(ProjectA) then TARGET_LINK_LIBRARIES(lib ProjectA_LibraryName). Simple enough without superbuilds.
When I get to a superbuild though I don't know how to handle this. It is easy to do write some sort of FindProjectA.cmake or ProjectAConfig.cmake file to make the FIND_PACKAGE work in projectB. However I don't know how to get a ProjectA_LibraryName target that I can link to, the superbuild only knows about LibraryName without the namespace.
The only idea I can think of is in the superbuild have a bunch of ADD_LIBRARY (ProjectA_LibraryName ALIAS LibraryName) lines hard coded. This means I have to maintain that file though which I don't like. Does anyone have a better idea?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160811/3a66c1fa/attachment-0001.html>
More information about the CMake
mailing list