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