将fixup_bundle结果添加到CPack

时间:2018-09-05 10:05:54

标签: cmake nsis cpack

如何将使用fixup_bundle找到的其他库添加到CPack?

这是我的CMake安装脚本:

install(
    TARGETS ${PROJECT_NAME}
    RUNTIME DESTINATION .)

install(
    FILES
        ${PROJECT_SOURCE_DIR}/LICENSE
        ${PROJECT_SOURCE_DIR}/COPYRIGHT
        ${PROJECT_SOURCE_DIR}/CHANGELOG
        ${PROJECT_SOURCE_DIR}/DESCRIPTION
    DESTINATION .)

install(
    CODE
    "
        include(InstallRequiredSystemLibraries)
        include(BundleUtilities)
        fixup_bundle(${CMAKE_INSTALL_PREFIX}/${SERVICE_INSTALL_PREFIX}/test.exe  \"\" \"\")
    "
    DESTINATION .
    COMPONENT Runtime)

install文件夹中,我可以找到我的EXE文件,文本内容(许可证,版权等)和所有必需的DLL库。

但是,当我执行package目标(使用NSIS构建器)时,它仅复制EXE文件和文本内容,而没有其他DLL库。

1 个答案:

答案 0 :(得分:0)

CPack将CMAKE_INSTALL_PREFIX变量替换为正确的变量。但是对于此字符串${CMAKE_INSTALL_PREFIX}应该在CPack执行代码时存在。将fixup_bundle的每个参数包装为字符串就足够了。

install(
    CODE
    "
        include(InstallRequiredSystemLibraries)
        include(BundleUtilities)
        fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${SERVICE_INSTALL_PREFIX}/test.exe\"  \"\" \"\")
    "
    DESTINATION .
    COMPONENT Runtime)