Skip to content

Commit 390e3af

Browse files
committed
Enable the use of ccache and other compiler cache utilities
1 parent 947efa1 commit 390e3af

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

cmake/defaults/CXXDefaults.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,17 @@ else()
9090
set(PXR_PREFER_SAFETY_OVER_SPEED "0")
9191
endif()
9292

93+
# Setup CCache for C/C++ compilation
94+
if(PXR_ENABLE_COMPILER_CACHE)
95+
find_program(COMPILER_CACHE_PROGRAM ${PXR_COMPILER_CACHE_NAME})
96+
if(COMPILER_CACHE_PROGRAM)
97+
set(CMAKE_C_COMPILER_LAUNCHER "${COMPILER_CACHE_PROGRAM}")
98+
set(CMAKE_CXX_COMPILER_LAUNCHER "${COMPILER_CACHE_PROGRAM}")
99+
else ()
100+
MESSAGE(STATUS "Compiler Caching disabled. Could not find ${PXR_COMPILER_CACHE_NAME}.")
101+
endif()
102+
endif()
103+
93104
# Set that Apple Framework is being build
94105
if (PXR_BUILD_APPLE_FRAMEWORK)
95106
_add_define("PXR_BUILD_APPLE_FRAMEWORK")

cmake/defaults/Options.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,11 @@ if (${PXR_BUILD_PYTHON_DOCUMENTATION})
245245
set(PXR_BUILD_PYTHON_DOCUMENTATION "OFF" CACHE BOOL "" FORCE)
246246
endif()
247247
endif()
248+
249+
# Configure the use of compiler caches for faster compilation
250+
option(PXR_ENABLE_COMPILER_CACHE "Enable the use of a compiler cache" OFF)
251+
set(PXR_COMPILER_CACHE_NAME "ccache"
252+
CACHE
253+
STRING
254+
"The name of the compiler cache program to use"
255+
)

0 commit comments

Comments
 (0)