Skip to content

Commit

Permalink
Fix CMake import's linker args sorting algorithm mangling -framework …
Browse files Browse the repository at this point in the history
…arguments
  • Loading branch information
2xsaiko committed Jan 9, 2025
1 parent 4379ca1 commit e46227a
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion mesonbuild/dependencies/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ def _detect_dep(self, name: str, package_version: str, modules: T.List[T.Tuple[s
# Make sure all elements in the lists are unique and sorted
incDirs = sorted(set(incDirs))
compileOptions = sorted(set(compileOptions))
libraries = sorted(set(libraries))
libraries = sort_link_args(libraries)

mlog.debug(f'Include Dirs: {incDirs}')
mlog.debug(f'Compiler Options: {compileOptions}')
Expand Down Expand Up @@ -654,3 +654,27 @@ def __call__(self, name: str, env: Environment, kwargs: T.Dict[str, T.Any], lang
@staticmethod
def log_tried() -> str:
return CMakeDependency.log_tried()


def sort_link_args(args: T.List[str]) -> T.List[str]:
itr = iter(args)
result = set()

while True:
try:
arg = next(itr)
except StopIteration:
break

if arg == '-framework':
# Frameworks '-framework ...' are two arguments that need to stay together
try:
arg2 = next(itr)
except StopIteration:
raise MesonException(f'Linker arguments contain \'-framework\' with no argument value: {args}')

result.add((arg, arg2))
else:
result.add((arg,))

return [x for xs in sorted(result) for x in xs]

0 comments on commit e46227a

Please sign in to comment.