weidai11 / cryptopp

free C++ class library of cryptographic schemes
https://cryptopp.com
Other
4.66k stars 1.47k forks source link

Add support for macOS Catalyst #1242

Open jnavarrom opened 9 months ago

jnavarrom commented 9 months ago

Allow to build cryptopp for macOS Catalyst, macOS Catalyst requires a specific target architecture.

Examples building for x86_64 and arm64 outputs

Using positional arg, MACOS_CPU=x86_64
Using positional arg, MACOS_CATALYST=1
Configuring for MacOSX (x86_64)
XCODE_TOOLCHAIN: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/
MACOS_SDK: MacOSX
MACOS_CPU: x86_64
MACOS_CFLAGS: -arch x86_64  -fno-common
MACOS_CXXFLAGS: -arch x86_64 -target x86_64-apple-ios15.0-macabi   -fno-common
MACOS_SYSROOT: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk
MACOS_CATALYST: 1

*******************************************************************************
It looks the the environment is set correctly. Your next step is build
the library with 'make -f GNUmakefile-cross'.
*******************************************************************************

Using testing flags: -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -g2 -O3 -fPIC -arch x86_64 -target x86_64-apple-ios15.0-macabi -fno-common
...
Using positional arg, MACOS_CPU=arm64
Using positional arg, MACOS_CATALYST=1
Configuring for MacOSX (arm64)
XCODE_TOOLCHAIN: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/
MACOS_SDK: MacOSX
MACOS_CPU: arm64
MACOS_CFLAGS: -arch arm64  -fno-common
MACOS_CXXFLAGS: -arch arm64 -target arm64-apple-ios15.0-macabi   -fno-common
MACOS_SYSROOT: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk
MACOS_CATALYST: 1

*******************************************************************************
It looks the the environment is set correctly. Your next step is build
the library with 'make -f GNUmakefile-cross'.
*******************************************************************************

Using testing flags: -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -g2 -O3 -fPIC -arch arm64 -target arm64-apple-ios15.0-macabi -fno-common
...
noloader commented 9 months ago

@jnavarrom,

Did you take a look at https://github.com/weidai11/cryptopp/blob/master/TestScripts/setenv-macos.sh?

jnavarrom commented 9 months ago

Hi @noloader, thanks for checking this.

Yes, I took a look at this file.

I can compile cryptopp for MacOS using setenv-macos.sh, but I can't build cryptopp for Catalyst using setenv-macos.sh as it currently is. This is the main reason of this pull request: add support for building crytopp for macOS Catalyst.

If I build cryptopp for macOS, without adding Catalyst support, and I want to build an app (that uses cryptopp) for Catalyst target, I won't be able to do it. Following error will happen:

libcryptopp.xcframework:1:1 While building for Mac Catalyst, no library for this platform was found in libcryptopp.xcframework

This is how the libcryptopp.xcframework looks like:

Screenshot 2023-10-11 at 12 26 14

If I build cryptopp for Catalyst target, I will be able to run the app in Catalyst:

Screenshot 2023-10-11 at 12 26 36 Screenshot 2023-10-11 at 12 31 11
noloader commented 9 months ago

@jnavarrom,

Thanks.

I don't know anything about Catalyst. And I don't have any modern Apple machines for Xcode testing.

So how about creating a setenv-catalyst.sh? Start with setenv-macos.sh, and assume the Catalyst gear so you can do away with the extra env var.

If there are problems using it, I will point folks to you.

jnavarrom commented 9 months ago

@noloader thanks

So how about creating a setenv-catalyst.sh?

Sure, I will create it. Thanks

jnavarrom commented 8 months ago

setenv-catalyst.sh created.

jnavarrom commented 8 months ago

Hi @noloader .

Would you mind to take a look at this pull request?

I just created the setenv-catalyst.sh based on setenv-mac.sh.

Let me know if I need to update something.

Thanks