How to use fixup_bundle for non-OSX targets for library and executable

In my library I have a shared library target and an executable target. I’m trying to use BundleUtilities and fixup_bundle to create a tarball like this (I guess I’ll use cPack for packing) with all the dependencies bundled in on a platform that is not macOS:

├── bin
│   └── myprogram
├── lib64
│   ├── libdep1
│   ├── libdep2
│   ├── libdep3
│   ├── libdep4
│   └── libmylib
└── share

My ${CMAKE_BINARY_DIR} looks like this:

├── ...
└── src
    ├── apps
    │   └── myprogram
    └── libs
        └── libmylib

And my portion of CMakeListst.txt that sets up the bundling looks like this:

set(BUNDLE_APPS "${CMAKE_BINARY_DIR}/src/apps/myprog")
set(BUNDLE_LIBS "${CMAKE_BINARY_DIR}/src/libs/")
configure_file("${CMAKE_SOURCE_DIR}/cmake/" "${CMAKE_BINARY_DIR}/bundle.cmake" @ONLY)
install(SCRIPT "${CMAKE_BINARY_DIR}/bundle.cmake")

This is the


fixup_bundle("@BUNDLE_APPS@" "@BUNDLE_LIBS@" "@BUNDLE_DIRS@")

This gives me the following error:

-- Analyzing app='[redacted]/build/src/apps/myprogram'
-- bundle='[redacted]/build/src/apps'
-- executable='[redacted]/build/src/apps/hgve'
-- valid='1'
-- executable file 1: [redacted]/build/src/apps/hgve
-- verified='0'
-- info='external prerequisites found:

The errors are quite cryptic… :cold_sweat:

I have some questions:

  1. Can I use fixup_bundle on a library? Or do I need an executable?
  2. The APPS and LIBS variables need to be in the ${CMAKE_BINARY_DIR} or ${CMAKE_INSTALL_DIR}?
  3. fixup_bundle looks to put dependencies in the same directory as the APP executable. That means if I want to put the libs in the lib64 directory, I need to edit the RPATH of APP to point to the right path?