f2fffef72b7f53e8bbebd33320fdc7a0754822b1
[platform/upstream/cmake.git] / Tests / Preprocess / preprocess.cxx
1 #include <preprocess.h>
2
3 #include FILE_PATH
4 #include TARGET_PATH
5
6 #include <stdio.h>
7 #include <string.h>
8
9 extern "C" int check_defines_C(void);
10
11 int check_defines_CXX()
12 {
13   int result = 1;
14   if (strcmp(FILE_STRING, STRING_VALUE) != 0) {
15     fprintf(stderr, "FILE_STRING has wrong value in CXX [%s] vs [%s]\n",
16             FILE_STRING, STRING_VALUE);
17     result = 0;
18   }
19   if (strcmp(TARGET_STRING, STRING_VALUE) != 0) {
20     fprintf(stderr, "TARGET_STRING has wrong value in CXX [%s] vs [%s]\n",
21             TARGET_STRING, STRING_VALUE);
22     result = 0;
23   }
24   {
25     int x = 2;
26     int y = 3;
27     if ((FILE_EXPR) != (EXPR)) {
28       fprintf(stderr, "FILE_EXPR did not work in CXX [%s] vs [%s]\n",
29               TO_STRING(FILE_EXPR), TO_STRING(EXPR));
30       result = 0;
31     }
32     if ((TARGET_EXPR) != (EXPR)) {
33       fprintf(stderr, "TARGET_EXPR did not work in CXX [%s] vs [%s]\n",
34               TO_STRING(TARGET_EXPR), TO_STRING(EXPR));
35       result = 0;
36     }
37   }
38 #ifdef NDEBUG
39 #  ifdef FILE_DEF_DEBUG
40   {
41     fprintf(stderr, "FILE_DEF_DEBUG should not be defined in CXX\n");
42     result = 0;
43   }
44 #  endif
45 #  ifdef TARGET_DEF_DEBUG
46   {
47     fprintf(stderr, "TARGET_DEF_DEBUG should not be defined in CXX\n");
48     result = 0;
49   }
50 #  endif
51 #  ifdef DIRECTORY_DEF_DEBUG
52   {
53     fprintf(stderr, "DIRECTORY_DEF_DEBUG should not be defined in CXX\n");
54     result = 0;
55   }
56 #  endif
57 #  ifndef FILE_DEF_RELEASE
58 #    ifndef PREPROCESS_XCODE
59   {
60     fprintf(stderr, "FILE_DEF_RELEASE should be defined in CXX\n");
61     result = 0;
62   }
63 #    endif
64 #  endif
65 #  ifndef TARGET_DEF_RELEASE
66   {
67     fprintf(stderr, "TARGET_DEF_RELEASE should be defined in CXX\n");
68     result = 0;
69   }
70 #  endif
71 #  ifndef DIRECTORY_DEF_RELEASE
72   {
73     fprintf(stderr, "DIRECTORY_DEF_RELEASE should be defined in CXX\n");
74     result = 0;
75   }
76 #  endif
77 #endif
78 #ifdef PREPROCESS_DEBUG
79 #  ifndef FILE_DEF_DEBUG
80 #    ifndef PREPROCESS_XCODE
81   {
82     fprintf(stderr, "FILE_DEF_DEBUG should be defined in CXX\n");
83     result = 0;
84   }
85 #    endif
86 #  endif
87 #  ifndef TARGET_DEF_DEBUG
88   {
89     fprintf(stderr, "TARGET_DEF_DEBUG should be defined in CXX\n");
90     result = 0;
91   }
92 #  endif
93 #  ifndef DIRECTORY_DEF_DEBUG
94   {
95     fprintf(stderr, "DIRECTORY_DEF_DEBUG should be defined in CXX\n");
96     result = 0;
97   }
98 #  endif
99 #  ifdef FILE_DEF_RELEASE
100   {
101     fprintf(stderr, "FILE_DEF_RELEASE should not be defined in CXX\n");
102     result = 0;
103   }
104 #  endif
105 #  ifdef TARGET_DEF_RELEASE
106   {
107     fprintf(stderr, "TARGET_DEF_RELEASE should not be defined in CXX\n");
108     result = 0;
109   }
110 #  endif
111 #  ifdef DIRECTORY_DEF_RELEASE
112   {
113     fprintf(stderr, "DIRECTORY_DEF_RELEASE should not be defined in CXX\n");
114     result = 0;
115   }
116 #  endif
117 #endif
118 #if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG)
119 #  if !defined(FILE_DEF_DEBUG) || !defined(TARGET_DEF_DEBUG)
120 #    ifndef PREPROCESS_XCODE
121   {
122     fprintf(stderr,
123             "FILE_DEF_DEBUG and TARGET_DEF_DEBUG inconsistent in CXX\n");
124     result = 0;
125   }
126 #    endif
127 #  endif
128 #  if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE)
129   {
130     fprintf(stderr, "DEBUG and RELEASE definitions inconsistent in CXX\n");
131     result = 0;
132   }
133 #  endif
134 #endif
135 #if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE)
136 #  if !defined(FILE_DEF_RELEASE) || !defined(TARGET_DEF_RELEASE)
137 #    ifndef PREPROCESS_XCODE
138   {
139     fprintf(stderr,
140             "FILE_DEF_RELEASE and TARGET_DEF_RELEASE inconsistent in CXX\n");
141     result = 0;
142   }
143 #    endif
144 #  endif
145 #  if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG)
146   {
147     fprintf(stderr, "RELEASE and DEBUG definitions inconsistent in CXX\n");
148     result = 0;
149   }
150 #  endif
151 #endif
152 #ifndef FILE_PATH_DEF
153   {
154     fprintf(stderr, "FILE_PATH_DEF not defined in CXX\n");
155     result = 0;
156   }
157 #endif
158 #ifndef TARGET_PATH_DEF
159   {
160     fprintf(stderr, "TARGET_PATH_DEF not defined in CXX\n");
161     result = 0;
162   }
163 #endif
164 #ifndef FILE_DEF
165   {
166     fprintf(stderr, "FILE_DEF not defined in CXX\n");
167     result = 0;
168   }
169 #endif
170 #ifndef TARGET_DEF
171   {
172     fprintf(stderr, "TARGET_DEF not defined in CXX\n");
173     result = 0;
174   }
175 #endif
176 #ifndef DIRECTORY_DEF
177   {
178     fprintf(stderr, "DIRECTORY_DEF not defined in CXX\n");
179     result = 0;
180   }
181 #endif
182 #ifndef OLD_DEF
183   {
184     fprintf(stderr, "OLD_DEF not defined in CXX\n");
185     result = 0;
186   }
187 #endif
188 #if !defined(OLD_EXPR) || OLD_EXPR != 2
189   {
190     fprintf(stderr, "OLD_EXPR id not work in C [%s]\n", TO_STRING(OLD_EXPR));
191     result = 0;
192   }
193 #endif
194   return result;
195 }
196
197 int main()
198 {
199   int result = 1;
200
201   if (!check_defines_C()) {
202     result = 0;
203   }
204
205   if (!check_defines_CXX()) {
206     result = 0;
207   }
208
209   if (result) {
210     printf("All preprocessor definitions are correct.\n");
211     return 0;
212   } else {
213     return 1;
214   }
215 }