8 ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED)
10 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED)
15 SET(STRING_VAR "CMake is great" CACHE STRING "test a cache variable")
18 # Test VARIABLE_REQUIRES
20 VARIABLE_REQUIRES(ONE_VAR
21 ONE_VAR_IS_DEFINED ONE_VAR)
24 # Test various IF/ELSE combinations
27 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_NOT)
29 ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_NOT)
33 ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_NOT2)
35 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_NOT2)
38 IF(ONE_VAR AND ONE_VAR2)
39 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_AND)
40 ELSE(ONE_VAR AND ONE_VAR2)
41 ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_AND)
42 ENDIF(ONE_VAR AND ONE_VAR2)
44 IF(ONE_VAR AND ZERO_VAR)
45 ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_AND2)
46 ELSE(ONE_VAR AND ZERO_VAR)
47 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_AND2)
48 ENDIF(ONE_VAR AND ZERO_VAR)
50 IF(ZERO_VAR OR ONE_VAR2)
51 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_OR)
52 ELSE(ZERO_VAR OR ONE_VAR2)
53 ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_OR)
54 ENDIF(ZERO_VAR OR ONE_VAR2)
56 IF(ZERO_VAR OR ZERO_VAR2)
57 ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_OR2)
58 ELSE(ZERO_VAR OR ZERO_VAR2)
59 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_OR2)
60 ENDIF(ZERO_VAR OR ZERO_VAR2)
62 IF(STRING_VAR MATCHES "^CMake")
63 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_MATCHES)
64 ELSE(STRING_VAR MATCHES "^CMake")
65 ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES)
66 ENDIF(STRING_VAR MATCHES "^CMake")
68 IF(STRING_VAR MATCHES "^foo")
69 ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES2)
70 ELSE(STRING_VAR MATCHES "^foo")
71 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_MATCHES2)
72 ENDIF(STRING_VAR MATCHES "^foo")
75 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_COMMAND)
77 ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_COMMAND)
80 IF(COMMAND "ROQUEFORT")
81 ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_COMMAND2)
82 ELSE(COMMAND "ROQUEFORT")
83 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_COMMAND2)
84 ENDIF(COMMAND "ROQUEFORT")
86 IF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
87 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_EXISTS)
88 ELSE(EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
89 ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_EXISTS)
90 ENDIF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
92 IF (EXISTS ${Complex_SOURCE_DIR}/roquefort.txt)
93 ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_EXISTS2)
94 ELSE(EXISTS ${Complex_SOURCE_DIR}/roquefort.txt)
95 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_EXISTS2)
96 ENDIF (EXISTS ${Complex_SOURCE_DIR}/roquefort.txt)
98 IF (IS_DIRECTORY ${Complex_SOURCE_DIR})
99 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_IS_DIRECTORY)
100 ENDIF (IS_DIRECTORY ${Complex_SOURCE_DIR})
102 IF (NOT IS_DIRECTORY ${Complex_SOURCE_DIR}/VarTests.cmake)
103 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_IS_DIRECTORY2)
104 ENDIF (NOT IS_DIRECTORY ${Complex_SOURCE_DIR}/VarTests.cmake)
111 IF (SNUM1_VAR LESS SNUM2_VAR)
112 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_LESS)
113 ELSE (SNUM1_VAR LESS SNUM2_VAR)
114 ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_LESS)
115 ENDIF (SNUM1_VAR LESS SNUM2_VAR)
117 IF (SNUM2_VAR LESS SNUM1_VAR)
118 ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_LESS2)
119 ELSE (SNUM2_VAR LESS SNUM1_VAR)
120 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_LESS2)
121 ENDIF (SNUM2_VAR LESS SNUM1_VAR)
123 IF (SNUM2_VAR GREATER SNUM1_VAR)
124 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_GREATER)
125 ELSE (SNUM2_VAR GREATER SNUM1_VAR)
126 ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_GREATER)
127 ENDIF (SNUM2_VAR GREATER SNUM1_VAR)
129 IF (SNUM2_VAR EQUAL SNUM1_VAR)
130 ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_EQUAL)
131 ELSE (SNUM2_VAR EQUAL SNUM1_VAR)
132 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_EQUAL)
133 ENDIF (SNUM2_VAR EQUAL SNUM1_VAR)
135 IF (SNUM3_VAR EQUAL SNUM1_VAR)
136 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_EQUAL)
137 ELSE (SNUM3_VAR EQUAL SNUM1_VAR)
138 ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_EQUAL)
139 ENDIF (SNUM3_VAR EQUAL SNUM1_VAR)
141 IF (SNUM1_VAR GREATER SNUM2_VAR)
142 ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_GREATER2)
143 ELSE (SNUM1_VAR GREATER SNUM2_VAR)
144 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_GREATER2)
145 ENDIF (SNUM1_VAR GREATER SNUM2_VAR)
147 SET (SSTR1_VAR "abc")
148 SET (SSTR2_VAR "bcd")
150 IF (SSTR1_VAR STRLESS SSTR2_VAR)
151 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_STRLESS)
152 ELSE (SSTR1_VAR STRLESS SSTR2_VAR)
153 ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_STRLESS)
154 ENDIF (SSTR1_VAR STRLESS SSTR2_VAR)
156 IF (SSTR2_VAR STRLESS SSTR1_VAR)
157 ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_STRLESS2)
158 ELSE (SSTR2_VAR STRLESS SSTR1_VAR)
159 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_STRLESS2)
160 ENDIF (SSTR2_VAR STRLESS SSTR1_VAR)
162 IF (SSTR2_VAR STRGREATER SSTR1_VAR)
163 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_STRGREATER)
164 ELSE (SSTR2_VAR STRGREATER SSTR1_VAR)
165 ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_STRGREATER)
166 ENDIF (SSTR2_VAR STRGREATER SSTR1_VAR)
168 IF (SSTR1_VAR STRGREATER SSTR2_VAR)
169 ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_STRGREATER2)
170 ELSE (SSTR1_VAR STRGREATER SSTR2_VAR)
171 ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_STRGREATER2)
172 ENDIF (SSTR1_VAR STRGREATER SSTR2_VAR)
178 SET(FOREACH_VAR${INDEX} "VALUE${INDEX}")
181 SET(FOREACH_CONCAT "")
182 FOREACH (INDEX a;b;c;d;e;f;g)
183 SET(FOREACH_CONCAT "${FOREACH_CONCAT}${INDEX}")
187 # Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
189 FIND_FILE(FILENAME_VAR "VarTests.cmake" ${Complex_SOURCE_DIR})
191 GET_FILENAME_COMPONENT(FILENAME_VAR_PATH ${FILENAME_VAR} PATH)
192 GET_FILENAME_COMPONENT(FILENAME_VAR_PATH_NAME ${FILENAME_VAR_PATH} NAME)
193 GET_FILENAME_COMPONENT(FILENAME_VAR_NAME ${FILENAME_VAR} NAME)
194 GET_FILENAME_COMPONENT(FILENAME_VAR_EXT ${FILENAME_VAR} EXT)
195 GET_FILENAME_COMPONENT(FILENAME_VAR_NAME_WE ${FILENAME_VAR} NAME_WE CACHE)
197 FIND_PATH(PATH_VAR "cmTestConfigure.h.in" ${Complex_SOURCE_DIR})
198 GET_FILENAME_COMPONENT(PATH_VAR_NAME ${PATH_VAR} NAME)