@@ -1789,6 +1789,11 @@ def InstallUSD(context, force, buildArgs):
17891789 '-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH' ,
17901790 '-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH' ])
17911791
1792+ if MacOS ():
1793+ extraArgs .append (f"-DPXR_BUILD_APPLE_FRAMEWORK={ 'ON' if context .buildAppleFramework else 'OFF' } " )
1794+ if context .macOSCodesign :
1795+ extraArgs .append (f"-DPXR_APPLE_CODESIGN_IDENTITY={ context .macOSCodesign } " )
1796+
17921797 # Make sure to use boost installed by the build script and not any
17931798 # system installed boost
17941799 extraArgs .append ('-DBoost_NO_BOOST_CMAKE=On' )
@@ -1903,6 +1908,12 @@ def InstallUSD(context, force, buildArgs):
19031908 help = ("Build target for macOS cross compilation. "
19041909 "(default: {})" .format (
19051910 apple_utils .GetBuildTargetDefault ())))
1911+ subgroup = group .add_mutually_exclusive_group ()
1912+ subgroup .add_argument ("--build-apple-framework" , dest = "build_apple_framework" , action = "store_true" ,
1913+ help = "Build USD as an Apple Framework (Default if using build)" )
1914+ subgroup .add_argument ("--no-build-apple-framework" , dest = "no_build_apple_framework" , action = "store_true" ,
1915+ help = "Do not build USD as an Apple Framework (Default if macOS)" )
1916+
19061917 if apple_utils .IsHostArm ():
19071918 # Intel Homebrew stores packages in /usr/local which unfortunately can
19081919 # be where a lot of other things are too. So we only add this flag on arm macs.
@@ -1938,6 +1949,7 @@ def InstallUSD(context, force, buildArgs):
19381949 default = codesignDefault , action = "store_true" ,
19391950 help = ("Enable code signing for macOS builds "
19401951 "(defaults to enabled on Apple Silicon)" ))
1952+ group .add_argument ("--codesign-id" , dest = "macos_codesign_id" , type = str )
19411953
19421954if Linux ():
19431955 group .add_argument ("--use-cxx11-abi" , type = int , choices = [0 , 1 ],
@@ -2216,17 +2228,25 @@ def __init__(self, args):
22162228 self .ignorePaths = args .ignore_paths or []
22172229 self .buildTarget = None
22182230 self .macOSCodesign = ""
2231+ self .buildAppleFramework = False
22192232 # Build target and code signing
22202233 if MacOS ():
22212234 self .buildTarget = args .build_target
22222235 apple_utils .SetTarget (self , self .buildTarget )
22232236
2224- self .macOSCodesign = \
2225- (args .macos_codesign if hasattr (args , "macos_codesign" )
2226- else False )
2237+ if args .macos_codesign :
2238+ self .macOSCodesign = args .macos_codesign_id or apple_utils .GetCodeSignID ()
22272239 if apple_utils .IsHostArm () and args .ignore_homebrew :
22282240 self .ignorePaths .append ("/opt/homebrew" )
22292241
2242+ self .buildAppleFramework = ((args .build_apple_framework
2243+ or self .buildTarget in apple_utils .EMBEDDED_PLATFORMS )
2244+ and not args .no_build_apple_framework )
2245+ if self .buildAppleFramework :
2246+ self .buildShared = False
2247+ self .buildMonolithic = True
2248+
2249+
22302250 coreOnly = self .buildTarget in apple_utils .EMBEDDED_PLATFORMS
22312251
22322252 self .useCXX11ABI = \
@@ -2239,10 +2259,10 @@ def __init__(self, args):
22392259
22402260 # Optional components
22412261 self .buildTests = args .build_tests
2242- self .buildPython = args .build_python and not coreOnly
2262+ self .buildPython = args .build_python and not coreOnly and not self . buildAppleFramework
22432263 self .buildExamples = args .build_examples
22442264 self .buildTutorials = args .build_tutorials
2245- self .buildTools = args .build_tools and not coreOnly
2265+ self .buildTools = args .build_tools and not coreOnly and not self . buildAppleFramework
22462266
22472267 # - Documentation
22482268 self .buildDocs = args .build_docs or args .build_python_docs
@@ -2675,8 +2695,9 @@ def FormatBuildArguments(buildArgs):
26752695 ])
26762696
26772697if MacOS ():
2678- if context .macOSCodesign :
2679- apple_utils .Codesign (context .usdInstDir , verbosity > 1 )
2698+ # We don't need to codesign when building a framework because it's handled during framework creation
2699+ if context .macOSCodesign and not context .buildAppleFramework :
2700+ apple_utils .Codesign (context , verbosity > 1 )
26802701
26812702printInstructions = any ([context .buildPython , context .buildTools , context .buildPrman ])
26822703if printInstructions :
@@ -2699,3 +2720,12 @@ def FormatBuildArguments(buildArgs):
26992720if context .buildPrman :
27002721 Print ("See documentation at http://openusd.org/docs/RenderMan-USD-Imaging-Plugin.html "
27012722 "for setting up the RenderMan plugin.\n " )
2723+
2724+ if context .buildAppleFramework :
2725+ Print ("""
2726+ Added the following framework to your Xcode Project, (recommended as Embed Without Signing):
2727+ OpenUSD.framework
2728+
2729+ Set the following compiler argument, to find the headers:
2730+ SYSTEM_HEADER_SEARCH_PATHS=$(SRCROOT)/$(TARGET_NAME)/OpenUSD.framework/Headers
2731+ """ )
0 commit comments