summaryrefslogtreecommitdiffstats
path: root/tests/auto/cmake/test_qt_add_ui_8/CMakeLists.txt
blob: f8d0763d3553df9ea3c5b24763588e832deffa75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause

cmake_minimum_required(VERSION 3.16)
project(test)

include(../test_qt_add_ui_common/RunCMake.cmake)
include(../test_qt_add_ui_common/functions.cmake)

get_generators(generators)

foreach(generator IN ITEMS ${generators})
    message(STATUS "Running tests for generator: ${generator}")
    is_multi_config(${generator} multi_config_out)
    # A CI test fails with the below condition. So, we are running the test
    # only for the Debug configuration.
    if ("${generator}" MATCHES "Xcode" AND
        CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
        set(configs "Debug")
    elseif(multi_config_out)
        set(configs "Debug" "Release")
    else()
        set(configs "single_config")
    endif()

    foreach(config IN ITEMS ${configs})
        if("${config}" STREQUAL "single_config")
            set(config_path "")
            set(config_arg "")
        else()
            set(config_path "_${config}")
            set(config_arg "${config}")
        endif()

    # Test case: ui_mainwindow.h is included as
    # "sub1/sub2/sub3/../../../../../../../../../../../../../ui_mainwindow.h".
    # Test case: mainwindow1.ui file is touched after the first build.
    # Expect 1: Successful build without the double build issue.
    # Expect 2: No build folder leakage and generation of the
    # "_/_/_/_/_/_/_/_/_/_/sub1/sub2/sub3" folder in ${hash_folder}/include.
    string(CONCAT test_ui_file "${CMAKE_CURRENT_SOURCE_DIR}/../"
        "test_qt_add_ui_common/uic_test/mainwindow.ui")
    generate_hash_folder("example" "${test_ui_file}" hash_folder)
    string(CONCAT test_build_dir "${CMAKE_CURRENT_BINARY_DIR}/"
        "UicBuildLeak_subFolderGen_complex${config_path}-build")
    string(CONCAT test_additional_args "-DMAINWINDOW_UI_PATH=sub1/sub2/sub3"
        "/../../../../../../../../../../../../../")
    string(CONCAT test_file_to_touch "${CMAKE_CURRENT_SOURCE_DIR}/../"
        "test_qt_add_ui_common/uic_test/mainwindow.ui")
    string(CONCAT test_file_to_check "${test_build_dir}/.qt/${hash_folder}/"
        "${config_arg}/ui_mainwindow.h")
    string(CONCAT test_folder_to_check "${test_build_dir}/.qt/${hash_folder}/"
        "${config_arg}/_/_/_/_/_/_/_/_/_/_/sub1/sub2/sub3")
    incremental_build_test(
        TEST_NAME UicBuildLeak_subFolderGen_complex
        SOURCE_DIR
            "${CMAKE_CURRENT_SOURCE_DIR}/../test_qt_add_ui_common/uic_test"
        BUILD_DIR "${test_build_dir}"
        CONFIG "${config_arg}"
        GENERATOR "${generator}"
        ADDITIONAL_ARGS "${test_additional_args}"
        FILE_TO_TOUCH "${test_file_to_touch}"
        FILE_TO_CHECK "${test_file_to_check}"
        FOLDER_TO_CHECK "${test_folder_to_check}"
    )
    endforeach()
endforeach()