Skip to content

Set version, soversion from cmake if available #14682

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions mesonbuild/cmake/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ def __init__(self, target: CMakeTarget, env: 'Environment', for_machine: Machine
self.compile_opts: T.Dict[str, T.List[str]] = {}
self.public_compile_opts: T.List[str] = []
self.pie = False
self.version: T.Optional[str] = None
self.soversion: T.Optional[str] = None

# Project default override options (c_std, cpp_std, etc.)
self.override_options: T.List[str] = []
Expand Down Expand Up @@ -357,6 +359,8 @@ def postprocess(self, output_target_map: OutputTargetMap, root_src_dir: Path, su
tgt = trace.targets.get(self.cmake_name)
if tgt:
self.depends_raw = trace.targets[self.cmake_name].depends
self.version = trace.targets[self.cmake_name].properties.get('VERSION', [None])[0]
self.soversion = trace.targets[self.cmake_name].properties.get('SOVERSION', [None])[0]

rtgt = resolve_cmake_trace_targets(self.cmake_name, trace, self.env, clib_compiler=self.clib_compiler)
self.includes += [Path(x) for x in rtgt.include_directories]
Expand Down Expand Up @@ -1172,6 +1176,12 @@ def process_target(tgt: ConverterTarget) -> None:
'objects': [method(x, 'extract_all_objects') for x in objec_libs],
}

# Only set version if we know it
if tgt.version:
tgt_kwargs['version'] = tgt.version
if tgt.soversion:
tgt_kwargs['soversion'] = tgt.soversion

# Only set if installed and only override if it is set
if install_tgt and tgt.install_dir:
tgt_kwargs['install_dir'] = tgt.install_dir
Expand Down
4 changes: 4 additions & 0 deletions test cases/cmake/2 advanced/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ test('test3', sub_pro.target('testEXE'))
# Test that we can add a new target with the same name as the CMake subproject
exe4 = executable('testEXE', ['main.cpp'], dependencies: [sub_sta])
test('test4', exe4)

# Test if libraries are named correctly
assert(sub_pro.target_type('cmModLib') == 'shared_library', 'Type should be shared_library')
assert(sub_pro.target('cmModLib').full_path().endswith('1.0.1'), 'Shared library version not picked up correctly')
Loading