diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2021-05-30 16:33:09 +0200 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2021-05-30 16:33:09 +0200 |
commit | 9b5463681e8f5df8dbe628be0a95982584b2343b (patch) | |
tree | ba0bfce27a7355a7f1674d2e4e86a8328d206669 /mesonbuild/cmake/common.py | |
parent | f0812baf8d1c746a4b5b7d8661a4e3d13af577b7 (diff) | |
download | meson-9b5463681e8f5df8dbe628be0a95982584b2343b.zip meson-9b5463681e8f5df8dbe628be0a95982584b2343b.tar.gz meson-9b5463681e8f5df8dbe628be0a95982584b2343b.tar.bz2 |
cmake: select correct generator in toolchain.py
Diffstat (limited to 'mesonbuild/cmake/common.py')
-rw-r--r-- | mesonbuild/cmake/common.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/mesonbuild/cmake/common.py b/mesonbuild/cmake/common.py index f0a54b5..d1f86f0 100644 --- a/mesonbuild/cmake/common.py +++ b/mesonbuild/cmake/common.py @@ -15,11 +15,14 @@ # This class contains the basic functionality needed to run any interpreter # or an interpreter-based tool. -from ..mesonlib import MesonException +from ..mesonlib import MesonException, OptionKey from .. import mlog from pathlib import Path import typing as T +if T.TYPE_CHECKING: + from ..environment import Environment + language_map = { 'c': 'C', 'cpp': 'CXX', @@ -32,6 +35,15 @@ language_map = { 'swift': 'Swift', } +backend_generator_map = { + 'ninja': 'Ninja', + 'xcode': 'Xcode', + 'vs2010': 'Visual Studio 10 2010', + 'vs2015': 'Visual Studio 15 2017', + 'vs2017': 'Visual Studio 15 2017', + 'vs2019': 'Visual Studio 16 2019', +} + blacklist_cmake_defs = [ 'CMAKE_TOOLCHAIN_FILE', 'CMAKE_PROJECT_INCLUDE', @@ -87,6 +99,12 @@ def _flags_to_list(raw: str) -> T.List[str]: res = list(filter(lambda x: len(x) > 0, res)) return res +def cmake_get_generator_args(env: 'Environment') -> T.List[str]: + backend_name = env.coredata.get_option(OptionKey('backend')) + assert isinstance(backend_name, str) + assert backend_name in backend_generator_map + return ['-G', backend_generator_map[backend_name]] + def cmake_defines_to_args(raw: T.Any, permissive: bool = False) -> T.List[str]: res = [] # type: T.List[str] if not isinstance(raw, list): |