From 545b84b93c0b84a08c037e7b70deec3400d1f827 Mon Sep 17 00:00:00 2001 From: Orkun Tokdemir Date: Tue, 21 Nov 2023 10:46:30 +0100 Subject: CMake: Add `qt_add_ui` API This commit introduces a new `qt_add_ui` CMake API to be used instead of AUTOUIC, due to several hard-to-fix bugs it has. * Resolves the issue where Ninja required two passes to correctly build `.ui` files. * Avoids build folder leakage, in contrast to `AUTOUIC` * Prevents unnecessary recompilation of unchanged source files when a `.ui` file is modified with Ninja. * Since `qt_add_ui` does not scan source files, it provides a faster build than `AUTOUIC`. These changes aim to streamline the build process and improve efficiency when working with `.ui` files. This addresses the following issues: https://gitlab.kitware.com/cmake/cmake/-/issues/16776 https://gitlab.kitware.com/cmake/cmake/-/issues/25436 https://gitlab.kitware.com/cmake/cmake/-/issues/25195 Task-number: QTBUG-110369 Fixes: QTBUG-114563 Change-Id: I34cd3df70542becf6e08502f0cbcd1c11eeeadd6 Reviewed-by: Alexandru Croitor --- .../doc/snippets/cmake-macros/examples.cmake | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/widgets/doc/snippets/cmake-macros/examples.cmake') diff --git a/src/widgets/doc/snippets/cmake-macros/examples.cmake b/src/widgets/doc/snippets/cmake-macros/examples.cmake index 3c58509fdf9..7d0023aed4a 100644 --- a/src/widgets/doc/snippets/cmake-macros/examples.cmake +++ b/src/widgets/doc/snippets/cmake-macros/examples.cmake @@ -6,3 +6,30 @@ set(SOURCES mainwindow.cpp main.cpp) qt_wrap_ui(SOURCES mainwindow.ui) qt_add_executable(myapp ${SOURCES}) #! [qt_wrap_ui] + +#! [qt6_add_ui_1] +qt_add_executable(myapp mainwindow.cpp main.cpp) +qt6_add_ui(myapp SOURCES mainwindow.ui) +#! [qt6_add_ui_1] + +#! [qt6_add_ui_2] +qt_add_executable(myapp mainwindow.cpp main.cpp) +qt6_add_ui(myapp INCLUDE_PREFIX "src/files" SOURCES mainwindow.ui) +#! [qt6_add_ui_2] + +#! [qt6_add_ui_3] +qt_add_executable(myapp widget1.cpp widget2.cpp main.cpp) +qt6_add_ui(myapp INCLUDE_PREFIX "src/files" SOURCES widget1.ui widget2.ui) +#! [qt6_add_ui_3] + +#! [qt6_add_ui_4] +qt_add_executable(myapp widget1.cpp widget2.cpp main.cpp) +qt6_add_ui(myapp INCLUDE_PREFIX "src/files" + SOURCES "my_ui_files_1/widget1.ui" "my_ui_files_2/widget2.ui") +#! [qt6_add_ui_4] + +#! [qt6_add_ui_5] +qt_add_executable(myapp widget1.cpp widget2.cpp main.cpp) +qt6_add_ui(myapp INCLUDE_PREFIX "src/files_1" SOURCES "my_ui_files/widget1.ui") +qt6_add_ui(myapp INCLUDE_PREFIX "src/files_2" SOURCES "my_ui_files/widget2.ui") +#! [qt6_add_ui_5] -- cgit v1.2.3