Skip to content

Commit

Permalink
improve cmake and boost selection logic, per platform
Browse files Browse the repository at this point in the history
Fixes #2106

(Internal change: 2259956)
  • Loading branch information
meshula authored and pixar-oss committed Jan 13, 2023
1 parent a6e6030 commit 59eaff4
Showing 1 changed file with 57 additions and 30 deletions.
87 changes: 57 additions & 30 deletions build_scripts/build_usd.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ def __init__(self, name, installer, *files):
AllDependenciesByName.setdefault(name.lower(), self)

def Exists(self, context):
return all([os.path.isfile(os.path.join(context.instDir, f))
return any([os.path.isfile(os.path.join(context.instDir, f))
for f in self.filesToCheck])

class PythonDependency(object):
Expand Down Expand Up @@ -689,32 +689,27 @@ def InstallZlib(context, force, buildArgs):
############################################################
# boost

if MacOS():
# This version of boost resolves Python3 compatibilty issues on Big Sur and Monterey and is
# compatible with Python 2.7 through Python 3.10
BOOST_URL = "https://boostorg.jfrog.io/artifactory/main/release/1.78.0/source/boost_1_78_0.tar.gz"
BOOST_VERSION_FILE = "include/boost/version.hpp"
elif Linux():
# Support for vfxplatform 2020
BOOST_URL = "https://boostorg.jfrog.io/artifactory/main/release/1.70.0/source/boost_1_70_0.tar.gz"
BOOST_VERSION_FILE = "include/boost/version.hpp"
elif Windows():
# The default installation of boost on Windows puts headers in a versioned
# subdirectory, which we have to account for here. In theory, specifying
# "layout=system" would make the Windows install match Linux/MacOS, but that
# causes problems for other dependencies that look for boost.
#
# boost 1.70 is required for Visual Studio 2019. For simplicity, we use
# this version for all older Visual Studio versions as well.
# boost 1.78 is required for Visual Studio 2022.
if IsVisualStudio2022OrGreater():
def InstallBoost_Helper(context, force, buildArgs):

# In general we use boost 1.70.0 to adhere to VFX Reference Platform CY2020.
# However, there are some cases where a newer version is required.
# - Building with Python 3.10 requires boost 1.76.0 or newer.
# (https://github.com/boostorg/python/commit/cbd2d9)
# - Building with Visual Studio 2022 requires boost 1.78.0 or newer.
# (https://github.com/boostorg/build/issues/735)
# - Building on MacOS requires boost 1.78.0 or newer to resolve Python 3
# compatibility issues on Big Sur and Monterey.
pyInfo = GetPythonInfo(context)
pyVer = (int(pyInfo[3].split('.')[0]), int(pyInfo[3].split('.')[1]))
if context.buildPython and pyVer >= (3, 10):
BOOST_URL = "https://boostorg.jfrog.io/artifactory/main/release/1.78.0/source/boost_1_78_0.tar.gz"
elif IsVisualStudio2022OrGreater():
BOOST_URL = "https://boostorg.jfrog.io/artifactory/main/release/1.78.0/source/boost_1_78_0.tar.gz"
elif MacOS():
BOOST_URL = "https://boostorg.jfrog.io/artifactory/main/release/1.78.0/source/boost_1_78_0.tar.gz"
BOOST_VERSION_FILE = "include/boost-1_78/boost/version.hpp"
else:
BOOST_URL = "https://boostorg.jfrog.io/artifactory/main/release/1.70.0/source/boost_1_70_0.tar.gz"
BOOST_VERSION_FILE = "include/boost-1_70/boost/version.hpp"

def InstallBoost_Helper(context, force, buildArgs):

# Documentation files in the boost archive can have exceptionally
# long paths. This can lead to errors when extracting boost on Windows,
# since paths are limited to 260 characters by default on that platform.
Expand Down Expand Up @@ -893,7 +888,27 @@ def InstallBoost(context, force, buildArgs):
except: pass
raise

BOOST = Dependency("boost", InstallBoost, BOOST_VERSION_FILE)
# The default installation of boost on Windows puts headers in a versioned
# subdirectory, which we have to account for here. Specifying "layout=system"
# would cause the Windows header install to match Linux/MacOS, but the
# "layout=system" flag also changes the naming of the boost dlls in a
# manner that causes problems for dependent libraries that rely on boost's
# trick of automatically linking the boost libraries via pragmas in boost's
# standard include files. Dependencies that use boost's pragma linking
# facility in general don't have enough configuration switches to also coerce
# the naming of the dlls and so it is best to rely on boost's most default
# settings for maximum compatibility.
#
# On behalf of versions of visual studio prior to vs2022, we still support
# boost 1.70. We don't completely know if boost 1.78 is in play on Windows,
# until we have determined whether Python 3 has been selected as a target.
# That isn't known at this point in the script, so we simplify the logic by
# checking for any of the possible boost header locations that are possible
# outcomes from running this script.
BOOST = Dependency("boost", InstallBoost,
"include/boost/version.hpp",
"include/boost-1_70/boost/version.hpp",
"include/boost-1_78/boost/version.hpp")

############################################################
# Intel TBB
Expand Down Expand Up @@ -2350,13 +2365,25 @@ def ForceBuildDependency(self, dep):
sys.exit(1)

if which("cmake"):
# Check cmake requirements
if Windows():
# Windows build depend on boost 1.70, which is not supported before
# cmake version 3.14
cmake_required_version = (3, 24) if IsVisualStudio2022OrGreater() else (3,14)
# Check cmake minimum version requirements
pyInfo = GetPythonInfo(context)
pyVer = (int(pyInfo[3].split('.')[0]), int(pyInfo[3].split('.')[1]))
if context.buildPython and pyVer >= (3, 10):
# Python 3.10 is not supported prior to 3.24
cmake_required_version = (3, 24)
elif IsVisualStudio2022OrGreater():
# Visual Studio 2022 is not supported prior to 3.24
cmake_required_version = (3, 24)
elif Windows():
# Visual Studio 2017 and 2019 are verified to work correctly with 3.14
cmake_required_version = (3, 14)
elif MacOS():
# Apple Silicon is not supported prior to 3.19
cmake_required_version = (3, 19)
else:
# Linux, and vfx platform CY2020, are verified to work correctly with 3.12
cmake_required_version = (3, 12)

cmake_version = GetCMakeVersion()
if not cmake_version:
PrintError("Failed to determine CMake version")
Expand Down

0 comments on commit 59eaff4

Please sign in to comment.