Mac arm, universal library, how to ling against 2 openssl libs?

Viewed 76

So my understanding is that on mac if I want to build universal library or executable I need to do :

set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE INTERNAL "" FORCE)

Now this is great, but if say, this project needs to link against brew - openSSL or vcpkg - zlib... Then I need to somehow link against 2 openSSL versions? Since vcpkg builds for either arm or intel, I have now 2x vcpkg installed, 1 for each architecture. I also have 2x brew installed for each architecture.

So my question is... How can I

find_package(OpenSSL REQUIRED ${BREW_INTEL})
find_package(OpenSSL REQUIRED ${BREW_ARM})
find_package(zlib REQUIRED ${vcpkg_INTEL})
find_package(zlib REQUIRED ${vcpkg_ARM})

So that each Architecture targets correct sub library... version ?

Am I wrong with this? Right? how do I bite it? Thanks!

1 Answers

Lacking a better option, I've used lipo to build a multiplatform library:

lipo /opt/homebrew/Cellar/openssl@1.1/1.1.1o/lib/libssl.a \
     /usr/local/opt/openssl/lib/libssl.a \
     -create -output ~/lib_all/libssl.a
Related