From 74e7595def967fe57225c69a215bb26d4635bb4b Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Sat, 18 Apr 2026 14:20:49 -0400 Subject: [PATCH] fix(build): default CPM_SOURCE_CACHE to repo-local cache to enable incremental builds (#2735) Without a stable CPM_SOURCE_CACHE, FetchContent_Populate runs on every cmake configure (new session), triggering ExternalProject's git fetch/checkout and touching header timestamps in _deps/-src/. This causes a complete C++ rebuild on every `uv build` even with no source changes. Defaulting CPM_SOURCE_CACHE to .cpm_cache/ in the repo root ensures CPM skips FetchContent_Populate for already-downloaded packages, keeping header timestamps stable. Users can still override via the CPM_SOURCE_CACHE env var. Co-authored-by: Claude Sonnet 4.6 --- .gitignore | 1 + cmake/dependencies.cmake | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index ff5a080f..caf970cf 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ Web/fluid_properties/fluids/molecule_sdf/ .version /bld* +/.cpm_cache/ /dev/VS2010 diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index 5c1afee9..8e060b72 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -1,6 +1,11 @@ # Dependencies for CoolProp managed via CPM.cmake -# Set CPM_SOURCE_CACHE in your environment (e.g. ~/.cache/CPM) to share the -# download cache across git worktrees and build directories. +# CPM_SOURCE_CACHE can be overridden via environment variable (e.g. ~/.cache/CPM) +# to share the download cache across git worktrees and build directories. +# Without a stable cache location, FetchContent re-runs on every cmake configure, +# touching header timestamps and forcing a complete C++ rebuild each time. +if(NOT DEFINED CPM_SOURCE_CACHE AND "$ENV{CPM_SOURCE_CACHE}" STREQUAL "") + set(CPM_SOURCE_CACHE "${CMAKE_CURRENT_LIST_DIR}/../.cpm_cache" CACHE PATH "CPM source cache") +endif() include("${CMAKE_CURRENT_LIST_DIR}/CPM.cmake")