diff --git a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake --- a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake +++ b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake @@ -44,8 +44,11 @@ endfunction() function(find_darwin_sdk_version var sdk_name) - # We deliberately don't cache the result here because - # CMake's caching causes too many problems. + set(DARWIN_${sdk_name}_CACHED_SDKVERSION "" CACHE STRING "Darwin SDK version for SDK ${sdk_name}.") + if(DARWIN_${sdk_name}_CACHED_SDKVERSION) + set(${var} ${DARWIN_${sdk_name}_CACHED_SDKVERSION} PARENT_SCOPE) + return() + endif() set(result_process 1) if(NOT DARWIN_PREFER_PUBLIC_SDK) # Let's first try the internal SDK, otherwise use the public SDK. @@ -76,6 +79,7 @@ "Reported SDK version \"${var_internal}\" does not look like a version") endif() set(${var} ${var_internal} PARENT_SCOPE) + set(DARWIN_${sdk_name}_CACHED_SDKVERSION ${var_internal} CACHE STRING "Darwin SDK version for SDK ${sdk_name}." FORCE) endfunction() # There isn't a clear mapping of what architectures are supported with a given