aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/cmake/common.py
diff options
context:
space:
mode:
authorDaniel Mensinger <daniel@mensinger-ka.de>2020-10-16 20:44:04 +0200
committerDaniel Mensinger <daniel@mensinger-ka.de>2020-10-16 20:44:04 +0200
commit5f1da86a9b3ed75c49df7073962c4e9b6a43d497 (patch)
tree8eda42a121d2ba12b444e5581fb73bd6290ea6c4 /mesonbuild/cmake/common.py
parentc3b3dc598e8c417e66792444945f7c803d772e62 (diff)
downloadmeson-5f1da86a9b3ed75c49df7073962c4e9b6a43d497.zip
meson-5f1da86a9b3ed75c49df7073962c4e9b6a43d497.tar.gz
meson-5f1da86a9b3ed75c49df7073962c4e9b6a43d497.tar.bz2
cmake: ignore CMAKE_TOOLCHAIN_FILE and CMAKE_PROJECT_INCLUDE to avoid conflicts with the meson CMake logic
Diffstat (limited to 'mesonbuild/cmake/common.py')
-rw-r--r--mesonbuild/cmake/common.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/mesonbuild/cmake/common.py b/mesonbuild/cmake/common.py
index 3534ec0..fe98497 100644
--- a/mesonbuild/cmake/common.py
+++ b/mesonbuild/cmake/common.py
@@ -32,6 +32,11 @@ language_map = {
'swift': 'Swift',
}
+blacklist_cmake_defs = [
+ 'CMAKE_TOOLCHAIN_FILE',
+ 'CMAKE_PROJECT_INCLUDE',
+]
+
class CMakeException(MesonException):
pass
@@ -83,6 +88,11 @@ def cmake_defines_to_args(raw: T.Any, permissive: bool = False) -> T.List[str]:
raise MesonException('Invalid CMake defines. Expected a dict, but got a {}'.format(type(i).__name__))
for key, val in i.items():
assert isinstance(key, str)
+ if key in blacklist_cmake_defs:
+ mlog.warning('Setting', mlog.bold(key), '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
if isinstance(val, (str, int, float)):
res += ['-D{}={}'.format(key, val)]
elif isinstance(val, bool):
@@ -93,6 +103,20 @@ def cmake_defines_to_args(raw: T.Any, permissive: bool = False) -> T.List[str]:
return res
+# TODO: this functuin will become obsolete once the `cmake_args` kwarg is dropped
+def check_cmake_args(args: T.List[str]) -> T.List[str]:
+ res = [] # type: T.List[str]
+ dis = ['-D' + x for x in blacklist_cmake_defs]
+ assert dis # Ensure that dis is not empty.
+ for i in args:
+ if any([i.startswith(x) for x in dis]):
+ mlog.warning('Setting', mlog.bold(i), '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 += [i]
+ return res
+
class CMakeInclude:
def __init__(self, path: Path, isSystem: bool = False):
self.path = path