diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2022-04-03 13:06:10 +0200 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2022-04-03 12:04:21 -0400 |
commit | 4dd6cb846900bf827c257f830d54d9fd0932743e (patch) | |
tree | 3151f6f9cff2e102635c883b59fb78bc4595a457 /mesonbuild/cmake/interpreter.py | |
parent | 2c4c7f6e64c923976158051cae8c63ee1364d573 (diff) | |
download | meson-4dd6cb846900bf827c257f830d54d9fd0932743e.zip meson-4dd6cb846900bf827c257f830d54d9fd0932743e.tar.gz meson-4dd6cb846900bf827c257f830d54d9fd0932743e.tar.bz2 |
cmake: Better error message when configuring a CMake subproject fails.
Diffstat (limited to 'mesonbuild/cmake/interpreter.py')
-rw-r--r-- | mesonbuild/cmake/interpreter.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py index 3f9326a..bbb0ce4 100644 --- a/mesonbuild/cmake/interpreter.py +++ b/mesonbuild/cmake/interpreter.py @@ -777,7 +777,7 @@ class CMakeInterpreter: # Raw CMake results self.bs_files = [] # type: T.List[Path] self.codemodel_configs = None # type: T.Optional[T.List[CMakeConfiguration]] - self.raw_trace = None # type: T.Optional[str] + self.cmake_stderr = None # type: T.Optional[str] # Analysed data self.project_name = '' @@ -841,13 +841,17 @@ class CMakeInterpreter: final_args = cmake_args + trace_args + cmcmp_args + toolchain.get_cmake_args() + [self.src_dir.as_posix()] cmake_exe.set_exec_mode(print_cmout=True, always_capture_stderr=self.trace.requires_stderr()) - rc, _, self.raw_trace = cmake_exe.call(final_args, self.build_dir, env=os_env, disable_cache=True) + rc, _, self.cmake_stderr = cmake_exe.call(final_args, self.build_dir, env=os_env, disable_cache=True) mlog.log() h = mlog.green('SUCCEEDED') if rc == 0 else mlog.red('FAILED') mlog.log('CMake configuration:', h) if rc != 0: - raise CMakeException('Failed to configure the CMake subproject') + # get the last CMake error - We only need the message function for this: + self.trace.functions = {'message': self.trace.functions['message']} + self.trace.parse(self.cmake_stderr) + error = f': {self.trace.errors[-1]}' if self.trace.errors else '' + raise CMakeException(f'Failed to configure the CMake subproject{error}') return cmake_exe @@ -879,7 +883,7 @@ class CMakeInterpreter: self.custom_targets = [] # Parse the trace - self.trace.parse(self.raw_trace) + self.trace.parse(self.cmake_stderr) # Find all targets added_target_names = [] # type: T.List[str] |