--- ./Source/cmXCOFF.cxx_orig	2024-10-04 04:18:17.370387214 -0500
+++ ./Source/cmXCOFF.cxx	2024-10-04 04:20:09.509597066 -0500
@@ -7,6 +7,7 @@
 
 #include <cm/memory>
 
+#include <cm/string_view>
 #include "cmsys/FStream.hxx"
 
 #include "cmStringAlgorithms.h"
@@ -281,20 +282,22 @@
 template <typename XCOFF>
 bool Impl<XCOFF>::SetLibPath(cm::string_view libPath)
 {
-  // The new LIBPATH must end in the standard AIX LIBPATH.
-#define CM_AIX_LIBPATH "/usr/lib:/lib"
-  std::string libPathBuf;
-  if (libPath != CM_AIX_LIBPATH &&
-      !cmHasLiteralSuffix(libPath, ":" CM_AIX_LIBPATH)) {
-    libPathBuf = std::string(libPath);
-    if (!libPathBuf.empty() && libPathBuf.back() != ':') {
-      libPathBuf.push_back(':');
-    }
-    libPathBuf += CM_AIX_LIBPATH;
-    libPath = libPathBuf;
-  }
-#undef CM_AIX_LIBPATH
-
+  // The new LIBPATH must contain standard AIX LIBPATH entries.
+#define ENSURE_ENTRY(x)                                                       \
+  if (libPath != x && !cmHasLiteralPrefix(libPath, x ":") &&                  \
+      !cmHasLiteralSuffix(libPath, ":" x) &&                                  \
+      libPath.find(":" x ":") == std::string::npos) {                         \
+    std::string libPathBuf = std::string(libPath);                                        \
+    if (!libPathBuf.empty() && libPathBuf.back() != ':') {                    \
+      libPathBuf.push_back(':');                                              \
+    }                                                                         \
+    libPathBuf += x;                                                          \
+    libPath = libPathBuf;                                                     \
+  }
+  ENSURE_ENTRY("/usr/lib")
+  ENSURE_ENTRY("/lib")
+#undef ENSURE_ENTRY
+  
   auto oldEnd = std::find(this->LoaderImportFileTable.begin(),
                           this->LoaderImportFileTable.end(), '\0');
   if (oldEnd == this->LoaderImportFileTable.end()) {
