[CMake] Shared Libraries & dependencies

Andreas Pakulat apaku at gmx.de
Thu Dec 11 16:05:02 EST 2008


On 11.12.08 14:50:45, Robert Dailey wrote:
> On Thu, Dec 11, 2008 at 2:44 PM, Robert Dailey <rcdailey at gmail.com> wrote:
> 
> > On Thu, Dec 11, 2008 at 12:19 PM, Andreas Pakulat <apaku at gmx.de> wrote:
> >
> >> On 11.12.08 10:55:42, Robert Dailey wrote:
> >> > If I have a project in CMake that builds a shared library, what will
> >> happen
> >> > if I set this shared library project as a parameter in
> >> > target_link_libraries() for an executable project? What will happen to
> >> the
> >> > DLL file? Will CMake copy it to the executable output directory
> >> > automatically, or must I do this manually through CMake -E?
> >>
> >> Inside the builddir? No it won't. If you however use the install() method
> >> together with the RUNTIME, ARCHIVE and LIBRARY options it will install the
> >> .dll into the RUNTIME directory and the import library into the ARCHIVE
> >> directory. So just make sure to provide all three for any install() call
> >> and .exe and .dll will end up in the same directory.
> >
> >
> > I'm finding that INSTALL() will not work unless a target is already
> > defined. This logically makes sense, of course, however this makes the order
> > in which I define my targets sensitive. Is it possible to reference a target
> > before it has been defined, or must I organize my projects accordingly?
> >
> 
> To elaborate, I'm specifically getting this error message:
> 
> CMake Error at vfx/CMakeLists.txt:74 (install):
>   install TARGETS given target "messenger" which does not exist in this
>   directory.
> 
> And this is what my INSTALL() command looks like:
> 
> install( TARGETS messenger ARCHIVE DESTINATION "${target_bin_dir}" )
> 
> 
> I have no idea what the error message above means. At first I thought it was
> due to the ordering in which I defined my projects, but I'm not sure that's
> true. The 'messenger' project is defined in another sibling directory,
> perhaps that is the issue?

Well, the error says exactly that, so there's not really a reason to not
believe thats the case, is there ;) I wasn't aware of that, but apparently
you can only install targets in the same CMakeLists.txt as they're defined.
This kinda makes sense too, because it makes sure that all stuff thats done
to a target is localized in one CMakeLists.txt.

Andreas

-- 
You have the power to influence all with whom you come in contact.


More information about the CMake mailing list