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

Allow for cmake w-flags addition #14102

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion mesonbuild/cmake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
'TargetOptions',
'language_map',
'cmake_defines_to_args',
'cmake_warning_flags_to_args',
'check_cmake_args',
'cmake_is_debug',
'resolve_cmake_trace_targets',
]

from .common import CMakeException, TargetOptions, cmake_defines_to_args, language_map, check_cmake_args, cmake_is_debug
from .common import CMakeException, TargetOptions, cmake_defines_to_args, cmake_warning_flags_to_args, language_map, check_cmake_args, cmake_is_debug
from .executor import CMakeExecutor
from .interpreter import CMakeInterpreter
from .toolchain import CMakeToolchain, CMakeExecScope
Expand Down
17 changes: 17 additions & 0 deletions mesonbuild/cmake/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
'MESON_CMAKE_ROOT',
]

blacklist_cmake_warning_flags = [
]

def cmake_is_debug(env: 'Environment') -> bool:
if OptionKey('b_vscrt') in env.coredata.optstore:
is_debug = env.coredata.get_option(OptionKey('buildtype')) == 'debug'
Expand Down Expand Up @@ -130,6 +133,20 @@ def cmake_defines_to_args(raw: T.List[T.Dict[str, TYPE_var]], permissive: bool =

return res

def cmake_warning_flags_to_args(raw: T.List[str], permissive: bool = False) -> T.List[str]:
res: T.List[str] = []

for flag in raw:
if flag in blacklist_cmake_warning_flags:
# idk something something
#mlog.warning('Setting', mlog.bold(flag), 'is not supported. See the meson docs for cross compilation support:')
#mlog.warning(' - URL: https://mesonbuild.com/CMake-module.html#cross-compilation')
#mlog.warning(' --> Ignoring this option')
continue
res += [f'-W{flag}']

return res

# TODO: this function will become obsolete once the `cmake_args` kwarg is dropped
def check_cmake_args(args: T.List[str]) -> T.List[str]:
res: T.List[str] = []
Expand Down
8 changes: 7 additions & 1 deletion mesonbuild/modules/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from .. import build, mesonlib, mlog, dependencies
from ..options import OptionKey
from ..cmake import TargetOptions, cmake_defines_to_args
from ..cmake import TargetOptions, cmake_defines_to_args, cmake_warning_flags_to_args
from ..interpreter import SubprojectHolder
from ..interpreter.type_checking import REQUIRED_KW, INSTALL_DIR_KW, NoneType, in_set_validator
from ..interpreterbase import (
Expand Down Expand Up @@ -191,6 +191,7 @@ def __init__(self) -> None:
self.methods.update(
{
'add_cmake_defines': self.add_cmake_defines,
'add_cmake_warning_flags': self.add_cmake_warning_flags,
'set_override_option': self.set_override_option,
'set_install': self.set_install,
'append_compile_args': self.append_compile_args,
Expand All @@ -209,6 +210,11 @@ def _get_opts(self, kwargs: TargetKW) -> SingleTargetOptions:
def add_cmake_defines(self, state: ModuleState, args: T.Tuple[T.List[T.Dict[str, TYPE_var]]], kwargs: TYPE_kwargs) -> None:
self.cmake_options += cmake_defines_to_args(args[0])

@typed_pos_args('subproject_options.add_cmake_warning_flags', varargs=str)
@noKwargs
def add_cmake_warning_flags(self, state: ModuleState, args: T.Tuple[T.List[str]], kwargs: TYPE_kwargs) -> None:
self.cmake_options += cmake_warning_flags_to_args(args[0])

@typed_pos_args('subproject_options.set_override_option', str, str)
@typed_kwargs('subproject_options.set_override_option', _TARGET_KW)
def set_override_option(self, state: ModuleState, args: T.Tuple[str, str], kwargs: TargetKW) -> None:
Expand Down
Loading