mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-12 17:19:05 -05:00
AIX: Fix XCOFF editor to avoid duplicating standard libpath entries
The `/usr/lib` and `/lib` entries need to be present, but do not need to be at the end. Avoid appending extra copies of the entries if they already exist. Closes: #26275
This commit is contained in:
committed by
Brad King
parent
80d16018fa
commit
3e5b9229e0
+15
-11
@@ -6,6 +6,7 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
#include <cm/memory>
|
#include <cm/memory>
|
||||||
|
#include <cm/string_view>
|
||||||
|
|
||||||
#include "cmsys/FStream.hxx"
|
#include "cmsys/FStream.hxx"
|
||||||
|
|
||||||
@@ -283,19 +284,22 @@ cm::optional<cm::string_view> Impl<XCOFF>::GetLibPath()
|
|||||||
template <typename XCOFF>
|
template <typename XCOFF>
|
||||||
bool Impl<XCOFF>::SetLibPath(cm::string_view libPath)
|
bool Impl<XCOFF>::SetLibPath(cm::string_view libPath)
|
||||||
{
|
{
|
||||||
// The new LIBPATH must end in the standard AIX LIBPATH.
|
// The new LIBPATH must contain standard AIX LIBPATH entries.
|
||||||
#define CM_AIX_LIBPATH "/usr/lib:/lib"
|
|
||||||
std::string libPathBuf;
|
std::string libPathBuf;
|
||||||
if (libPath != CM_AIX_LIBPATH &&
|
#define ENSURE_ENTRY(x) \
|
||||||
!cmHasLiteralSuffix(libPath, ":" CM_AIX_LIBPATH)) {
|
if (libPath != x && !cmHasLiteralPrefix(libPath, x ":") && \
|
||||||
libPathBuf = std::string(libPath);
|
!cmHasLiteralSuffix(libPath, ":" x) && \
|
||||||
if (!libPathBuf.empty() && libPathBuf.back() != ':') {
|
libPath.find(":" x ":") == std::string::npos) { \
|
||||||
libPathBuf.push_back(':');
|
libPathBuf = std::string(libPath); \
|
||||||
}
|
if (!libPathBuf.empty() && libPathBuf.back() != ':') { \
|
||||||
libPathBuf += CM_AIX_LIBPATH;
|
libPathBuf.push_back(':'); \
|
||||||
libPath = libPathBuf;
|
} \
|
||||||
|
libPathBuf += x; \
|
||||||
|
libPath = libPathBuf; \
|
||||||
}
|
}
|
||||||
#undef CM_AIX_LIBPATH
|
ENSURE_ENTRY("/usr/lib")
|
||||||
|
ENSURE_ENTRY("/lib")
|
||||||
|
#undef ENSURE_ENTRY
|
||||||
|
|
||||||
auto oldEnd = std::find(this->LoaderImportFileTable.begin(),
|
auto oldEnd = std::find(this->LoaderImportFileTable.begin(),
|
||||||
this->LoaderImportFileTable.end(), '\0');
|
this->LoaderImportFileTable.end(), '\0');
|
||||||
|
|||||||
Reference in New Issue
Block a user