Skip to content

Commit a4cbe22

Browse files
committed
Enable the use of ccache and other compiler cache utilities
1 parent 5332d62 commit a4cbe22

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

cmake/defaults/CXXDefaults.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,14 @@ if (PXR_PREFER_SAFETY_OVER_SPEED)
8989
else()
9090
set(PXR_PREFER_SAFETY_OVER_SPEED "0")
9191
endif()
92+
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()

cmake/defaults/Options.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,11 @@ if (${PXR_BUILD_PYTHON_DOCUMENTATION})
231231
set(PXR_BUILD_PYTHON_DOCUMENTATION "OFF" CACHE BOOL "" FORCE)
232232
endif()
233233
endif()
234+
235+
# Configure the use of compiler caches for faster compilation
236+
option(PXR_ENABLE_COMPILER_CACHE "Enable the use of a compiler cache" OFF)
237+
set(PXR_COMPILER_CACHE_NAME "ccache"
238+
CACHE
239+
STRING
240+
"The name of the compiler cache program to use"
241+
)

0 commit comments

Comments
 (0)