cpack and third-party libs on mac os

I’m trying to create an installer on Mac Os of a little project that uses openssl as dependency.
I need to create an installer that includes libssl and libcrypto in my destination foder.
How can I change the rpath on the third-party libraries?
Thank you very much for your help

You’ll need to run install_name_tool to edit the libraries (post-installation). Though @kyle.edwards is working on some code which should help with that, it’s not in a CMake release yet.

Hi, thanks for your very fast answer.
I found this command:

add_custom_command(TARGET executable 
    ${CMAKE_INSTALL_NAME_TOOL} -add_rpath "@executable_path/../../Frameworks/"

My problem is: how can I run it recursively to non-system libraries?

For your own code, just do something like:

# Or edit the `INSTALL_RPATH` property on the executable afterwards.

There’s no mechanism to run install_name_tool recursively, but you could write a CMake script and use install(SCRIPT) to run it. file(GET_RUNTIME_DEPENDENCIES) is useful for this.

thanks for your help.

I’m noticing that during the “make package” phase, the script creates a folder
where I can find all the libraries that I want to install.
how can I tell to cpack to execute a script before the package or after the installation phase?
Thank you

Those files get copied there based on project-specific rules. I imagine it is either using file(GRD) or the BundleUtilities module already. You’ll have to hook into those parts of the code to do any post-processing.