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

Baptiste Lepilleur baptiste.lepilleur at gmail.com
Sat May 15 11:53:45 EDT 2010


Hi all, I'm trying to make it so that Release configuration library is
installed in lib/Release, and debug configuration library is installed in
lib/Debug.

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
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)"...

Is there a way to use the configuration name passed to cmake in the install
step (e.g. I've found out that in Visual Studio the install step invoke
"cmake.exe -DBUILD_TYPE=$(OutDir) -P cmake_install.cmake")?

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

What I want to do it simple compiles and install all configurations using a
single batch build...

Baptiste.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100515/420953df/attachment.htm>


More information about the CMake mailing list