diff --git a/kwsysPlatformTestsCXX.cxx b/kwsysPlatformTestsCXX.cxx
index 01c69514c0cc2f255d1bcadf4c5066880d9eed95..e67d4366239a57d0c5e1cde35b05def52a889fa1 100644
--- a/kwsysPlatformTestsCXX.cxx
+++ b/kwsysPlatformTestsCXX.cxx
@@ -265,6 +265,12 @@ int main()
 #ifdef TEST_KWSYS_CXX_HAS_UTIMENSAT
 #include <fcntl.h>
 #include <sys/stat.h>
+#if defined(__APPLE__)
+#include <AvailabilityMacros.h>
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 101300
+#error "utimensat not available on macOS < 10.13"
+#endif
+#endif
 int main()
 {
   struct timespec times[2] = { { 0, UTIME_OMIT }, { 0, UTIME_NOW } };