aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mensinger <daniel@mensinger-ka.de>2020-03-28 12:07:56 +0100
committerJussi Pakkanen <jpakkane@gmail.com>2020-03-29 19:35:37 +0300
commit95e7477d120ef8ff4d86aa1c669ad0ad9c5835e1 (patch)
tree651b41f83abf5819b429fa6b5202cac15feb0b80
parent4bfc143c5e83160327cd5cf0508849691c3bb678 (diff)
downloadmeson-95e7477d120ef8ff4d86aa1c669ad0ad9c5835e1.zip
meson-95e7477d120ef8ff4d86aa1c669ad0ad9c5835e1.tar.gz
meson-95e7477d120ef8ff4d86aa1c669ad0ad9c5835e1.tar.bz2
cmake: Only expand executable targets in COMMAND (fixes #6857)
-rw-r--r--mesonbuild/cmake/interpreter.py12
-rw-r--r--test cases/cmake/8 custom command/subprojects/cmMod/CMakeLists.txt4
2 files changed, 14 insertions, 2 deletions
diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py
index dcb9e25..2e33be6 100644
--- a/mesonbuild/cmake/interpreter.py
+++ b/mesonbuild/cmake/interpreter.py
@@ -163,6 +163,14 @@ class OutputTargetMap:
def target(self, name: str) -> T.Optional[T.Union['ConverterTarget', 'ConverterCustomTarget']]:
return self._return_first_valid_key([self._target_key(name)])
+ def executable(self, name: str) -> T.Optional['ConverterTarget']:
+ tgt = self.target(name)
+ if tgt is None or not isinstance(tgt, ConverterTarget):
+ return None
+ if tgt.meson_func() != 'executable':
+ return None
+ return tgt
+
def artifact(self, name: str) -> T.Optional[T.Union['ConverterTarget', 'ConverterCustomTarget']]:
keys = []
candidates = [name, OutputTargetMap.rm_so_version.sub('', name)]
@@ -659,7 +667,7 @@ class ConverterCustomTarget:
for j in i:
if not j:
continue
- target = output_target_map.target(j)
+ target = output_target_map.executable(j)
cmd += [target] if target else [j]
commands += [cmd]
@@ -725,7 +733,7 @@ class ConverterCustomTarget:
return None
def log(self) -> None:
- mlog.log('Custom Target', mlog.bold(self.name))
+ mlog.log('Custom Target', mlog.bold(self.name), '({})'.format(self.cmake_name))
mlog.log(' -- command: ', mlog.bold(str(self.command)))
mlog.log(' -- outputs: ', mlog.bold(str(self.outputs)))
mlog.log(' -- conflict_map: ', mlog.bold(str(self.conflict_map)))
diff --git a/test cases/cmake/8 custom command/subprojects/cmMod/CMakeLists.txt b/test cases/cmake/8 custom command/subprojects/cmMod/CMakeLists.txt
index c7797db..39b19d7 100644
--- a/test cases/cmake/8 custom command/subprojects/cmMod/CMakeLists.txt
+++ b/test cases/cmake/8 custom command/subprojects/cmMod/CMakeLists.txt
@@ -125,5 +125,9 @@ add_custom_target(args_test_cmd
)
add_custom_target(macro_name_cmd COMMAND macro_name)
+# Only executable targets are replaced in the command
+# all other target names are kept as is
+add_custom_target(clang-format COMMAND clang-format -i cmMod.cpp)
+
add_dependencies(cmModLib args_test_cmd tgtCpyTest4)
add_dependencies(args_test_cmd macro_name_cmd;gen;mycpy)