Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
CMake
CMake
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,198
    • Issues 3,198
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 16
    • Merge Requests 16
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • External Wiki
    • External Wiki
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • CMake
  • CMakeCMake
  • Issues
  • #21691

Closed
Open
Opened Jan 11, 2021 by Mario Emmenlauer@emmenlau👾Contributor

file(GET_RUNTIME_DEPENDENCIES) does not resolve libraries in @rpath on macOS

I'm trying to use file(GET_RUNTIME_DEPENDENCIES) to collect the list of all dependencies of an executable. This generally works well on Linux and Windows, but I have some problems on macOS. Some of the libraries are referenced using @rpath. For some reason, they can not be resolved. I read in the docs of https://cmake.org/cmake/help/latest/command/file.html#get-runtime-dependencies:

On Apple platforms, library resolution works as follows:
[...]
4. Otherwise, if the dependency starts with @rpath/, and replacing @rpath/ with one of the RPATH entries of the depending file yields an existing file, the dependency is resolved to that file. Note that RPATH entries that start with @executable_path/ or @loader_path/ also have these items replaced with the appropriate path.

I'm not sure why this does not work for me. Reading the source code of cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool.cxx also did not make it more obvious. Here is what I could find:

One unresolved library is @rpath/libbz2.1.0.8.dylib. The only such reference comes from libfreetype.6.17.4.dylib. The dependencies shown from otool -L are:

/System/Volumes/Data/data/Debug/lib/libfreetype.6.17.4.dylib:
        @rpath/libfreetype.6.dylib (compatibility version 6.0.0, current version 6.17.4)
        @rpath/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
        @rpath/libbz2.1.0.8.dylib (compatibility version 1.0.8, current version 1.0.8)
        @rpath/libpng16.16.dylib (compatibility version 16.0.0, current version 16.37.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)

I can see that libbz2.1.0.8.dylib exists in the same directory /System/Volumes/Data/data/Debug/lib/ as libfreetype.6.17.4.dylib. Is there something wrong on my side so that file(GET_RUNTIME_DEPENDENCIES) does not resolve it?

To upload designs, you'll need to enable LFS and have admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: cmake/cmake#21691