| 1 |
# Copyright (C) 2024 The Qt Company Ltd. |
| 2 |
# SPDX-License-Identifier: BSD-3-Clause |
| 3 |
|
| 4 |
cmake_minimum_required(VERSION 3.16) |
| 5 |
project(test) |
| 6 |
|
| 7 |
include(../test_qt_add_ui_common/RunCMake.cmake) |
| 8 |
include(../test_qt_add_ui_common/functions.cmake) |
| 9 |
|
| 10 |
get_generators(generators) |
| 11 |
|
| 12 |
foreach(generator IN ITEMS ${generators}) |
| 13 |
message(STATUS "Running tests for generator: ${generator}") |
| 14 |
is_multi_config(${generator} multi_config_out) |
| 15 |
# A CI test fails with the below condition. So, we are running the test |
| 16 |
# only for the Debug configuration. |
| 17 |
if ("${generator}" MATCHES "Xcode" AND |
| 18 |
CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") |
| 19 |
set(configs "Debug") |
| 20 |
elseif(multi_config_out) |
| 21 |
set(configs "Debug" "Release") |
| 22 |
else() |
| 23 |
set(configs "single_config") |
| 24 |
endif() |
| 25 |
|
| 26 |
foreach(config IN ITEMS ${configs}) |
| 27 |
if("${config}" STREQUAL "single_config") |
| 28 |
set(config_path "") |
| 29 |
set(config_arg "") |
| 30 |
else() |
| 31 |
set(config_path "_${config}") |
| 32 |
set(config_arg "${config}") |
| 33 |
endif() |
| 34 |
|
| 35 |
# Test case: ui_mainwindow.h is included as |
| 36 |
# "sub1/sub2/sub3/../../../../../../../../../../../../../ui_mainwindow.h". |
| 37 |
# Test case: mainwindow.ui file is touched after the first build. |
| 38 |
# Expect 1: Successful build without the double build issue. |
| 39 |
# Expect 2: No build folder leakage and generation of the |
| 40 |
# "_/_/_/_/_/_/_/_/_/_/sub1/sub2/sub3" folder in ${hash_folder}/include. |
| 41 |
string(CONCAT test_ui_file "${CMAKE_CURRENT_SOURCE_DIR}/../" |
| 42 |
"test_qt_add_ui_common/uic_test/mainwindow.ui") |
| 43 |
generate_hash_folder("example" "${test_ui_file}" hash_folder) |
| 44 |
string(CONCAT test_build_dir "${CMAKE_CURRENT_BINARY_DIR}/" |
| 45 |
"UicBuildLeak_subFolderGen_complex${config_path}-build") |
| 46 |
string(CONCAT test_additional_args "-DMAINWINDOW_UI_PATH=sub1/sub2/sub3" |
| 47 |
"/../../../../../../../../../../../../../") |
| 48 |
string(CONCAT test_file_to_touch "${CMAKE_CURRENT_SOURCE_DIR}/../" |
| 49 |
"test_qt_add_ui_common/uic_test/mainwindow.ui") |
| 50 |
string(CONCAT test_file_to_check "${test_build_dir}/.qt/${hash_folder}/" |
| 51 |
"${config_arg}/ui_mainwindow.h") |
| 52 |
string(CONCAT test_folder_to_check "${test_build_dir}/.qt/${hash_folder}/" |
| 53 |
"${config_arg}/_/_/_/_/_/_/_/_/_/_/sub1/sub2/sub3") |
| 54 |
incremental_build_test( |
| 55 |
TEST_NAME UicBuildLeak_subFolderGen_complex |
| 56 |
SOURCE_DIR |
| 57 |
"${CMAKE_CURRENT_SOURCE_DIR}/../test_qt_add_ui_common/uic_test" |
| 58 |
BUILD_DIR "${test_build_dir}" |
| 59 |
CONFIG "${config_arg}" |
| 60 |
GENERATOR "${generator}" |
| 61 |
ADDITIONAL_ARGS "${test_additional_args}" |
| 62 |
FILE_TO_TOUCH "${test_file_to_touch}" |
| 63 |
FILE_TO_CHECK "${test_file_to_check}" |
| 64 |
FOLDER_TO_CHECK "${test_folder_to_check}" |
| 65 |
) |
| 66 |
endforeach() |
| 67 |
endforeach() |