cmake: Init uic only if Qt::Widgets is a target

Otherwise we get errors like the following in non-gui projects:
  Error evaluating generator expression:
    $<TARGET_FILE:Qt6::uic>
  No target "Qt6::uic"

Change-Id: I8a3a6f8ec5e5c1c3d1f73369c5739a321c64bfbb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
bb10
Joerg Bornemann 2019-09-20 14:18:17 +02:00 committed by Alexandru Croitor
parent be3287d779
commit d8647910bc
1 changed files with 4 additions and 1 deletions

View File

@ -175,7 +175,10 @@ macro(qt_examples_build_end)
get_all_targets(targets "${CMAKE_CURRENT_SOURCE_DIR}")
foreach(target ${targets})
qt_autogen_tools(${target} ENABLE_AUTOGEN_TOOLS "moc" "uic" "rcc")
qt_autogen_tools(${target} ENABLE_AUTOGEN_TOOLS "moc" "rcc")
if(TARGET Qt::Widgets)
qt_autogen_tools(${target} ENABLE_AUTOGEN_TOOLS "uic")
endif()
endforeach()
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ${BACKUP_CMAKE_FIND_ROOT_PATH_MODE_PACKAGE})