[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 15:02:03 EDT 2010


2010/5/15 Tyler Roscoe <tyler at cryptio.net>

> [...]
> On Sat, May 15, 2010 at 05:53:45PM +0200, Baptiste Lepilleur wrote:
> > 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.
>

Thanks, the \${VAR} trick works great to delay variable expansion. Though,
CMAKE_BUILD_TYPE also expand to an empty variable. Using either BUILD_TYPE
or CMAKE_INSTALL_CONFIG_NAME variable works. I think I'm going to stick with
CMAKE_INSTALL_CONFIG_NAME since the script go through great length to make
sure it is initialized. Though none of those variables are documented.

So the final installation command that install the library in a matching
sub-directory matching the configuration used in the IDE is:

install(TARGETS unrar_lib
    RUNTIME DESTINATION bin/\${CMAKE_INSTALL_CONFIG_NAME}
    ARCHIVE DESTINATION lib/\${CMAKE_INSTALL_CONFIG_NAME}
    LIBRARY DESTINATION lib/\${CMAKE_INSTALL_CONFIG_NAME}
)

Baptiste.


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


More information about the CMake mailing list