[CMake] install(TARGETS) does not work with configuration-specific destinations

Alessio masariello+cmake.org at gmail.com
Mon Jun 8 13:40:29 EDT 2015


I forgot to mention that, by contrast, elsewhere I have the following
working code. So install(FILES) seems to work fine with multiple calls for
different configurations.

install(
    FILES "$<TARGET_FILE_DIR:corelib>/some_file.txt"
    COMPONENT platform
    DESTINATION "${${PROJECT_NAME}_INSTALL_RUNTIME_RELEASE}"
    CONFIGURATIONS Release RelWithDebInfo MinSizeRel)
install(
    FILES "$<TARGET_FILE_DIR:corelib>/some_file.txt"
    COMPONENT platform
    DESTINATION "${${PROJECT_NAME}_INSTALL_RUNTIME_DEBUG}"
    CONFIGURATIONS Debug PDebug)

On 8 June 2015 at 18:32, Alessio <masariello+cmake.org at gmail.com> wrote:

> Hi
>
> The below CMake code is causing my targets to get installed twice in the
> same tarball when I invoke cpack with the following command line
>
>     "${CPACK_COMMAND}" -G ${cpack_gen} --config
> "${CMAKE_CURRENT_BINARY_DIR}/${package_cfg_file}" -C "$<CONFIGURATION>"
>
> The generated cmake_install.cmake in fact contains two fiel(INSTALL)
> sections for every target like the one at the bottom.
>
> Using \${CMAKE_INSTALL_CONFIG_NAME} as suggested in reference (1) does not
> quite work for me. I would like the installed directory to have a name of
> my choosing, rather than relying on the name of the configuration.
>
> Can this be done at all? Is there a single-call install(TARGETS) signature
> that gives me what I want?
>
> Thank you very much for any light you can shed on this.
> -alessio
>
>
> THE CMAKE INSTALL CODE WITH THE PROBLEM
> ---------------------------------------
>     set(${PROJECT_NAME}_INSTALL_RUNTIME_RELEASE        "release")
>     set(${PROJECT_NAME}_INSTALL_RUNTIME_DEBUG          "debug")
>
>     install(TARGETS ${target}
>         COMPONENT ${component}
>         RUNTIME DESTINATION "${${PROJECT_NAME}_INSTALL_RUNTIME_RELEASE}"
>         LIBRARY DESTINATION "${${PROJECT_NAME}_INSTALL_RUNTIME_RELEASE}"
>         CONFIGURATIONS Release MinSizeRel RelWithDebInfo)
>     install(TARGETS ${target}
>         COMPONENT ${component}
>         RUNTIME DESTINATION "${${PROJECT_NAME}_INSTALL_RUNTIME_DEBUG}"
>         LIBRARY DESTINATION "${${PROJECT_NAME}_INSTALL_RUNTIME_DEBUG}"
>         CONFIGURATIONS Debug PDebug)
>
>
>
> SAMPLE cmake_install.cmake SECTION
> ----------------------------------
> if(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL
> "platform")
>   if("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Dd][Ee][Bb][Uu][Gg])$")
>     file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/release" TYPE
> SHARED_LIBRARY FILES "E:/Views/build/testapp/Debug/testapp-d.dll")
>   elseif("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES
> "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$")
>     file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/release" TYPE
> SHARED_LIBRARY FILES "E:/Views/build/testapp/Release/testapp.dll")
>   elseif("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES
> "^([Mm][Ii][Nn][Ss][Ii][Zz][Ee][Rr][Ee][Ll])$")
>     file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/release" TYPE
> SHARED_LIBRARY FILES "E:/Views/build/testapp/MinSizeRel/testapp-ms.dll")
>   elseif("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES
> "^([Rr][Ee][Ll][Ww][Ii][Tt][Hh][Dd][Ee][Bb][Ii][Nn][Ff][Oo])$")
>     file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/release" TYPE
> SHARED_LIBRARY FILES "E:/Views/build/testapp/RelWithDebInfo/testapp-rd.dll")
>   elseif("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES
> "^([Pp][Dd][Ee][Bb][Uu][Gg])$")
>     file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/release" TYPE
> SHARED_LIBRARY FILES "E:/Views/build/testapp/PDebug/testapp-pd.dll")
>   endif()
> endif()
>
>
> REFERENCES
> ----------
> (1) http://www.cmake.org/pipermail/cmake/2010-May/036979.html
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150608/6769065f/attachment.html>


More information about the CMake mailing list