diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2020-08-22 22:40:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-22 22:40:44 +0300 |
commit | a9f33d96c674763657315770a99358d271206551 (patch) | |
tree | de831b9144d7fbb0478221dba3f858fcf6a9470d /mesonbuild/cmake | |
parent | e9a71ebf60a91443ae024dea94a8b68d46987589 (diff) | |
parent | 2845f5a2302de86e04efe7d9a153e05bde3caa65 (diff) | |
download | meson-a9f33d96c674763657315770a99358d271206551.zip meson-a9f33d96c674763657315770a99358d271206551.tar.gz meson-a9f33d96c674763657315770a99358d271206551.tar.bz2 |
Merge pull request #7609 from dcbaker/submit/2020-08/cmake-fix-apple-clang
Fix mapping of apple compilers in cmake
Diffstat (limited to 'mesonbuild/cmake')
-rw-r--r-- | mesonbuild/cmake/executor.py | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/mesonbuild/cmake/executor.py b/mesonbuild/cmake/executor.py index e29e67a..2226c02 100644 --- a/mesonbuild/cmake/executor.py +++ b/mesonbuild/cmake/executor.py @@ -29,13 +29,18 @@ from .. import mlog, mesonlib from ..mesonlib import PerMachine, Popen_safe, version_compare, MachineChoice from ..environment import Environment from ..envconfig import get_env_var +from ..compilers import ( + AppleClangCCompiler, AppleClangCPPCompiler, AppleClangObjCCompiler, + AppleClangObjCPPCompiler +) if T.TYPE_CHECKING: from ..dependencies.base import ExternalProgram + from ..compilers import Compiler TYPE_result = T.Tuple[int, T.Optional[str], T.Optional[str]] -MESON_TO_CMAKE_MAPPING = { +_MESON_TO_CMAKE_MAPPING = { 'arm': 'ARMCC', 'armclang': 'ARMClang', 'clang': 'Clang', @@ -51,13 +56,21 @@ MESON_TO_CMAKE_MAPPING = { 'sun': 'SunPro', } -def meson_compiler_to_cmake_id(cobj): - # cland and apple clang both map to 'clang' in meson, so we need to look at - # the linker that's being used - if cobj.linker.get_id() == 'ld64': +def meson_compiler_to_cmake_id(cobj: 'Compiler') -> str: + """Translate meson compiler's into CMAKE compiler ID's. + + Most of these can be handled by a simple table lookup, with a few + exceptions. + + Clang and Apple's Clang are both identified as "clang" by meson. To make + things more complicated gcc and vanilla clang both use Apple's ld64 on + macOS. The only way to know for sure is to do an isinstance() check. + """ + if isinstance(cobj, (AppleClangCCompiler, AppleClangCPPCompiler, + AppleClangObjCCompiler, AppleClangObjCPPCompiler)): return 'AppleClang' # If no mapping, try GNU and hope that the build files don't care - return MESON_TO_CMAKE_MAPPING.get(cobj.get_id(), 'GNU') + return _MESON_TO_CMAKE_MAPPING.get(cobj.get_id(), 'GNU') class CMakeExecutor: |