cpack and third-party libs on mac os

Hi,
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
Angelo

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 
    POST_BUILD COMMAND 
    ${CMAKE_INSTALL_NAME_TOOL} -add_rpath "@executable_path/../../Frameworks/"
    $<TARGET_FILE:executable>)

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

For your own code, just do something like:

list(APPEND CMAKE_INSTALL_RPATH
  "@executable_path/../../Frameworks")
add_executable(…)
# 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.

Hi,
thanks for your help.

I’m noticing that during the “make package” phase, the script creates a folder
./_CPack_Packages/Darwin/productbuild/MyLib-1.0.0-Darwin/development/Applications/lib/
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.