From 99ffa9910c1fc0d33abff91d4b277c3af214b9ce Mon Sep 17 00:00:00 2001
From: Ben Boeckel <ben.boeckel@kitware.com>
Date: Thu, 29 Apr 2021 17:59:42 -0400
Subject: [PATCH] cmake: clear some configure checks when the deployment target
 changes

If the target is changed since the last configure, some checks need to
be looked up again. Clear their cache entries when these checks need to
be redone.
---
 CMakeLists.txt | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index bf8543e..ef615b3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -98,6 +98,16 @@ foreach(p
   endif()
 endforeach()
 
+# Some configure checks depend upon the deployment target. Clear checks when
+# the deployment target changes.
+if (APPLE)
+  if (NOT CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL KWSYS_LAST_OSX_DEPLOYMENT_TARGET)
+    unset(KWSYS_CXX_HAS_UTIMENSAT CACHE)
+  endif ()
+  set(KWSYS_LAST_OSX_DEPLOYMENT_TARGET "${CMAKE_OSX_DEPLOYMENT_TARGET}"
+    CACHE INTERNAL "remember the last deployment target to trigger configure rechecks")
+endif ()
+
 #-----------------------------------------------------------------------------
 # If a namespace is not specified, use "kwsys" and enable testing.
 # This should be the case only when kwsys is not included inside
-- 
GitLab