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.xcframeworkto alib/XCFrameworksorlib/Frameworksto avoid the issue - Use a variable for the name which is set to
Foofor Windows/Linux andlibFoo.dylibon macOS - Remove
.tdbfromCMAKE_FIND_LIBRARY_SUFFIXESfor the whole build. - Something else?
Thanks in advance.