diff options
-rw-r--r-- | mesonbuild/cmake/interpreter.py | 33 | ||||
-rw-r--r-- | mesonbuild/compilers/compilers.py | 2 | ||||
-rw-r--r-- | test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt | 2 | ||||
-rw-r--r-- | test cases/cmake/3 advanced no dep/subprojects/cmMod/CMakeLists.txt | 2 |
4 files changed, 27 insertions, 12 deletions
diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py index 773e2ec..09ac7c6 100644 --- a/mesonbuild/cmake/interpreter.py +++ b/mesonbuild/cmake/interpreter.py @@ -22,7 +22,7 @@ from .traceparser import CMakeTraceParser, CMakeGeneratorTarget from .. import mlog from ..environment import Environment from ..mesonlib import MachineChoice -from ..compilers.compilers import lang_suffixes, header_suffixes, obj_suffixes, is_header +from ..compilers.compilers import lang_suffixes, header_suffixes, obj_suffixes, lib_suffixes, is_header from subprocess import Popen, PIPE from typing import Any, List, Dict, Optional, TYPE_CHECKING from threading import Thread @@ -117,6 +117,7 @@ def _generated_file_key(fname: str) -> str: class ConverterTarget: lang_cmake_to_meson = {val.lower(): key for key, val in language_map.items()} + rm_so_version = re.compile(r'(\.[0-9]+)+$') def __init__(self, target: CMakeTarget, env: Environment): self.env = env @@ -211,15 +212,30 @@ class ConverterTarget: mlog.warning('CMake: Target', mlog.bold(self.name), 'not found in CMake trace. This can lead to build errors') # Fix link libraries + def try_resolve_link_with(path: str) -> Optional[str]: + basename = os.path.basename(path) + candidates = [basename, ConverterTarget.rm_so_version.sub('', basename)] + for i in lib_suffixes: + if not basename.endswith('.' + i): + continue + new_basename = basename[:-len(i) - 1] + new_basename = ConverterTarget.rm_so_version.sub('', new_basename) + new_basename = '{}.{}'.format(new_basename, i) + candidates += [new_basename] + for i in candidates: + if i in output_target_map: + return output_target_map[i] + return None + temp = [] for i in self.link_libraries: # Let meson handle this arcane magic if ',-rpath,' in i: continue if not os.path.isabs(i): - basename = os.path.basename(i) - if basename in output_target_map: - self.link_with += [output_target_map[basename]] + link_with = try_resolve_link_with(i) + if link_with: + self.link_with += [link_with] continue temp += [i] @@ -586,14 +602,9 @@ class CMakeInterpreter: # generate the output_target_map output_target_map = {} + output_target_map.update({x.full_name: x for x in self.targets}) + output_target_map.update({_target_key(x.name): x for x in self.targets}) for i in self.targets: - output_target_map[i.full_name] = i - output_target_map[_target_key(i.name)] = i - ttarget = self.trace.targets.get(i.name) - soversion = ttarget.properties.get('SOVERSION') if ttarget else None - if soversion: - k = '{}.{}'.format(i.full_name, soversion[0]) - output_target_map[k] = i for j in i.artifacts: output_target_map[os.path.basename(j)] = i for i in self.custom_targets: diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 2c9508b..b79fa41 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -39,7 +39,7 @@ Also add corresponding autodetection code in environment.py.""" header_suffixes = ('h', 'hh', 'hpp', 'hxx', 'H', 'ipp', 'moc', 'vapi', 'di') obj_suffixes = ('o', 'obj', 'res') -lib_suffixes = ('a', 'lib', 'dll', 'dylib', 'so') +lib_suffixes = ('a', 'lib', 'dll', 'dll.a', 'dylib', 'so') # Mapping of language to suffixes of files that should always be in that language # This means we can't include .h headers here since they could be C, C++, ObjC, etc. lang_suffixes = { diff --git a/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt b/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt index f9e7578..05ccb9e 100644 --- a/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt +++ b/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt @@ -14,6 +14,8 @@ add_library(cmModLib SHARED lib/cmMod.cpp) include(GenerateExportHeader) generate_export_header(cmModLib) +set_target_properties(cmModLib PROPERTIES VERSION 1.0.1) + add_executable(testEXE main.cpp) target_link_libraries(cmModLib ZLIB::ZLIB) diff --git a/test cases/cmake/3 advanced no dep/subprojects/cmMod/CMakeLists.txt b/test cases/cmake/3 advanced no dep/subprojects/cmMod/CMakeLists.txt index 2fdd5a8..2f6267d 100644 --- a/test cases/cmake/3 advanced no dep/subprojects/cmMod/CMakeLists.txt +++ b/test cases/cmake/3 advanced no dep/subprojects/cmMod/CMakeLists.txt @@ -12,6 +12,8 @@ add_library(cmModLib SHARED lib/cmMod.cpp) include(GenerateExportHeader) generate_export_header(cmModLib) +set_target_properties(cmModLib PROPERTIES VERSION 1.0.1) + add_executable(testEXE main.cpp) target_link_libraries(testEXE cmModLib) |