[CMake] How to install an imported library?

Andreas Pakulat apaku at gmx.de
Tue Jan 6 06:29:12 EST 2009


On 06.01.09 10:55:19, Clement SOMMELET wrote:
> Hi, I try the following to install an imported dll:
> 
> ADD_LIBRARY(Foo SHARED IMPORTED)
> SET_TARGET_PROPERTIES(Foo PROPERTIES IMPORTED_LOCATION "C:/FooLocation/Foo.dll")
> INSTALL(TARGETS Foo RUNTIME DESTINATION bin)
> 
> and I get the following error:
> 
> install TARGETS given target "Foo" which does not exist in this directory
> 
> When looking into the cmake source code, it seems that INSTALL(TARGETS
> ...) does not look for imported targets (it uses
> cmMakefile::FindTarget and not cmMakefile::FindTargetToUse).
> 
> Is it the expected behaviour?

IMHO yes, the exporting and importing is geared towards using an already
installed target. So there's no need to install it again. 

> If yes what is the prefered way to
> include an imported DLL in an install? A typical use case is when
> importing a library built using cmake and the INSTALL(EXPORT ...)
> command (generated cmakes contain ADD_LIBRARY(xxx SHARED IMPORTED)
> commands)

If somebody builds your project he'll need to install that external target
before. In that case installing it again is useless and just wastes
diskspace.

So this would only be useful when using cpack to generate an installer for
your project (or zip package) and as such it should IMHO be handled somehow
by cpack. Maybe kitware didn't think of that yet, so you might want to file
a wishlist report in their bugtracker.

Andreas

-- 
Don't relax!  It's only your tension that's holding you together.


More information about the CMake mailing list