Serbin
Serbin

Reputation: 823

Add fixup_bundle result to CPack

How to add additional libraries that were found using the fixup_bundle to the CPack?

This is my CMake install script:

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)

In the install folder I can found my EXE file, text stuff (LICENSE, COPYRIGHT, etc) and all required DLL libraries.

But when I execute package target (with NSIS builder), it copy only EXE file and text stuff, without additional DLL libraries.

Upvotes: 1

Views: 1001

Answers (1)

Serbin
Serbin

Reputation: 823

CPack will replace CMAKE_INSTALL_PREFIX variable with the correct one. But for this string ${CMAKE_INSTALL_PREFIX} should exist at the time when CPack will execute the code. It is enough to wrap every argument for fixup_bundle as a string.

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

Upvotes: 2

Related Questions