diff options
Diffstat (limited to 'tests/auto/cmake/test_qt_add_ui_common/uic_test')
4 files changed, 172 insertions, 0 deletions
diff --git a/tests/auto/cmake/test_qt_add_ui_common/uic_test/CMakeLists.txt b/tests/auto/cmake/test_qt_add_ui_common/uic_test/CMakeLists.txt new file mode 100644 index 0000000000..b05efd5e4d --- /dev/null +++ b/tests/auto/cmake/test_qt_add_ui_common/uic_test/CMakeLists.txt @@ -0,0 +1,65 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) + +project(UicTest LANGUAGES CXX) + +find_package(Qt6 REQUIRED COMPONENTS Core Widgets Gui) + +set(CMAKE_AUTOMOC ON) + +if (NOT DO_NOT_GENERATE_FILE) + file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mainwindow.cpp" + CONTENT " \ +#include \"${CMAKE_CURRENT_SOURCE_DIR}/../UicBuildFolderLeakageCommon/mainwindow.h\" \n \ +#include \"${MAINWINDOW_UI_PATH}ui_mainwindow.h\" \n \ +MainWindow::MainWindow(QWidget* parent) \n \ + : QMainWindow(parent) \n \ + , ui(new Ui::MainWindow) \n \ +{ \n \ + ui->setupUi(this); \n \ +} \n \ + \n \ +MainWindow::~MainWindow() \n \ +{ \n \ + delete ui; \n \ +} \n \ +") +endif() + +qt_add_executable(example + ../UicBuildFolderLeakageCommon/main.cpp + ../UicBuildFolderLeakageCommon/mainwindow.h + mainwindow.ui +) + +if (${DO_NOT_GENERATE_FILE}) + target_sources(example PRIVATE mainwindow.cpp) +else() + target_sources(example PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/mainwindow.cpp") +endif() + +target_link_libraries(example PRIVATE Qt6::Widgets + Qt6::Core + Qt6::Gui) + +if (NOT UI_NO_CONFIG_OPTIONS) + set(uic_options "$<$<CONFIG:Debug>:-a>") +endif() +qt6_add_ui(example + INCLUDE_PREFIX "${MAINWINDOW_UI_PATH}" + SOURCES "mainwindow.ui" + OPTIONS "${uic_options}") + +if(ADD_NEW_UI) + qt6_add_ui(example INCLUDE_PREFIX "${NEW_UI_PATH}" + SOURCES "subdir/mainwindow.ui" + OPTIONS "${uic_options}") +endif() + +# Enable AUTOUIC after qt6_add_ui() has been called +if (CMAKE_AUTOUIC) + set_property(TARGET example PROPERTY AUTOUIC ON) +endif() + diff --git a/tests/auto/cmake/test_qt_add_ui_common/uic_test/mainwindow.cpp b/tests/auto/cmake/test_qt_add_ui_common/uic_test/mainwindow.cpp new file mode 100644 index 0000000000..1c4b48b49e --- /dev/null +++ b/tests/auto/cmake/test_qt_add_ui_common/uic_test/mainwindow.cpp @@ -0,0 +1,17 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "../UicBuildFolderLeakageCommon/mainwindow.h" +#include "sub1/sub2/sub3/ui_mainwindow.h" + +MainWindow::MainWindow(QWidget* parent) + : QMainWindow(parent) + , ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/tests/auto/cmake/test_qt_add_ui_common/uic_test/mainwindow.ui b/tests/auto/cmake/test_qt_add_ui_common/uic_test/mainwindow.ui new file mode 100644 index 0000000000..4e57b05eac --- /dev/null +++ b/tests/auto/cmake/test_qt_add_ui_common/uic_test/mainwindow.ui @@ -0,0 +1,45 @@ +<?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="QVBoxLayout" name="verticalLayout_2"> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QPushButton" name="pushButton"> + <property name="text"> + <string>PushButton</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>800</width> + <height>23</height> + </rect> + </property> + </widget> + <widget class="QStatusBar" name="statusbar"/> + </widget> + <resources/> + <connections/> +</ui> diff --git a/tests/auto/cmake/test_qt_add_ui_common/uic_test/subdir/mainwindow.ui b/tests/auto/cmake/test_qt_add_ui_common/uic_test/subdir/mainwindow.ui new file mode 100644 index 0000000000..4e57b05eac --- /dev/null +++ b/tests/auto/cmake/test_qt_add_ui_common/uic_test/subdir/mainwindow.ui @@ -0,0 +1,45 @@ +<?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="QVBoxLayout" name="verticalLayout_2"> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QPushButton" name="pushButton"> + <property name="text"> + <string>PushButton</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>800</width> + <height>23</height> + </rect> + </property> + </widget> + <widget class="QStatusBar" name="statusbar"/> + </widget> + <resources/> + <connections/> +</ui> |