Skip to content

Commit eaa2329

Browse files
committed
dependencies/cmake: Handle spaces in set_property calls
1 parent 99b848f commit eaa2329

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

mesonbuild/dependencies/base.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,7 +1639,7 @@ def _cmake_add_custom_target(self, tline: CMakeTraceLine):
16391639

16401640
self.targets[tline.args[0]] = CMakeTarget(tline.args[0], 'CUSTOM', {})
16411641

1642-
def _cmake_set_property(self, tline: CMakeTraceLine):
1642+
def _cmake_set_property(self, tline: CMakeTraceLine) -> None:
16431643
# DOC: https://cmake.org/cmake/help/latest/command/set_property.html
16441644
args = list(tline.args)
16451645

@@ -1649,8 +1649,10 @@ def _cmake_set_property(self, tline: CMakeTraceLine):
16491649

16501650
append = False
16511651
targets = []
1652-
while len(args) > 0:
1652+
while args:
16531653
curr = args.pop(0)
1654+
# XXX: APPEND_STRING is specifically *not* supposed to create a
1655+
# list, is treating them as aliases really okay?
16541656
if curr == 'APPEND' or curr == 'APPEND_STRING':
16551657
append = True
16561658
continue
@@ -1660,31 +1662,29 @@ def _cmake_set_property(self, tline: CMakeTraceLine):
16601662

16611663
targets.append(curr)
16621664

1665+
if not args:
1666+
raise self._gen_exception('CMake: set_property() faild to parse argument list\n{}'.format(tline))
1667+
16631668
if len(args) == 1:
16641669
# Tries to set property to nothing so nothing has to be done
16651670
return
16661671

1667-
if len(args) < 2:
1668-
raise self._gen_exception('CMake: set_property() faild to parse argument list\n{}'.format(tline))
1669-
1670-
propName = args[0]
1671-
propVal = list(itertools.chain(*map(lambda x: x.split(';'), args[1:])))
1672-
propVal = list(filter(lambda x: len(x) > 0, propVal))
1673-
1674-
if len(propVal) == 0:
1672+
identifier = args.pop(0)
1673+
value = ' '.join(args).split(';')
1674+
if not value:
16751675
return
16761676

16771677
for i in targets:
16781678
if i not in self.targets:
16791679
raise self._gen_exception('CMake: set_property() TARGET {} not found\n{}'.format(i, tline))
16801680

1681-
if propName not in self.targets[i].properies:
1682-
self.targets[i].properies[propName] = []
1681+
if identifier not in self.targets[i].properies:
1682+
self.targets[i].properies[identifier] = []
16831683

16841684
if append:
1685-
self.targets[i].properies[propName] += propVal
1685+
self.targets[i].properies[identifier] += value
16861686
else:
1687-
self.targets[i].properies[propName] = propVal
1687+
self.targets[i].properies[identifier] = value
16881688

16891689
def _cmake_set_target_properties(self, tline: CMakeTraceLine) -> None:
16901690
# DOC: https://cmake.org/cmake/help/latest/command/set_target_properties.html

0 commit comments

Comments
 (0)