[CMake] How to place .dll and .lib in different places?

Alexander Neundorf a.neundorf-work at gmx.net
Mon Aug 27 08:52:51 EDT 2007


On Monday 27 August 2007 06:08, Luigi Calori wrote:
> I have the problem of placing, at build time .lib in one folder (lib)
> and .dll in another (bin)
> One solution is to add POST_BUILD copy commands, but i would prefer not.
> I have also been suggested to use
> SET_TARGET_PROPERTIES ...  PROPERTIES PREFIX
> being lib and bin sibling, this hack seem to work:
>
> SET(LIBRARY_OUTPUT_PATH <lib>)
> SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../../bin/")
>
>
> Is it "supported" or works by chances?
>
> I ask, because, I have also tried
> SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../../bin/lib")
>
> to being able to have
> <lib_name>.lib in lib/Release
> <lib_name>d.lib in lib/Debug
>
> and
>
> lib<lib_name>.dll and lib<lib_name>d.dll both in bin
>
> Unfortunately this is working in debug but not in release mode.

Do you really need this in the build tree or only in the install tree ?
Then you should use something like this:

install(TARGETS ${LIB_NAME} RUNTIME DESTINATION bin
                            ARCHIVE DESTINATION lib
                            LIBRARY DESTINATION lib)

Alex


More information about the CMake mailing list