Skip to content
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

Fix CMake import's linker args sorting algorithm mangling -framework arguments #14099

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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: T.Set[T.Union[T.Tuple[str], T.Tuple[str, str]]] = 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]
Loading