cmake module: Better warnings and error messages in some cases.

pull/10617/head
Volker Weißmann 3 years ago committed by Daniel Mensinger
parent 0bf66ff02c
commit cdd2dca174
  1. 2
      mesonbuild/cmake/generator.py
  2. 1
      mesonbuild/cmake/interpreter.py
  3. 7
      mesonbuild/cmake/traceparser.py

@ -13,6 +13,7 @@
# limitations under the License.
from .. import mesonlib
from .. import mlog
from .common import cmake_is_debug
import typing as T
@ -66,6 +67,7 @@ def parse_generator_expressions(
def target_file(arg: str) -> str:
if arg not in trace.targets:
mlog.warning(f"Somewhere in your CMakeLists.txt you have '$<TARGET_FILE:{arg}>'. In cmake, this evaluates to the path to '{arg}'. If '{arg}' does not exist, cmake errors out. We think that '{arg}' does not exist, so we do not know its path and just return an empty string.")
return ''
tgt = trace.targets[arg]

@ -667,6 +667,7 @@ class ConverterCustomTarget:
commands = [] # type: T.List[T.List[T.Union[str, ConverterTarget]]]
for curr_cmd in self._raw_target.command:
assert isinstance(curr_cmd, list)
assert curr_cmd[0] != '', "An empty string is not a valid executable"
cmd = [] # type: T.List[T.Union[str, ConverterTarget]]
for j in curr_cmd:

@ -231,7 +231,14 @@ class CMakeTraceParser:
for ctgt in self.custom_targets:
ctgt.outputs = pathlist_gen(ctgt._outputs_str)
temp = ctgt.command
ctgt.command = [strlist_gen(x) for x in ctgt.command]
for command, src in zip(ctgt.command, temp):
if command[0] == "":
raise CMakeException(
"We have a problem: We would like to generate a recipe for a target that should be generated by the custom command %s\nThe problem is that the executable that should be called, here: '%s', is a variable that evaluates to an empty string. An empty string is not a valid path to an executable so ninja will not be able to call it."
% (repr(src), src[0])
)
ctgt.working_dir = Path(parse_generator_expressions(str(ctgt.working_dir), self)) if ctgt.working_dir is not None else None
# Postprocess

Loading…
Cancel
Save