cmake: Fix custom command CMake list issue

pull/6963/head
Daniel Mensinger 5 years ago
parent 03b86cdbed
commit 4199cb32a5
No known key found for this signature in database
GPG Key ID: 54DD94C131E277D4
  1. 15
      mesonbuild/cmake/traceparser.py
  2. 6
      test cases/cmake/8 custom command/subprojects/cmMod/CMakeLists.txt

@ -309,7 +309,7 @@ class CMakeTraceParser:
def _cmake_add_custom_command(self, tline: CMakeTraceLine, name=None):
# DOC: https://cmake.org/cmake/help/latest/command/add_custom_command.html
args = list(tline.args) # Make a working copy
args = self._flatten_args(list(tline.args)) # Commands can be passed as ';' seperated lists
if not args:
return self._gen_exception('add_custom_command', 'requires at least 1 argument', tline)
@ -325,15 +325,15 @@ class CMakeTraceParser:
target = CMakeGeneratorTarget(name)
def handle_output(key: str, target: CMakeGeneratorTarget) -> None:
target.outputs += key.split(';')
target.outputs += [key]
def handle_command(key: str, target: CMakeGeneratorTarget) -> None:
if key == 'ARGS':
return
target.command[-1] += key.split(';')
target.command[-1] += [key]
def handle_depends(key: str, target: CMakeGeneratorTarget) -> None:
target.depends += key.split(';')
target.depends += [key]
def handle_working_dir(key: str, target: CMakeGeneratorTarget) -> None:
if target.working_dir is None:
@ -608,6 +608,13 @@ class CMakeTraceParser:
args = [parse_generator_expressions(x) for x in args]
yield CMakeTraceLine(data['file'], data['line'], data['cmd'], args)
def _flatten_args(self, args: T.List[str]) -> T.List[str]:
# Split lists in arguments
res = [] # type: T.List[str]
for i in args:
res += i.split(';')
return res
def _guess_files(self, broken_list: T.List[str]) -> T.List[str]:
# Nothing has to be done for newer formats
if self.trace_format != 'human':

@ -16,9 +16,15 @@ add_custom_command(
COMMAND gen ARGS genTest
)
set(CMD_PART)
list(APPEND CMD_PART COMMAND mycpy cpyBase.cpp.in cpyBase.cpp.in.gen)
list(APPEND CMD_PART COMMAND mycpy cpyBase.cpp.in.gen cpyBase.cpp.out)
list(APPEND CMD_PART COMMAND mycpy cpyBase.cpp.out cpyBase.cpp.something)
add_custom_command(
OUTPUT cpyBase.cpp
COMMAND mycpy "${CMAKE_CURRENT_SOURCE_DIR}/cpyBase.cpp.am" cpyBase.cpp.in
${CMD_PART}
COMMAND mycpy cpyBase.cpp.in cpyBase.cpp.something
COMMAND mycpy cpyBase.cpp.something cpyBase.cpp.IAmRunningOutOfIdeas
COMMAND mycpy cpyBase.cpp.IAmRunningOutOfIdeas cpyBase.cpp

Loading…
Cancel
Save