-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Apple framework builds #2020
Add support for Apple framework builds #2020
Conversation
…andard CMake directives. Also remove TARGET_OS_IOS in favor of the more correct TARGET_OS_IPHONE Signed-off-by: Dhruv Govil <[email protected]>
Signed-off-by: Dhruv Govil <[email protected]>
Signed-off-by: Dhruv Govil <[email protected]>
Signed-off-by: Dhruv Govil <[email protected]>
Signed-off-by: Dhruv Govil <[email protected]>
@dgovil Should this changelist include corresponding updates to our GitHub CI, so that the new, recommended pattern for iOS builds is validated for current and future commits? https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/.github/workflows/main.yml#L94 |
Signed-off-by: Dhruv Govil <[email protected]>
Ah good catch, I'd missed that hidden folder. |
Signed-off-by: Dhruv Govil <[email protected]>
Signed-off-by: Jonathan Stone <[email protected]>
Signed-off-by: Jonathan Stone <[email protected]>
…rated. Signed-off-by: Dhruv Govil <[email protected]>
Signed-off-by: Jonathan Stone <[email protected]>
Signed-off-by: Jonathan Stone <[email protected]>
Signed-off-by: Dhruv Govil <[email protected]>
Signed-off-by: Dhruv Govil <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, thanks @dgovil! I'm CC'ing @ld-kerley in case he has additional thoughts and recommendations.
e6b9650
into
AcademySoftwareFoundation:main
This PR makes a few changes that have been derived from a corresponding PR to USD PixarAnimationStudios/OpenUSD#2969
The changes are:
Deprecates
MATERIALX_BUILD_IOS
in favor of usingCMAKE_SYSTEM_NAME
. This allows for better support for iPhone derived targets like visionOS. Earlier this would force it to iOS which can cause subtle issues when compiled against other SDKs. See https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-ios-tvos-visionos-or-watchosChanges
TARGET_OS_IOS
define toTARGET_OS_IPHONE
which is more correct to support iPhone derivatives. See https://chaosinmotion.com/2021/08/02/things-to-remember-compiler-conditionals-for-macos-ios-etc/ . But the gist isTARGET_OS_IOS
refers specifically to the modern iOS/iPadOS SDK, whereasTARGET_OS_IPHONE
refers to all Apple SDKs that derived from the original iPhone.Add support for building as a Framework. This creates a special directory structure that streamlines embedding of MaterialX within Apps on Apple platforms to just dragging the project into the app in Xcode. No other linker and compiler configuration is necessary. See Framework notes below.
Adds a new
getSharedLibraryPath
function on Apple platforms that finds the path that contains the dylib, instead of just the executable that is ultimately linking to the dylib. I didn't implement this for Windows/Linux since there's only one the one need for it right now. This is derived from USD's method to do the same.Additionally, I've added a
MATERIALX_BUILD_IDENTIFIER
that mirrors how USD generates a single integer build number for its namespace. I only use this within the Plist for the framework since it requires the identifier version to be an incrementing integer.Framework notes
I have opted to use a zsh to keep this consistent with the PR for USD, rather than use CMake's built in Framework generation. This is also because, either way, I need to do some processing to the headers (see below) , fixing of linkage etc so it's simpler to just do it all in one spot.
Zsh is always guaranteed to exist on any macOS in the last several years.
The zsh script also modifies the Headers because Clang will automatically add frameworks to the include search path, as long as the include starts with the frameworks name. This means that
#include <MaterialXCore/Document.h>
now needs to be#include <MaterialX/MaterialXCore/Document.h>
. However if your code requires the unprefixed version, you can still manually add the Header directory in the framework and it'll work as it normally would.One other advantage to using the Zsh script as a post process is that you still get a standard build of the libraries too in case you want to use them otherwise, and you also can fix issues in the Framework without doing a full rebuild.