CMake: Fix qt_add_ui for CMake 3.16

qt_add_ui failed for CMake 3.16 and the Ninja generator on Linux,
because it generated empty commands like
   ... && "" && "" && "" && ""
for targets that don't have AUTOUIC set.

Adjust the generator expressions for those commands to generate the
"cmake -E true" command instead of the empty string.

Change-Id: I03c9eb2e8f14685bccadf4eb74f309bcf152c01b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit e98517564fa0a87ff030deb1cb05ec51aa231294)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Joerg Bornemann 2024-08-07 16:17:53 +02:00 committed by Qt Cherry-pick Bot
parent 7c1e2072f5
commit e2c02c5b20

View File

@ -290,20 +290,24 @@ function(qt6_add_ui target)
"${CMAKE_CURRENT_BINARY_DIR}/${target}_autogen"
COMMAND ${CMAKE_COMMAND} -E touch ${ui_property_check_dummy_file}
COMMAND
"$<$<BOOL:$<TARGET_PROPERTY:${target},AUTOUIC>>:${CMAKE_COMMAND}\
;-E;echo;${error_message_1}>"
"$<IF:$<BOOL:$<TARGET_PROPERTY:${target},AUTOUIC>>,\
${CMAKE_COMMAND};-E;echo;${error_message_1},\
${CMAKE_COMMAND};-E;true>"
COMMAND
"$<$<BOOL:$<TARGET_PROPERTY:${target},AUTOUIC>>:${CMAKE_COMMAND}\
;-E;echo;${error_message_2}>"
"$<IF:$<BOOL:$<TARGET_PROPERTY:${target},AUTOUIC>>,\
${CMAKE_COMMAND};-E;echo;${error_message_2},\
${CMAKE_COMMAND};-E;true>"
# Remove the dummy file so that the error message is shown until
# the AUTOUIC is disabled. Otherwise, the error message is shown
# only once when the AUTOUIC is enabled with Visual Studio generator.
COMMAND
"$<$<BOOL:$<TARGET_PROPERTY:${target},AUTOUIC>>:${CMAKE_COMMAND}\
;-E;remove;${ui_property_check_dummy_file}>"
"$<IF:$<BOOL:$<TARGET_PROPERTY:${target},AUTOUIC>>,\
${CMAKE_COMMAND};-E;remove;${ui_property_check_dummy_file},\
${CMAKE_COMMAND};-E;true>"
COMMAND
"$<$<BOOL:$<TARGET_PROPERTY:${target},AUTOUIC>>:${CMAKE_COMMAND}\
;-E;false>"
"$<IF:$<BOOL:$<TARGET_PROPERTY:${target},AUTOUIC>>,\
${CMAKE_COMMAND};-E;false,\
${CMAKE_COMMAND};-E;true>"
COMMAND_EXPAND_LISTS
VERBATIM)