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
This commit is contained in:
parent
27647acc6c
commit
debc4d3906
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
|
@ -8,16 +8,10 @@ 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
|
||||
main.cpp
|
||||
ui/widget.cpp
|
||||
ui/widget.h
|
||||
ui/widget.ui
|
||||
)
|
||||
|
||||
target_link_libraries(example PRIVATE Qt${with_qt_version}::Widgets
|
@ -1,11 +1,11 @@
|
||||
#include <QApplication>
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "ui/widget.h"
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
Widget w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
15
Tests/RunCMake/Autogen_6/incremental_build/ui/widget.cpp
Normal file
15
Tests/RunCMake/Autogen_6/incremental_build/ui/widget.cpp
Normal file
@ -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;
|
||||
}
|
23
Tests/RunCMake/Autogen_6/incremental_build/ui/widget.h
Normal file
23
Tests/RunCMake/Autogen_6/incremental_build/ui/widget.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef WIDGET_H
|
||||
#define WIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
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
|
19
Tests/RunCMake/Autogen_6/incremental_build/ui/widget.ui
Normal file
19
Tests/RunCMake/Autogen_6/incremental_build/ui/widget.ui
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Widget</class>
|
||||
<widget class="QWidget" name="Widget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Widget</string>
|
||||
</property>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -1,25 +0,0 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#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;
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
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
|
@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout"/>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -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);
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
#ifndef WIDGET1_H
|
||||
#define WIDGET1_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
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
|
@ -1,52 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Widget1</class>
|
||||
<widget class="QWidget" name="Widget1">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Input:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>OnTextChanged:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="OnTextChanged">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -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);
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
#ifndef WIDGET2_H
|
||||
#define WIDGET2_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
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
|
@ -1,45 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Widget2</class>
|
||||
<widget class="QWidget" name="Widget2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Input:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>OnTextChanged:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="OnTextChanged">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue
Block a user