CMake: Do not file(GENERATE) illegal genexes in .pri file generation

We must filter out expressions of the form $<TARGET_PROPERTY:name>, because
1. They cannot be used in file(GENERATE) content.
2. They refer to the consuming target we have no access to here.

The CMake error
  Error evaluating generator expression:

    $<TARGET_PROPERTY:QT_PLUGIN_CLASS_NAME>
was triggered when building the UiPlugin module of qttools.

Change-Id: Idf639be50120b94d68a70965604e6f1ef72edc9b
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann 2020-06-19 14:45:35 +02:00
parent 47a4e6a949
commit 7f2ff4ffce

View File

@ -835,6 +835,11 @@ function(qt_generate_module_pri_file target)
# will compute the transitive list of all defines for a module (so Gui would get Core
#defines too). Instead query just the public defines on the target.
get_target_property(target_defines "${target}" INTERFACE_COMPILE_DEFINITIONS)
# We must filter out expressions of the form $<TARGET_PROPERTY:name>, because
# 1. They cannot be used in file(GENERATE) content.
# 2. They refer to the consuming target we have no access to here.
list(FILTER target_defines EXCLUDE REGEX "\\$<TARGET_PROPERTY:[^,>]+>")
list(JOIN target_defines " " joined_target_defines)
file(GENERATE