@@ -1790,6 +1790,10 @@ def InstallUSD(context, force, buildArgs):
17901790 if Windows ():
17911791 # Increase the precompiled header buffer limit.
17921792 extraArgs .append ('-DCMAKE_CXX_FLAGS="/Zm150"' )
1793+ if MacOS ():
1794+ extraArgs .append (f"-DPXR_BUILD_APPLE_FRAMEWORK={ 'ON' if context .buildAppleFramework else 'OFF' } " )
1795+ if context .macOSCodesign :
1796+ extraArgs .append (f"-DPXR_APPLE_CODESIGN_IDENTITY={ context .macOSCodesign } " )
17931797
17941798 # Make sure to use boost installed by the build script and not any
17951799 # system installed boost
@@ -1910,6 +1914,12 @@ def InstallUSD(context, force, buildArgs):
19101914 help = ("Build target for macOS cross compilation. "
19111915 "(default: {})" .format (
19121916 apple_utils .GetBuildTargetDefault ())))
1917+ subgroup = group .add_mutually_exclusive_group ()
1918+ subgroup .add_argument ("--build-apple-framework" , dest = "build_apple_framework" , action = "store_true" ,
1919+ help = "Build USD as an Apple Framework (Default if using build)" )
1920+ subgroup .add_argument ("--no-build-apple-framework" , dest = "no_build_apple_framework" , action = "store_true" ,
1921+ help = "Do not build USD as an Apple Framework (Default if macOS)" )
1922+
19131923 if apple_utils .IsHostArm ():
19141924 # Intel Homebrew stores packages in /usr/local which unfortunately can
19151925 # be where a lot of other things are too. So we only add this flag on arm macs.
@@ -1945,6 +1955,7 @@ def InstallUSD(context, force, buildArgs):
19451955 default = codesignDefault , action = "store_true" ,
19461956 help = ("Enable code signing for macOS builds "
19471957 "(defaults to enabled on Apple Silicon)" ))
1958+ group .add_argument ("--codesign-id" , dest = "macos_codesign_id" , type = str )
19481959
19491960if Linux ():
19501961 group .add_argument ("--use-cxx11-abi" , type = int , choices = [0 , 1 ],
@@ -2234,11 +2245,18 @@ def __init__(self, args):
22342245 self .buildTarget = args .build_target
22352246 apple_utils .SetTarget (self , self .buildTarget )
22362247
2237- self .macOSCodesign = \
2238- ( args .macos_codesign if hasattr ( args , "macos_codesign" )
2239- else False )
2248+ self .macOSCodesign = False
2249+ if args .macos_codesign :
2250+ self . macOSCodesign = args . macos_codesign_id or apple_utils . GetCodeSignID ( )
22402251 if apple_utils .IsHostArm () and args .ignore_homebrew :
22412252 self .ignorePaths .append ("/opt/homebrew" )
2253+
2254+ self .buildAppleFramework = ((args .build_apple_framework
2255+ or self .buildTarget in apple_utils .EMBEDDED_PLATFORMS )
2256+ and not args .no_build_apple_framework )
2257+ if self .buildAppleFramework :
2258+ self .buildShared = False
2259+ self .buildMonolithic = True
22422260 else :
22432261 self .buildTarget = ""
22442262
@@ -2585,6 +2603,7 @@ def _JoinVersion(v):
25852603summaryMsg += """\
25862604 Variant {buildVariant}
25872605 Target {buildTarget}
2606+ Framework Build {buildAppleFramework}
25882607 Imaging {buildImaging}
25892608 Ptex support: {enablePtex}
25902609 OpenVDB support: {enableOpenVDB}
@@ -2669,7 +2688,8 @@ def FormatBuildArguments(buildArgs):
26692688 buildMaterialX = ("On" if context .buildMaterialX else "Off" ),
26702689 buildMayapyTests = ("On" if context .buildMayapyTests else "Off" ),
26712690 buildAnimXTests = ("On" if context .buildAnimXTests else "Off" ),
2672- enableHDF5 = ("On" if context .enableHDF5 else "Off" ))
2691+ enableHDF5 = ("On" if context .enableHDF5 else "Off" ),
2692+ buildAppleFramework = ("On" if MacOS () and context .buildAppleFramework else "Off" ))
26732693
26742694Print (summaryMsg )
26752695
@@ -2731,8 +2751,9 @@ def FormatBuildArguments(buildArgs):
27312751 ])
27322752
27332753if MacOS ():
2734- if context .macOSCodesign :
2735- apple_utils .Codesign (context .usdInstDir , verbosity > 1 )
2754+ # We don't need to codesign when building a framework because it's handled during framework creation
2755+ if context .macOSCodesign and not context .buildAppleFramework :
2756+ apple_utils .Codesign (context , verbosity > 1 )
27362757
27372758additionalInstructions = any ([context .buildPython , context .buildTools , context .buildPrman ])
27382759if additionalInstructions :
@@ -2755,3 +2776,12 @@ def FormatBuildArguments(buildArgs):
27552776if context .buildPrman :
27562777 Print ("See documentation at http://openusd.org/docs/RenderMan-USD-Imaging-Plugin.html "
27572778 "for setting up the RenderMan plugin.\n " )
2779+
2780+ if context .buildAppleFramework :
2781+ Print ("""
2782+ Added the following framework to your Xcode Project, (recommended as Embed Without Signing):
2783+ OpenUSD.framework
2784+
2785+ Set the following compiler argument, to find the headers:
2786+ SYSTEM_HEADER_SEARCH_PATHS=$(SRCROOT)/$(TARGET_NAME)/OpenUSD.framework/Headers
2787+ """ )
0 commit comments