summaryrefslogtreecommitdiffstats
path: root/Tests/QtAutogen/GlobalAutogenTarget/CMakeLists.txt
blob: e020673eef5d60f752dc84e1cde87e6d31870a43 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
cmake_minimum_required(VERSION 3.12)
project(GlobalAutogenTarget)
include("../AutogenTest.cmake")

# This tests
# CMAKE_GLOBAL_AUTOGEN_TARGET,
# CMAKE_GLOBAL_AUTORCC_TARGET,
# CMAKE_GLOBAL_AUTOGEN_TARGET_NAME and
# CMAKE_GLOBAL_AUTORCC_TARGET_NAME
# for the latter two with different values in different subdirectories.

# Directories
set(GAT_SDIR "${CMAKE_CURRENT_SOURCE_DIR}/GAT")
set(GAT_BDIR "${CMAKE_CURRENT_BINARY_DIR}/GAT")
# Files
set(MCA "sda/sda_autogen/mocs_compilation.cpp")
set(MCB "sdb/sdb_autogen/mocs_compilation.cpp")
set(MCC "sdc/sdc_autogen/mocs_compilation.cpp")
set(MCG "gat_autogen/mocs_compilation.cpp")

set(DRA "sda/sda_autogen/*qrc_data.cpp")
set(DRB "sdb/sdb_autogen/*qrc_data.cpp")
set(DRC "sdc/sdc_autogen/*qrc_data.cpp")
set(DRG "gat_autogen/*qrc_data.cpp")

# -- Utility macros
macro(GAT_FIND_FILES VAR NAME)
    file(GLOB_RECURSE ${VAR} ${GAT_BDIR}/*${NAME})
endmacro()

macro(GAT_FIND_FILE NAME)
    GAT_FIND_FILES(LST ${NAME})
    if(LST)
        message("Good find ${LST}")
    else()
        message(SEND_ERROR "Expected to find ${GAT_BDIR}/${NAME}")
    endif()
    unset(LST)
endmacro()

macro(GAT_FIND_FILE_NOT NAME)
    GAT_FIND_FILES(LST ${NAME})
    if(LST)
        message(SEND_ERROR "Not expected to find ${GAT_BDIR}/${NAME}")
    else()
        message("Good not find ${GAT_BDIR}/${NAME}")
    endif()
    unset(LST)
endmacro()

macro(GAT_BUILD_TARGET NAME)
    message("___ Building GAT ${NAME} target ___")
    execute_process(
        COMMAND "${CMAKE_COMMAND}" --build "${GAT_BDIR}" --target ${NAME}
        WORKING_DIRECTORY "${GAT_BDIR}"
        RESULT_VARIABLE result)
    if (result)
      message(SEND_ERROR "Building of GAT ${NAME} target failed")
    endif()
endmacro()


# -- Remove and recreate build directory
file(REMOVE_RECURSE ${GAT_BDIR})
file(MAKE_DIRECTORY ${GAT_BDIR})


# -- Configure project
message("___ Configuring GAT project ___")
execute_process(
    COMMAND "${CMAKE_COMMAND}" "${GAT_SDIR}"
        "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
        "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}"
        "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
    WORKING_DIRECTORY "${GAT_BDIR}"
    OUTPUT_VARIABLE output
    RESULT_VARIABLE result)
if (result)
  message(SEND_ERROR "Configuring of GAT project failed")
else()
  message("Configuring of GAT project succeeded")
  message("${output}")
endif()


# -- Build autogen subtargets
GAT_BUILD_TARGET("autogen")
GAT_FIND_FILE("${MCA}")
GAT_FIND_FILE_NOT("${MCB}")
GAT_FIND_FILE_NOT("${MCC}")
GAT_FIND_FILE("${MCG}")

GAT_BUILD_TARGET("global_autogen_sdb")
GAT_FIND_FILE("${MCA}")
GAT_FIND_FILE("${MCB}")
GAT_FIND_FILE_NOT("${MCC}")
GAT_FIND_FILE("${MCG}")

GAT_BUILD_TARGET("all_autogen")
GAT_FIND_FILE("${MCA}")
GAT_FIND_FILE("${MCB}")
GAT_FIND_FILE("${MCC}")
GAT_FIND_FILE("${MCG}")


# -- Build autorcc subtargets
GAT_BUILD_TARGET("autorcc")
GAT_FIND_FILE("${DRA}")
GAT_FIND_FILE_NOT("${DRB}")
GAT_FIND_FILE_NOT("${DRC}")
GAT_FIND_FILE("${DRG}")

GAT_BUILD_TARGET("global_autorcc_sdb")
GAT_FIND_FILE("${DRA}")
GAT_FIND_FILE("${DRB}")
GAT_FIND_FILE_NOT("${DRC}")
GAT_FIND_FILE("${DRG}")

GAT_BUILD_TARGET("all_autorcc")
GAT_FIND_FILE("${DRA}")
GAT_FIND_FILE("${DRB}")
GAT_FIND_FILE("${DRC}")
GAT_FIND_FILE("${DRG}")