# Looking for clarity on using find\_package with a dylib and xcframework in same directory.

**URL:** https://discourse.cmake.org/t/looking-for-clarity-on-using-find-package-with-a-dylib-and-xcframework-in-same-directory/13545
**Category:** Usage
**Tags:** os:macos
**Created:** [February 5, 2025, 10:54pm UTC](https://discourse.cmake.org/t/looking-for-clarity-on-using-find-package-with-a-dylib-and-xcframework-in-same-directory/13545 "2025-02-05T22:54:43Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![externl](https://discourse.cmake.org/user_avatar/discourse.cmake.org/externl/32/5333_2.png) [@externl](https://discourse.cmake.org/u/externl)
#### Post date: [February 5, 2025, 10:54pm UTC](https://discourse.cmake.org/t/looking-for-clarity-on-using-find-package-with-a-dylib-and-xcframework-in-same-directory/13545/1 "2025-02-05T22:54:43Z")

</div>

Hello,

Sorry if this should be obvious but I’m relatively new to cmake and haven’t been able to find a clean solution to my issue.

I’m trying to create some imported targets for an installation of a library on my system. Let’s call it `Foo`. I’ve created a `FooConfig.cmake` file so I can use `find_package(Foo CONFIG)` and its targets.

The `Foo` install has a `lib` directory containing (among other things): `libFoo.a`, `libFoo.dylib`, and `Foo.xcframework` (used for Swift).

Calling `find_library(Foo_LIBRARY NAMES Foo PATHS lib)` results in `lib/Foo.xcframework`. I assume this is related to the fact that `CMAKE_FIND_LIBRARY_SUFFIXES` has this order on macOS `.tbd;.dylib;.so;.a`. I would prefer to get the dynamic library.

I could of course specify `libFoo.dylib` build I would prefer to use `NAMES Foo` as the library is cross-platform and also has Windows and Linux installs. I grepped though the `FindXXX.cmake` files that are included in cmake and didn’t see many (any?) `.dylib` in `find_library` calls so I’m not sure what the right approach is.

Is there way to ask `find_library` to not include `xcframeworks`?

Or is one of these solutions the most CMake friendly approach:

- Move `Foo.xcframework` to a `lib/XCFrameworks` or `lib/Frameworks` to avoid the issue
- Use a variable for the name which is set to `Foo` for Windows/Linux and `libFoo.dylib` on macOS
- Remove `.tdb` from `CMAKE_FIND_LIBRARY_SUFFIXES` for the whole build.
- Something else?

Thanks in advance.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [February 6, 2025, 8:29pm UTC](https://discourse.cmake.org/t/looking-for-clarity-on-using-find-package-with-a-dylib-and-xcframework-in-same-directory/13545/2 "2025-02-06T20:29:08Z")

</div>

You can control whether `find_library()` prefers frameworks or non-framework libraries by setting the [CMAKE\_FIND\_FRAMEWORK](https://cmake.org/cmake/help/latest/variable/CMAKE_FIND_FRAMEWORK.html) variable. See those docs for how to use it.

---

<div class="post-metadata">

### Author: ![externl](https://discourse.cmake.org/user_avatar/discourse.cmake.org/externl/32/5333_2.png) [@externl](https://discourse.cmake.org/u/externl)
#### Post date: [February 7, 2025, 3:04pm UTC](https://discourse.cmake.org/t/looking-for-clarity-on-using-find-package-with-a-dylib-and-xcframework-in-same-directory/13545/3 "2025-02-07T15:04:21Z")

</div>

Thanks, I completely missed this.
