[CMake] How to install library in a sub-directory matching the active visual studio configuration?

Tyler Roscoe tyler at cryptio.net
Sat May 15 12:28:47 EDT 2010


On Sat, May 15, 2010 at 05:53:45PM +0200, Baptiste Lepilleur wrote:
> I initially tried using the variable ${CMAKE_BUILD_TYPE} but it seems to
> always expand to a blank string, and the doc imply that it does not work
> with Visual Studio solution as it has multiple configurations. So I switched

Correct.

> to ${CMAKE_CFG_INTDIR}:
> 
>     install(TARGETS unrar_lib
>         RUNTIME DESTINATION bin/${CMAKE_CFG_INTDIR}
>         ARCHIVE DESTINATION lib/${CMAKE_CFG_INTDIR}
>         LIBRARY DESTINATION lib/${CMAKE_CFG_INTDIR}
>     )
> 
> But it installs the library in a directory named "$(OutDir)"...

$(OutDir) is a VS "macro" so only VS knows how to interpret it. Since
installation is done by CMake, you can't use CMAKE_CFG_INTDIR there.

> Alternatively, is it possible to delay variable expansion until the
> cmake_install.cmake script is invoked?

I think what I use to solve this problem (can't check right now) is
\${CMAKE_BUILD_TYPE}. This sticks "${CMAKE_BUILD_TYPE}" into
cmake_install.cmake, which is then correctly interpreted at install
time.

tyler


More information about the CMake mailing list