summaryrefslogtreecommitdiff
path: root/Tests/ComplexOneConfig/VarTests.cmake
blob: 70b803a1e59cb973f32e359b770372e31ed2476b (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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#
# Test SET
#
set (ZERO_VAR 0)
set (ZERO_VAR2 0)

if(ZERO_VAR)
  add_definitions(-DSHOULD_NOT_BE_DEFINED)
else()
  add_definitions(-DSHOULD_BE_DEFINED)
endif()

set(ONE_VAR 1)
set(ONE_VAR2 1)
set(STRING_VAR "CMake is great" CACHE STRING "test a cache variable")

#
# Test VARIABLE_REQUIRES
#
variable_requires(ONE_VAR
                  ONE_VAR_IS_DEFINED ONE_VAR)

#
# Test various IF/ELSE combinations
#
if(NOT ZERO_VAR)
  add_definitions(-DSHOULD_BE_DEFINED_NOT)
else()
  add_definitions(-DSHOULD_NOT_BE_DEFINED_NOT)
endif()

if(NOT ONE_VAR)
  add_definitions(-DSHOULD_NOT_BE_DEFINED_NOT2)
else()
  add_definitions(-DSHOULD_BE_DEFINED_NOT2)
endif()

if(ONE_VAR AND ONE_VAR2)
  add_definitions(-DSHOULD_BE_DEFINED_AND)
else()
  add_definitions(-DSHOULD_NOT_BE_DEFINED_AND)
endif()

if(ONE_VAR AND ZERO_VAR)
  add_definitions(-DSHOULD_NOT_BE_DEFINED_AND2)
else()
  add_definitions(-DSHOULD_BE_DEFINED_AND2)
endif()

if(ZERO_VAR OR ONE_VAR2)
  add_definitions(-DSHOULD_BE_DEFINED_OR)
else()
  add_definitions(-DSHOULD_NOT_BE_DEFINED_OR)
endif()

if(ZERO_VAR OR ZERO_VAR2)
  add_definitions(-DSHOULD_NOT_BE_DEFINED_OR2)
else()
  add_definitions(-DSHOULD_BE_DEFINED_OR2)
endif()

if(STRING_VAR MATCHES "^CMake")
  add_definitions(-DSHOULD_BE_DEFINED_MATCHES)
else()
  add_definitions(-DSHOULD_NOT_BE_DEFINED_MATCHES)
endif()

if(STRING_VAR MATCHES "^foo")
  add_definitions(-DSHOULD_NOT_BE_DEFINED_MATCHES2)
else()
  add_definitions(-DSHOULD_BE_DEFINED_MATCHES2)
endif()

if(COMMAND "IF")
  add_definitions(-DSHOULD_BE_DEFINED_COMMAND)
else()
  add_definitions(-DSHOULD_NOT_BE_DEFINED_COMMAND)
endif()

if(COMMAND "ROQUEFORT")
  add_definitions(-DSHOULD_NOT_BE_DEFINED_COMMAND2)
else()
  add_definitions(-DSHOULD_BE_DEFINED_COMMAND2)
endif()

if (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
  add_definitions(-DSHOULD_BE_DEFINED_EXISTS)
else()
  add_definitions(-DSHOULD_NOT_BE_DEFINED_EXISTS)
endif ()

if (EXISTS ${Complex_SOURCE_DIR}/roquefort.txt)
  add_definitions(-DSHOULD_NOT_BE_DEFINED_EXISTS2)
else()
  add_definitions(-DSHOULD_BE_DEFINED_EXISTS2)
endif ()

if (IS_DIRECTORY ${Complex_SOURCE_DIR})
  add_definitions(-DSHOULD_BE_DEFINED_IS_DIRECTORY)
endif ()

if (NOT IS_DIRECTORY ${Complex_SOURCE_DIR}/VarTests.cmake)
  add_definitions(-DSHOULD_BE_DEFINED_IS_DIRECTORY2)
endif ()

set (SNUM1_VAR "1")
set (SNUM2_VAR "2")
set (SNUM3_VAR "1")


if (SNUM1_VAR LESS SNUM2_VAR)
  add_definitions(-DSHOULD_BE_DEFINED_LESS)
else ()
  add_definitions(-DSHOULD_NOT_BE_DEFINED_LESS)
endif ()

if (SNUM2_VAR LESS SNUM1_VAR)
  add_definitions(-DSHOULD_NOT_BE_DEFINED_LESS2)
else ()
  add_definitions(-DSHOULD_BE_DEFINED_LESS2)
endif ()

if (SNUM2_VAR GREATER SNUM1_VAR)
  add_definitions(-DSHOULD_BE_DEFINED_GREATER)
else ()
  add_definitions(-DSHOULD_NOT_BE_DEFINED_GREATER)
endif ()

if (SNUM2_VAR EQUAL SNUM1_VAR)
  add_definitions(-DSHOULD_NOT_BE_DEFINED_EQUAL)
else ()
  add_definitions(-DSHOULD_BE_DEFINED_EQUAL)
endif ()

if (SNUM3_VAR EQUAL SNUM1_VAR)
  add_definitions(-DSHOULD_BE_DEFINED_EQUAL)
else ()
  add_definitions(-DSHOULD_NOT_BE_DEFINED_EQUAL)
endif ()

if (SNUM1_VAR GREATER SNUM2_VAR)
  add_definitions(-DSHOULD_NOT_BE_DEFINED_GREATER2)
else ()
  add_definitions(-DSHOULD_BE_DEFINED_GREATER2)
endif ()

set (SSTR1_VAR "abc")
set (SSTR2_VAR "bcd")

if (SSTR1_VAR STRLESS SSTR2_VAR)
  add_definitions(-DSHOULD_BE_DEFINED_STRLESS)
else ()
  add_definitions(-DSHOULD_NOT_BE_DEFINED_STRLESS)
endif ()

if (SSTR2_VAR STRLESS SSTR1_VAR)
  add_definitions(-DSHOULD_NOT_BE_DEFINED_STRLESS2)
else ()
  add_definitions(-DSHOULD_BE_DEFINED_STRLESS2)
endif ()

if (SSTR2_VAR STRGREATER SSTR1_VAR)
  add_definitions(-DSHOULD_BE_DEFINED_STRGREATER)
else ()
  add_definitions(-DSHOULD_NOT_BE_DEFINED_STRGREATER)
endif ()

if (SSTR1_VAR STRGREATER SSTR2_VAR)
  add_definitions(-DSHOULD_NOT_BE_DEFINED_STRGREATER2)
else ()
  add_definitions(-DSHOULD_BE_DEFINED_STRGREATER2)
endif ()

#
# Test FOREACH
#
foreach (INDEX 1 2)
  set(FOREACH_VAR${INDEX} "VALUE${INDEX}")
endforeach()

set(FOREACH_CONCAT "")
foreach (INDEX a;b;c;d;e;f;g)
  set(FOREACH_CONCAT "${FOREACH_CONCAT}${INDEX}")
endforeach()