diff options
| author | Marco Rebhan <me@dblsaiko.net> | 2025-01-08 23:21:16 +0100 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2025-02-11 14:43:20 -0800 |
| commit | 0ce5c8142917cdece30407d284fdea1087e55e43 (patch) | |
| tree | 2811e4c2b6b52bec588f807c760e511fdd6651c9 /mesonbuild/dependencies | |
| parent | e42cd6aff6fcbf5556261d874e731613d9345378 (diff) | |
| download | meson-0ce5c8142917cdece30407d284fdea1087e55e43.tar.gz | |
Fix CMake import's linker args sorting algorithm mangling -framework arguments
Diffstat (limited to 'mesonbuild/dependencies')
| -rw-r--r-- | mesonbuild/dependencies/cmake.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/mesonbuild/dependencies/cmake.py b/mesonbuild/dependencies/cmake.py index 4a722157f..42cffd595 100644 --- a/mesonbuild/dependencies/cmake.py +++ b/mesonbuild/dependencies/cmake.py @@ -546,7 +546,7 @@ class CMakeDependency(ExternalDependency): # 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}') @@ -654,3 +654,27 @@ class CMakeDependencyFactory: @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] |
