Skip to content

Commit

Permalink
cmake: Use find_library() on bare library names in cmake dependencies
Browse files Browse the repository at this point in the history
Convert bare library names to a dependency linker argument using
find_library(), rather than hardcoding the MSVC transformation.
  • Loading branch information
jon-turney authored and dcbaker committed Nov 20, 2021
1 parent 987a26e commit 61ca564
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions mesonbuild/dependencies/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,12 +617,10 @@ def _detect_dep(self, name: str, package_version: str, modules: T.List[T.Tuple[s
libraries += [j]
elif self.env.machines.build.is_windows() and reg_is_maybe_bare_lib.match(j):
# On Windows, CMake library dependencies can be passed as bare library names,
# e.g. 'version' should translate into 'version.lib'. CMake brute-forces a
# combination of prefix/suffix combinations to find the right library, however
# as we do not have a compiler environment available to us, we cannot do the
# same, but must assume any bare argument passed which is not also a CMake
# target must be a system library we should try to link against
libraries += [f"{j}.lib"]
# CMake brute-forces a combination of prefix/suffix combinations to find the
# right library. Assume any bare argument passed which is not also a CMake
# target must be a system library we should try to link against.
libraries += self.clib_compiler.find_library(j, self.env, [])
else:
mlog.warning('CMake: Dependency', mlog.bold(j), 'for', mlog.bold(name), 'target', mlog.bold(self._original_module_name(curr)), 'was not found')

Expand Down

0 comments on commit 61ca564

Please sign in to comment.