[CMake] Install command incorrectly installing archive libraries

Michael Wild themiwi at gmail.com
Fri Nov 18 00:22:17 EST 2011


On 11/17/2011 06:12 PM, Stephen Torri wrote:
> CMake Version: 2.8
> 
> Generator: Visual Studio 2008
> 
> Problem: Two install commands are used per library. First command
> should only install libraries to lib/debug when the build type is
> Debug. The second command should only install libraries to the
> lib/release directory. When the build type is Debug than three
> libraries .lib files are being installed to the lib\release directory.
> 
> For example I have the following entries for a library:
> 
> INSTALL ( TARGETS first
>     ARCHIVE DESTINATION lib/debug
>     LIBRARY DESTINATION lib/debug
>     RUNTIME DESTINATION lib/debug
>     CONFIGURATIONS Debug )
> 
> INSTALL ( TARGETS first
>     ARCHIVE DESTINATION lib/release
>     LIBRARY DESTINATION lib/release
>     RUNTIME DESTINATION lib/release
>     CONFIGURATIONS Release )
> 
> So when I run cpack -C Debug and use the installer I find first.lib in
> both lib/debug and lib/release. I am not sure why this is the case.
> Any ideas?
> 
> Stephen

I think you mis-read the install() documentation. Granted, it is a bit
confusing and matching up the brackets is a bit tedious, but the
CONFIGURATIONS option applies only to the preceeding DESTINATION option.
So you could write everything in one single command:

install(TARGETS first
  ARCHIVE DESTINATION lib/debug CONFIGURATIONS Debug
  LIBRARY DESTINATION lib/debug CONFIGURATIONS Debug
  RUNTIME DESTINATION lib/debug CONFIGURATIONS Debug
  ARCHIVE DESTINATION lib/release CONFIGURATIONS Release
  LIBRARY DESTINATION lib/release CONFIGURATIONS Release
  RUNTIME DESTINATION lib/release CONFIGURATIONS Release)

HTH

Michael


More information about the CMake mailing list