From debc4d39069faecba2cf8c6263bb7d974c3bf34b Mon Sep 17 00:00:00 2001 From: Orkun Tokdemir Date: Mon, 2 Dec 2024 12:42:26 +0100 Subject: Autogen: Revert adding ui files to byproducts of the timestamp target When `ui_` include directives have different paths than `CMakeLists.txt`, the dependency graph is not generated correctly. This is the root cause of #16776. However, when #26135 was fixed by commit 5363bebc1e (Autogen: Fix compilation of unchanged source files, 2024-07-16, v3.31.0-rc1~328^2), it made #16776 worse: the build is always dirty. Revert the fix for now. Fixes: #26485 Issue: #26135 Issue: #25436 --- Source/cmQtAutoGenInitializer.cxx | 22 ++------- Tests/RunCMake/Autogen_6/RunCMakeTest.cmake | 27 ++++++----- .../Autogen_6/incremental_build/CMakeLists.txt | 19 ++++++++ .../RunCMake/Autogen_6/incremental_build/main.cpp | 11 +++++ .../Autogen_6/incremental_build/ui/widget.cpp | 15 +++++++ .../Autogen_6/incremental_build/ui/widget.h | 23 ++++++++++ .../Autogen_6/incremental_build/ui/widget.ui | 19 ++++++++ .../Autogen_6/multi_ui_files/CMakeLists.txt | 25 ----------- .../RunCMake/Autogen_6/multi_ui_files/src/main.cpp | 11 ----- .../Autogen_6/multi_ui_files/src/mainwindow.cpp | 25 ----------- .../Autogen_6/multi_ui_files/src/mainwindow.h | 22 --------- .../Autogen_6/multi_ui_files/src/mainwindow.ui | 33 -------------- .../Autogen_6/multi_ui_files/src/widget1.cpp | 22 --------- .../Autogen_6/multi_ui_files/src/widget1.h | 23 ---------- .../Autogen_6/multi_ui_files/src/widget1.ui | 52 ---------------------- .../Autogen_6/multi_ui_files/src/widget2.cpp | 22 --------- .../Autogen_6/multi_ui_files/src/widget2.h | 24 ---------- .../Autogen_6/multi_ui_files/src/widget2.ui | 45 ------------------- 18 files changed, 103 insertions(+), 337 deletions(-) create mode 100644 Tests/RunCMake/Autogen_6/incremental_build/CMakeLists.txt create mode 100644 Tests/RunCMake/Autogen_6/incremental_build/main.cpp create mode 100644 Tests/RunCMake/Autogen_6/incremental_build/ui/widget.cpp create mode 100644 Tests/RunCMake/Autogen_6/incremental_build/ui/widget.h create mode 100644 Tests/RunCMake/Autogen_6/incremental_build/ui/widget.ui delete mode 100644 Tests/RunCMake/Autogen_6/multi_ui_files/CMakeLists.txt delete mode 100644 Tests/RunCMake/Autogen_6/multi_ui_files/src/main.cpp delete mode 100644 Tests/RunCMake/Autogen_6/multi_ui_files/src/mainwindow.cpp delete mode 100644 Tests/RunCMake/Autogen_6/multi_ui_files/src/mainwindow.h delete mode 100644 Tests/RunCMake/Autogen_6/multi_ui_files/src/mainwindow.ui delete mode 100644 Tests/RunCMake/Autogen_6/multi_ui_files/src/widget1.cpp delete mode 100644 Tests/RunCMake/Autogen_6/multi_ui_files/src/widget1.h delete mode 100644 Tests/RunCMake/Autogen_6/multi_ui_files/src/widget1.ui delete mode 100644 Tests/RunCMake/Autogen_6/multi_ui_files/src/widget2.cpp delete mode 100644 Tests/RunCMake/Autogen_6/multi_ui_files/src/widget2.h delete mode 100644 Tests/RunCMake/Autogen_6/multi_ui_files/src/widget2.ui diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index b75a574..c9dd154 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1340,25 +1340,9 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() } if (this->Uic.Enabled) { - auto const useAdvancedUicGraph = [this]() -> bool { - if (this->MultiConfig && this->GlobalGen->IsNinja()) { - return this->UseBetterGraph; - } - return true; - }(); - if (useAdvancedUicGraph) { - // Make all ui_*.h files byproducts of the ${target}_autogen/timestamp - // custom command if the generation of depfile is enabled. - auto& byProducts = useDepfile ? timestampByproducts : autogenByproducts; - for (auto const& file : this->Uic.UiHeaders) { - this->AddGeneratedSource(file.first, this->Uic); - byProducts.push_back(file.second); - } - } else { - for (auto const& file : this->Uic.UiHeaders) { - this->AddGeneratedSource(file.first, this->Uic); - autogenByproducts.push_back(file.second); - } + for (auto const& file : this->Uic.UiHeaders) { + this->AddGeneratedSource(file.first, this->Uic); + autogenByproducts.push_back(file.second); } } diff --git a/Tests/RunCMake/Autogen_6/RunCMakeTest.cmake b/Tests/RunCMake/Autogen_6/RunCMakeTest.cmake index 66514f9..65d58a9 100644 --- a/Tests/RunCMake/Autogen_6/RunCMakeTest.cmake +++ b/Tests/RunCMake/Autogen_6/RunCMakeTest.cmake @@ -1,3 +1,4 @@ + include(RunCMake) include(Autogen_common/utils) @@ -6,23 +7,22 @@ if (DEFINED with_qt_version) -Dwith_qt_version=${with_qt_version} "-DQt${with_qt_version}_DIR:PATH=${Qt${with_qt_version}_DIR}" "-DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH}" - "-DCMAKE_AUTOGEN_BETTER_GRAPH_MULTI_CONFIG=ON" ) if (QtCore_VERSION VERSION_GREATER_EQUAL 5.15.0) macro(set_test_variables_for_unwanted_builds) if (RunCMake_GENERATOR MATCHES "Ninja") - set(RunCMake_TEST_NOT_EXPECT_stdout "widget2.cpp.o.d|mainwindow.cpp.o.d") + set(RunCMake_TEST_EXPECT_stdout "ninja: no work to do.") elseif (RunCMake_GENERATOR MATCHES "Make") - set(RunCMake_TEST_NOT_EXPECT_stdout "Building CXX object multi_ui_files/CMakeFiles/example.dir/src/widget2.cpp.o|\ - Building CXX object multi_ui_files/CMakeFiles/example.dir/src/mainwindow.cpp.o") + set(RunCMake_TEST_NOT_EXPECT_stdout "Building CXX object multi_ui_files/CMakeFiles/example.dir/src/main.cpp.o|\ + Building CXX object multi_ui_files/CMakeFiles/example.dir/src/widget.cpp.o") elseif (RunCMake_GENERATOR MATCHES "Visual Studio") - set(RunCMake_TEST_NOT_EXPECT_stdout "widget2.cpp|mainwindow.cpp") + set(RunCMake_TEST_NOT_EXPECT_stdout "widget.cpp") elseif (RunCMake_GENERATOR MATCHES "Xcode") - set(RunCMake_TEST_NOT_EXPECT_stdout "widget2.cpp|mainwindow.cpp") + set(RunCMake_TEST_NOT_EXPECT_stdout "widget.cpp") endif() endmacro() - function(uic_build_test test_name binary_dir source_dir file_to_touch test_config) + function(uic_incremental_build_test test_name binary_dir source_dir test_config) set(RunCMake_TEST_BINARY_DIR ${binary_dir}) set(RunCMake_TEST_SOURCE_DIR ${source_dir}) @@ -39,13 +39,14 @@ if (DEFINED with_qt_version) endif() run_cmake_with_options(${test_name} ${RunCMake_TEST_OPTIONS} ${config_arg}) set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_VARIANT_DESCRIPTION "${RunCMake_TEST_VARIANT_DESCRIPTION}-First build") + run_cmake_command("${test_name}-build" ${CMAKE_COMMAND} --build . ${test_verbose_arg} ${multiconfig_config_arg}) + set(RunCMake_TEST_VARIANT_DESCRIPTION "${config_desc}-Second build") run_cmake_command("${test_name}-build" ${CMAKE_COMMAND} --build . ${test_verbose_arg} ${multiconfig_config_arg}) - file(TOUCH ${file_to_touch}) - set(RunCMake_TEST_VARIANT_DESCRIPTION "${config_desc}-first_build_after_touching") + set(RunCMake_TEST_VARIANT_DESCRIPTION "${config_desc}-No files were built on the third build") set_test_variables_for_unwanted_builds() run_cmake_command("${test_name}-build" ${CMAKE_COMMAND} --build . ${test_verbose_arg} ${multiconfig_config_arg}) - message(STATUS "${test_name}-build${config_desc}-Only build files that were touched were built - PASSED") endfunction() if(RunCMake_GENERATOR MATCHES "Make|Ninja|Visual Studio|Xcode") @@ -60,11 +61,9 @@ if (DEFINED with_qt_version) set(config_desc "-${config}") endif() - uic_build_test(multi_ui_files_touch_ui ${RunCMake_BINARY_DIR}/multi_ui_files_touch_ui${config_desc}-build - ${RunCMake_SOURCE_DIR}/multi_ui_files ${RunCMake_SOURCE_DIR}/multi_ui_files/src/widget1.ui ${config}) + uic_incremental_build_test(incremental_build_test ${RunCMake_BINARY_DIR}/incremental_build${config_desc}-build + ${RunCMake_SOURCE_DIR}/incremental_build ${config}) - uic_build_test(multi_ui_files_touch_cpp ${RunCMake_BINARY_DIR}/multi_ui_files_touch_cpp${config_desc}-build - ${RunCMake_SOURCE_DIR}/multi_ui_files ${RunCMake_SOURCE_DIR}/multi_ui_files/src/widget1.cpp ${config}) endforeach() endif() endif() diff --git a/Tests/RunCMake/Autogen_6/incremental_build/CMakeLists.txt b/Tests/RunCMake/Autogen_6/incremental_build/CMakeLists.txt new file mode 100644 index 0000000..1796b8f --- /dev/null +++ b/Tests/RunCMake/Autogen_6/incremental_build/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.10) + +project(UicIncrementalBuild LANGUAGES CXX) + +find_package(Qt${with_qt_version} REQUIRED COMPONENTS Core Widgets Gui) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOUIC ON) + +add_executable(example + main.cpp + ui/widget.cpp + ui/widget.h + ui/widget.ui +) + +target_link_libraries(example PRIVATE Qt${with_qt_version}::Widgets + Qt${with_qt_version}::Core + Qt${with_qt_version}::Gui) diff --git a/Tests/RunCMake/Autogen_6/incremental_build/main.cpp b/Tests/RunCMake/Autogen_6/incremental_build/main.cpp new file mode 100644 index 0000000..c15abe4 --- /dev/null +++ b/Tests/RunCMake/Autogen_6/incremental_build/main.cpp @@ -0,0 +1,11 @@ +#include + +#include "ui/widget.h" + +int main(int argc, char* argv[]) +{ + QApplication a(argc, argv); + Widget w; + w.show(); + return a.exec(); +} diff --git a/Tests/RunCMake/Autogen_6/incremental_build/ui/widget.cpp b/Tests/RunCMake/Autogen_6/incremental_build/ui/widget.cpp new file mode 100644 index 0000000..4de4ed2 --- /dev/null +++ b/Tests/RunCMake/Autogen_6/incremental_build/ui/widget.cpp @@ -0,0 +1,15 @@ +#include "widget.h" + +#include "./ui_widget.h" + +Widget::Widget(QWidget* parent) + : QWidget(parent) + , ui(new Ui::Widget) +{ + ui->setupUi(this); +} + +Widget::~Widget() +{ + delete ui; +} diff --git a/Tests/RunCMake/Autogen_6/incremental_build/ui/widget.h b/Tests/RunCMake/Autogen_6/incremental_build/ui/widget.h new file mode 100644 index 0000000..2243ffe --- /dev/null +++ b/Tests/RunCMake/Autogen_6/incremental_build/ui/widget.h @@ -0,0 +1,23 @@ +#ifndef WIDGET_H +#define WIDGET_H + +#include + +QT_BEGIN_NAMESPACE +namespace Ui { +class Widget; +} +QT_END_NAMESPACE + +class Widget : public QWidget +{ + Q_OBJECT + +public: + Widget(QWidget* parent = nullptr); + ~Widget(); + +private: + Ui::Widget* ui; +}; +#endif // WIDGET_H diff --git a/Tests/RunCMake/Autogen_6/incremental_build/ui/widget.ui b/Tests/RunCMake/Autogen_6/incremental_build/ui/widget.ui new file mode 100644 index 0000000..b90248d --- /dev/null +++ b/Tests/RunCMake/Autogen_6/incremental_build/ui/widget.ui @@ -0,0 +1,19 @@ + + + Widget + + + + 0 + 0 + 800 + 600 + + + + Widget + + + + + diff --git a/Tests/RunCMake/Autogen_6/multi_ui_files/CMakeLists.txt b/Tests/RunCMake/Autogen_6/multi_ui_files/CMakeLists.txt deleted file mode 100644 index a4f7206..0000000 --- a/Tests/RunCMake/Autogen_6/multi_ui_files/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -cmake_minimum_required(VERSION 3.10) - -project(UicIncrementalBuild LANGUAGES CXX) - -find_package(Qt${with_qt_version} REQUIRED COMPONENTS Core Widgets Gui) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTOUIC ON) - -add_executable(example - src/mainwindow.ui - src/widget1.ui - src/widget2.ui - src/mainwindow.h - src/widget1.h - src/widget2.h - src/main.cpp - src/mainwindow.cpp - src/widget1.cpp - src/widget2.cpp -) - -target_link_libraries(example PRIVATE Qt${with_qt_version}::Widgets - Qt${with_qt_version}::Core - Qt${with_qt_version}::Gui) diff --git a/Tests/RunCMake/Autogen_6/multi_ui_files/src/main.cpp b/Tests/RunCMake/Autogen_6/multi_ui_files/src/main.cpp deleted file mode 100644 index 8d76ad9..0000000 --- a/Tests/RunCMake/Autogen_6/multi_ui_files/src/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include - -#include "mainwindow.h" - -int main(int argc, char* argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/Tests/RunCMake/Autogen_6/multi_ui_files/src/mainwindow.cpp b/Tests/RunCMake/Autogen_6/multi_ui_files/src/mainwindow.cpp deleted file mode 100644 index eb3d366..0000000 --- a/Tests/RunCMake/Autogen_6/multi_ui_files/src/mainwindow.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "mainwindow.h" - -#include - -#include "src/ui_mainwindow.h" -#include "widget1.h" - -MainWindow::MainWindow(QWidget* parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) -{ - ui->setupUi(this); - auto layout = new QVBoxLayout; - layout->addWidget(new Widget1); - - QWidget* w = new QWidget(this); - w->setLayout(layout); - - setCentralWidget(w); -} - -MainWindow::~MainWindow() -{ - delete ui; -} diff --git a/Tests/RunCMake/Autogen_6/multi_ui_files/src/mainwindow.h b/Tests/RunCMake/Autogen_6/multi_ui_files/src/mainwindow.h deleted file mode 100644 index 3e64459..0000000 --- a/Tests/RunCMake/Autogen_6/multi_ui_files/src/mainwindow.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -QT_BEGIN_NAMESPACE -namespace Ui { -class MainWindow; -} -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT -public: - MainWindow(QWidget* parent = nullptr); - ~MainWindow(); - -private: - Ui::MainWindow* ui; -}; -#endif // MAINWINDOW_H diff --git a/Tests/RunCMake/Autogen_6/multi_ui_files/src/mainwindow.ui b/Tests/RunCMake/Autogen_6/multi_ui_files/src/mainwindow.ui deleted file mode 100644 index 828d7c1..0000000 --- a/Tests/RunCMake/Autogen_6/multi_ui_files/src/mainwindow.ui +++ /dev/null @@ -1,33 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - - - - 0 - 0 - 800 - 22 - - - - - - - - diff --git a/Tests/RunCMake/Autogen_6/multi_ui_files/src/widget1.cpp b/Tests/RunCMake/Autogen_6/multi_ui_files/src/widget1.cpp deleted file mode 100644 index 05657ce..0000000 --- a/Tests/RunCMake/Autogen_6/multi_ui_files/src/widget1.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "widget1.h" - -#include "src/ui_widget1.h" - -Widget1::Widget1(QWidget* parent) - : QWidget(parent) - , ui(new Ui::Widget1) -{ - ui->setupUi(this); - connect(ui->lineEdit, SIGNAL(textChanged(const QString&)), this, - SLOT(onTextChanged(const QString&))); -} - -Widget1::~Widget1() -{ - delete ui; -} - -void Widget1::onTextChanged(const QString& text) -{ - ui->OnTextChanged->setText(text); -} diff --git a/Tests/RunCMake/Autogen_6/multi_ui_files/src/widget1.h b/Tests/RunCMake/Autogen_6/multi_ui_files/src/widget1.h deleted file mode 100644 index 8c28d6d..0000000 --- a/Tests/RunCMake/Autogen_6/multi_ui_files/src/widget1.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef WIDGET1_H -#define WIDGET1_H - -#include - -namespace Ui { -class Widget1; -} - -class Widget1 : public QWidget -{ - Q_OBJECT -public: - explicit Widget1(QWidget* parent = nullptr); - ~Widget1(); -public slots: - void onTextChanged(const QString& text); - -private: - Ui::Widget1* ui; -}; - -#endif // WIDGET1_H diff --git a/Tests/RunCMake/Autogen_6/multi_ui_files/src/widget1.ui b/Tests/RunCMake/Autogen_6/multi_ui_files/src/widget1.ui deleted file mode 100644 index db0c58d..0000000 --- a/Tests/RunCMake/Autogen_6/multi_ui_files/src/widget1.ui +++ /dev/null @@ -1,52 +0,0 @@ - - - Widget1 - - - - 0 - 0 - 400 - 300 - - - - Form - - - - - - Input: - - - - - - - - - - OnTextChanged: - - - - - - - - - - - - - - TextLabel - - - - - - - - diff --git a/Tests/RunCMake/Autogen_6/multi_ui_files/src/widget2.cpp b/Tests/RunCMake/Autogen_6/multi_ui_files/src/widget2.cpp deleted file mode 100644 index 7f4bbaf..0000000 --- a/Tests/RunCMake/Autogen_6/multi_ui_files/src/widget2.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "widget2.h" - -#include "src/ui_widget2.h" - -Widget2::Widget2(QWidget* parent) - : QWidget(parent) - , ui(new Ui::Widget2) -{ - ui->setupUi(this); - connect(ui->lineEdit, SIGNAL(textChanged(const QString&)), this, - SLOT(onTextChanged(const QString&))); -} - -Widget2::~Widget2() -{ - delete ui; -} - -void Widget2::onTextChanged(const QString& text) -{ - ui->OnTextChanged->setText(text); -} diff --git a/Tests/RunCMake/Autogen_6/multi_ui_files/src/widget2.h b/Tests/RunCMake/Autogen_6/multi_ui_files/src/widget2.h deleted file mode 100644 index 41d7e1f..0000000 --- a/Tests/RunCMake/Autogen_6/multi_ui_files/src/widget2.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef WIDGET2_H -#define WIDGET2_H - -#include - -namespace Ui { -class Widget2; -} - -class Widget2 : public QWidget -{ - Q_OBJECT - -public: - explicit Widget2(QWidget* parent = nullptr); - ~Widget2(); -public slots: - void onTextChanged(const QString& text); - -private: - Ui::Widget2* ui; -}; - -#endif // WIDGET2_H diff --git a/Tests/RunCMake/Autogen_6/multi_ui_files/src/widget2.ui b/Tests/RunCMake/Autogen_6/multi_ui_files/src/widget2.ui deleted file mode 100644 index facf467..0000000 --- a/Tests/RunCMake/Autogen_6/multi_ui_files/src/widget2.ui +++ /dev/null @@ -1,45 +0,0 @@ - - - Widget2 - - - - 0 - 0 - 400 - 300 - - - - Form - - - - - - Input: - - - - - - - - - - OnTextChanged: - - - - - - - - - - - - - - - -- cgit v0.12