diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2020-08-12 15:39:18 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2020-08-12 12:21:32 +0000 |
commit | 4b0e1850a00431fe34b4e8087865f51225fe027d (patch) | |
tree | 1a058ebf3ed5cb881ca39d825d85f0781a4a9dac /mesonbuild/cmake/executor.py | |
parent | bc64e1d6b0c0306457ae4643fc3d3d9bec51f1b9 (diff) | |
download | meson-4b0e1850a00431fe34b4e8087865f51225fe027d.zip meson-4b0e1850a00431fe34b4e8087865f51225fe027d.tar.gz meson-4b0e1850a00431fe34b4e8087865f51225fe027d.tar.bz2 |
cmake: Use a mapping when writing compiler ID
Meson and CMake compiler ids are different. This commit adds a mapping
from the meson list:
https://mesonbuild.com/Reference-tables.html#compiler-ids
to the CMake list:
https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html
The mapping is not 1-1, and not all entries are mapped, so this is
a best-effort attempt. Fallback to GNU as before to try to limp along
and hope that the build files don't rely on an accurate compiler ID.
Diffstat (limited to 'mesonbuild/cmake/executor.py')
-rw-r--r-- | mesonbuild/cmake/executor.py | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/mesonbuild/cmake/executor.py b/mesonbuild/cmake/executor.py index 793862f..e29e67a 100644 --- a/mesonbuild/cmake/executor.py +++ b/mesonbuild/cmake/executor.py @@ -35,6 +35,31 @@ if T.TYPE_CHECKING: TYPE_result = T.Tuple[int, T.Optional[str], T.Optional[str]] +MESON_TO_CMAKE_MAPPING = { + 'arm': 'ARMCC', + 'armclang': 'ARMClang', + 'clang': 'Clang', + 'clang-cl': 'MSVC', + 'flang': 'Flang', + 'g95': 'G95', + 'gcc': 'GNU', + 'intel': 'Intel', + 'intel-cl': 'MSVC', + 'msvc': 'MSVC', + 'pathscale': 'PathScale', + 'pgi': 'PGI', + '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': + 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') + + class CMakeExecutor: # The class's copy of the CMake path. Avoids having to search for it # multiple times in the same Meson invocation. @@ -280,7 +305,7 @@ class CMakeExecutor: if comp_obj is not None: exe_list = comp_obj.get_exelist() - comp_id = comp_obj.get_id().upper() + comp_id = meson_compiler_to_cmake_id(comp_obj) comp_version = comp_obj.version.upper() if len(exe_list) == 1: |