@@ -75,21 +75,34 @@ def MacOS():
7575if MacOS ():
7676 import apple_utils
7777
78+ # WASM specific defines and helpers
79+ TARGET_WASM = 'wasm'
80+ TARGET_WASM64 = 'wasm64'
81+
82+ # determines flags based on 32 / 64 bit wasm build target
83+ def GetWasmCompilerFlags (buildTarget ):
84+ compileFlags = '-pthread --use-port=zlib'
85+ linkerFlags = '-pthread'
86+
87+ if buildTarget == TARGET_WASM64 :
88+ compileFlags += ' -sMEMORY64=1'
89+ linkerFlags += ' -sMEMORY64=1'
90+
91+ return (compileFlags , linkerFlags )
92+
7893def GetBuildTargetDefault ():
7994 if MacOS ():
8095 return apple_utils .GetBuildTargetDefault ()
8196 else :
8297 return ''
8398
84- TARGET_WASM = 'wasm'
85-
8699def GetBuildTargets ():
87100 if MacOS ():
88- return apple_utils .GetBuildTargets () + [TARGET_WASM ]
101+ return apple_utils .GetBuildTargets () + [TARGET_WASM , TARGET_WASM64 ]
89102 elif Linux ():
90- return [TARGET_WASM ]
103+ return [TARGET_WASM , TARGET_WASM64 ]
91104 elif Windows ():
92- return [TARGET_WASM ]
105+ return [TARGET_WASM , TARGET_WASM64 ]
93106 else :
94107 return []
95108
@@ -1007,7 +1020,16 @@ def InstallOneTBB(context, force, buildArgs):
10071020 with CurrentWorkingDirectory (DownloadURL (ONETBB_URL , context , force )):
10081021 cmakeOptions = ['-DTBB_TEST=OFF' , '-DTBB_STRICT=OFF' ]
10091022 if context .targetWasm :
1010- cmakeOptions += ['-DBUILD_SHARED_LIBS=OFF' , '-DCMAKE_CXX_FLAGS="-pthread"' ]
1023+ compileFlags , _ = GetWasmCompilerFlags (context .buildTarget )
1024+
1025+ # Note: Emscripten toolchain file will check presence of
1026+ # '-sMEMORY64=1' in 'CMAKE_C_FLAGS' to determine if a
1027+ # 64 bit build is to be performed
1028+ cmakeOptions += [
1029+ '-DBUILD_SHARED_LIBS=OFF' ,
1030+ '-DCMAKE_CXX_FLAGS="{}"' .format (compileFlags ),
1031+ '-DCMAKE_C_FLAGS="{}"' .format (compileFlags )
1032+ ]
10111033
10121034 cmakeOptions += buildArgs
10131035 RunCMake (context , force , cmakeOptions )
@@ -1196,6 +1218,9 @@ def InstallJPEG(context, force, buildArgs):
11961218 extraJPEGArgs = buildArgs
11971219 if not which ("nasm" ):
11981220 extraJPEGArgs .append ("-DWITH_SIMD=FALSE" )
1221+
1222+ # For compatibility with CMake 4+
1223+ extraJPEGArgs .append ("-DCMAKE_POLICY_VERSION_MINIMUM=3.5" )
11991224
12001225 RunCMake (context , force , extraJPEGArgs )
12011226 return os .getcwd ()
@@ -1230,6 +1255,10 @@ def InstallTIFF(context, force, buildArgs):
12301255 else :
12311256 extraArgs = []
12321257 extraArgs += buildArgs
1258+
1259+ # For compatibility with CMake 4+
1260+ extraArgs .append ("-DCMAKE_POLICY_VERSION_MINIMUM=3.5" )
1261+
12331262 RunCMake (context , force , extraArgs )
12341263
12351264TIFF = Dependency ("TIFF" , InstallTIFF , "include/tiff.h" )
@@ -1467,10 +1496,15 @@ def InstallOpenSubdiv(context, force, buildArgs):
14671496 '-DNO_PTEX=ON' ,
14681497 '-DNO_TBB=ON' ,
14691498 ]
1499+ # Note: Emscripten toolchain file will check presence of
1500+ # '-sMEMORY64=1' in 'CMAKE_C_FLAGS' to determine if a
1501+ # 64 bit build is to be performed
14701502 if context .targetWasm :
1503+ compileFlags , _ = GetWasmCompilerFlags (context .buildTarget )
1504+
14711505 extraArgs .append ('-DBUILD_SHARED_LIB=OFF' )
1472- extraArgs .append ('-DCMAKE_CXX_FLAGS="-pthread"' )
1473- extraArgs .append ('-DCMAKE_C_FLAGS="-pthread"' )
1506+ extraArgs .append ('-DCMAKE_CXX_FLAGS="{}"' . format ( compileFlags ) )
1507+ extraArgs .append ('-DCMAKE_C_FLAGS="{}"' . format ( compileFlags ) )
14741508 extraArgs .append ('-DNO_METAL=ON' )
14751509
14761510 # Use Metal for macOS and all Apple embedded systems.
@@ -1885,6 +1919,12 @@ def InstallUSD(context, force, buildArgs):
18851919
18861920 extraArgs .append ('-DBUILD_SHARED_LIBS=OFF' )
18871921
1922+ compileFlags , linkFlags = GetWasmCompilerFlags (context .buildTarget )
1923+
1924+ extraArgs .append ('-DCMAKE_CXX_FLAGS="{}"' .format (compileFlags ))
1925+ extraArgs .append ('-DCMAKE_C_FLAGS="{}"' .format (compileFlags ))
1926+ extraArgs .append ('-DCMAKE_EXE_LINKER_FLAGS="{}"' .format (linkFlags ))
1927+
18881928 RunCMake (context , force , extraArgs , context .usdInstDir )
18891929
18901930USD = Dependency ("USD" , InstallUSD , "include/pxr/pxr.h" )
@@ -2346,7 +2386,8 @@ def __init__(self, args):
23462386
23472387 self .ignorePaths = args .ignore_paths or []
23482388 # Build target and code signing
2349- self .targetWasm = (args .build_target == TARGET_WASM )
2389+ self .targetWasm = (args .build_target == TARGET_WASM or
2390+ args .build_target == TARGET_WASM64 )
23502391 self .buildTarget = args .build_target
23512392 if MacOS ():
23522393 apple_utils .SetTarget (self , self .buildTarget )
0 commit comments