Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions build_scripts/build_usd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1661,6 +1661,7 @@ def InstallUSD(context, force, buildArgs):

extraArgs.append('-DPXR_PREFER_SAFETY_OVER_SPEED={}'
.format('ON' if context.safetyFirst else 'OFF'))
extraArgs.append(f"-DPXR_ENABLE_COMPILER_CACHE={'ON' if context.useCompilerCache else 'OFF'}")

if context.buildPython:
extraArgs.append('-DPXR_ENABLE_PYTHON_SUPPORT=ON')
Expand Down Expand Up @@ -1996,6 +1997,12 @@ def InstallUSD(context, force, buildArgs):
group.add_argument("--toolset", type=str,
help=("CMake toolset to use when building libraries with "
"cmake"))
subgroup = group.add_mutually_exclusive_group()
subgroup.add_argument("--compiler-cache", dest="use_compiler_cache", action="store_true",
default=not Windows(),
help="Use ccache to enable faster iterative builds. (default on macOS and Linux)")
subgroup.add_argument("--no-compiler-cache", dest="use_compiler_cache", action="store_false",
help="Do not use ccache. (default on Windows)")
if MacOS():
codesignDefault = True if apple_utils.IsHostArm() else False
group.add_argument("--codesign", dest="macos_codesign",
Expand Down Expand Up @@ -2267,6 +2274,7 @@ def __init__(self, args):
self.cmakeGenerator = args.generator
self.cmakeToolset = args.toolset
self.cmakeBuildArgs = args.cmake_build_args
self.useCompilerCache = args.use_compiler_cache

# Number of jobs
self.numJobs = args.jobs
Expand Down
11 changes: 11 additions & 0 deletions cmake/defaults/CXXDefaults.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,14 @@ if (PXR_PREFER_SAFETY_OVER_SPEED)
else()
set(PXR_PREFER_SAFETY_OVER_SPEED "0")
endif()

# Setup CCache for C/C++ compilation
if(PXR_ENABLE_COMPILER_CACHE)
find_program(COMPILER_CACHE_PROGRAM ${PXR_COMPILER_CACHE_NAME})
if(COMPILER_CACHE_PROGRAM)
set(CMAKE_C_COMPILER_LAUNCHER "${COMPILER_CACHE_PROGRAM}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${COMPILER_CACHE_PROGRAM}")
else ()
MESSAGE(STATUS "Compiler Caching disabled. Could not find ${PXR_COMPILER_CACHE_NAME}.")
endif()
endif()
8 changes: 8 additions & 0 deletions cmake/defaults/Options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,11 @@ if (${PXR_BUILD_PYTHON_DOCUMENTATION})
set(PXR_BUILD_PYTHON_DOCUMENTATION "OFF" CACHE BOOL "" FORCE)
endif()
endif()

# Configure the use of compiler caches for faster compilation
option(PXR_ENABLE_COMPILER_CACHE "Enable the use of a compiler cache" OFF)
set(PXR_COMPILER_CACHE_NAME "ccache"
CACHE
STRING
"The name of the compiler cache program to use"
)
Loading