From 76ad5fe8d387638d21258177328763f05a0e95ae Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Fri, 6 Oct 2023 18:06:41 -0500 Subject: [PATCH] backend: Add rpath for external versioned .so's On Linux many .so's are augmented with version information, e.g. libxyz.so.1.2.3. CMake will happily refer to these versioned .so's in its dependencies instead of libxyz.so (typically a symlink). Unfortunately these versioned .so's aren't recognized as libraries by the Backend's logic to produce build rpaths from library paths. Fix this by recognizing any .so extension as sufficient reason to produce a build rpath, not just if .so is the last extension. --- mesonbuild/backend/backends.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 85f689646..cb730de5b 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -780,7 +780,11 @@ class Backend: # Windows doesn't support rpaths, but we use this function to # emulate rpaths by setting PATH # .dll is there for mingw gcc - if os.path.splitext(libpath)[1] not in {'.dll', '.lib', '.so', '.dylib'}: + # .so's may be extended with version information, e.g. libxyz.so.1.2.3 + if not ( + os.path.splitext(libpath)[1] in {'.dll', '.lib', '.so', '.dylib'} + or re.match(r'.+\.so(\.|$)', os.path.basename(libpath)) + ): continue try: