diff --git a/mesonbuild/dependencies/cmake.py b/mesonbuild/dependencies/cmake.py index cff0e5814..e9a4aa3ea 100644 --- a/mesonbuild/dependencies/cmake.py +++ b/mesonbuild/dependencies/cmake.py @@ -76,10 +76,10 @@ class CMakeDependency(ExternalDependency): # one module return module - def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any], language: T.Optional[str] = None) -> None: + def __init__(self, name: str, environment: 'Environment', kwargs: T.Dict[str, T.Any], language: T.Optional[str] = None, force_use_global_compilers: bool = False) -> None: # Gather a list of all languages to support self.language_list = [] # type: T.List[str] - if language is None: + if language is None or force_use_global_compilers: compilers = None if kwargs.get('native', False): compilers = environment.coredata.compilers.build diff --git a/mesonbuild/dependencies/data/CMakeListsLLVM.txt b/mesonbuild/dependencies/data/CMakeListsLLVM.txt index 9d3e41234..da23189b7 100644 --- a/mesonbuild/dependencies/data/CMakeListsLLVM.txt +++ b/mesonbuild/dependencies/data/CMakeListsLLVM.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} ) set(PACKAGE_FOUND FALSE) diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py index c2bef0d7f..97d1633ab 100644 --- a/mesonbuild/dependencies/dev.py +++ b/mesonbuild/dependencies/dev.py @@ -404,7 +404,18 @@ class LLVMDependencyCMake(CMakeDependency): def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]) -> None: self.llvm_modules = stringlistify(extract_as_list(kwargs, 'modules')) self.llvm_opt_modules = stringlistify(extract_as_list(kwargs, 'optional_modules')) - super().__init__(name, env, kwargs, language='cpp') + + compilers = None + if kwargs.get('native', False): + compilers = env.coredata.compilers.build + else: + compilers = env.coredata.compilers.host + if not compilers or not all(x in compilers for x in ('c', 'cpp')): + self.is_found = False + mlog.warning('The LLVM dependency was not found via CMake since both a C and C++ compiler are required.') + return + + super().__init__(name, env, kwargs, language='cpp', force_use_global_compilers=True) # Cmake will always create a statically linked binary, so don't use # cmake if dynamic is required