# How to get macOS/iOS framework root directory at install time?

**URL:** https://discourse.cmake.org/t/how-to-get-macos-ios-framework-root-directory-at-install-time/15640
**Category:** Code
**Tags:** os:macos
**Created:** [May 5, 2026, 9:53am UTC](https://discourse.cmake.org/t/how-to-get-macos-ios-framework-root-directory-at-install-time/15640 "2026-05-05T09:53:05Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![emaschino](https://discourse.cmake.org/user_avatar/discourse.cmake.org/emaschino/32/6126_2.png) [@emaschino](https://discourse.cmake.org/u/emaschino)
#### Post date: [May 5, 2026, 9:53am UTC](https://discourse.cmake.org/t/how-to-get-macos-ios-framework-root-directory-at-install-time/15640/1 "2026-05-05T09:53:06Z")

</div>

Hi,

Let’s have a cross-platform command-line test application TestApp. This app depends on OpenCV, built as a dynamic framework on Apple. To install the app and runtime dependencies, I have:

```auto
install(TARGETS TestApp
        RUNTIME_DEPENDENCY_SET TestAppDeps
        DESTINATION "$<TARGET_FILE_DIR:TestApp>"
)

install(IMPORTED_RUNTIME_ARTIFACTS
        RUNTIME_DEPENDENCY_SET TestAppDeps
        DESTINATION "$<TARGET_FILE_DIR:TestApp>"
)

install(RUNTIME_DEPENDENCY_SET TestAppDeps
        DESTINATION "$<TARGET_FILE_DIR:TestApp>"
        PRE_EXCLUDE_REGEXES
                [=[api-ms-]=]
                [=[ext-ms-]=]
        POST_EXCLUDE_REGEXES
                [=[.*(\\|/)system32(\\|/).*\.dll]=]
                [=[^/(lib|usr/lib|usr/local/lib)]=]
                "$<TARGET_FILE_DIR:TestApp>"
        DIRECTORIES
                "$<TARGET_FILE_DIR:opencv_core>"
)

```

When running cmake install, I’m getting the following error:

```auto
CMake Error at TestApp/cmake_install.cmake:140 (file):
  file Could not resolve runtime dependencies:

    @rpath/opencv2.framework/Versions/4.0.1/opencv2

```

Looking at TestApp/cmake\_install.cmake, I can see that the `opencv_core` target directory is obviously “too deep” into the `opencv2.framework` directory structure:

```auto
  elseif(CMAKE_INSTALL_CONFIG_NAME MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$")
    file(GET_RUNTIME_DEPENDENCIES 
      RESOLVED_DEPENDENCIES_VAR _CMAKE_DEPS
      EXECUTABLES
        "/Users/<user>/Documents/TestApp/build_arm64_osx/TestApp/Release/TestApp"
      DIRECTORIES
        "/Users/<user>/Documents/Dependencies/macOS/arm64/OpenCV_4.0.1/lib/3rdparty/opencv2.framework/Versions/4.0.1"
      PRE_EXCLUDE_REGEXES
        "api-ms-"
        "ext-ms-"
      POST_EXCLUDE_REGEXES
        ".*(\\\\|/)system32(\\\\|/).*\\.dll"
        "^/(lib|usr/lib|usr/local/lib)"
        "/Users/<user>/Documents/TestApp/build_arm64_osx/TestApp/Release"
      )

```

Is there a target or framework property, defining the root path of the framework, that I should use to give the `DIRECTORIES` argument the correct search path? In the above example, it should be two levels upper, _i.e._ omitting the `Versions/4.0.1` part of the path.

Thanks.

---

<div class="post-metadata">

### Author: ![emaschino](https://discourse.cmake.org/user_avatar/discourse.cmake.org/emaschino/32/6126_2.png) [@emaschino](https://discourse.cmake.org/u/emaschino)
#### Post date: [May 7, 2026, 3:39pm UTC](https://discourse.cmake.org/t/how-to-get-macos-ios-framework-root-directory-at-install-time/15640/2 "2026-05-07T15:39:13Z")

</div>

So the problem isn’t with the recorded framework path, it appears. Even hardcoding the correct path doesn’t fix this issue.

The problem seems to reside in the inability of GET\_RUNTIME\_DEPENDENCIES to retrieve the path of the opencv2 framework.
