cb7402c02674b4239364541cde95706bdb5cedbd
[platform/upstream/cmake.git] / Source / cmPolicies.h
1 /* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2    file Copyright.txt or https://cmake.org/licensing for details.  */
3 #pragma once
4
5 #include "cmConfigure.h" // IWYU pragma: keep
6
7 #include <bitset>
8 #include <string>
9
10 class cmMakefile;
11
12 #define CM_FOR_EACH_POLICY_TABLE(POLICY, SELECT)                              \
13   SELECT(POLICY, CMP0000,                                                     \
14          "A minimum required CMake version must be specified.", 2, 6, 0,      \
15          cmPolicies::WARN)                                                    \
16   SELECT(POLICY, CMP0001,                                                     \
17          "CMAKE_BACKWARDS_COMPATIBILITY should no longer be used.", 2, 6, 0,  \
18          cmPolicies::WARN)                                                    \
19   SELECT(POLICY, CMP0002, "Logical target names must be globally unique.", 2, \
20          6, 0, cmPolicies::WARN)                                              \
21   SELECT(                                                                     \
22     POLICY, CMP0003,                                                          \
23     "Libraries linked via full path no longer produce linker search paths.",  \
24     2, 6, 0, cmPolicies::WARN)                                                \
25   SELECT(POLICY, CMP0004,                                                     \
26          "Libraries linked may not have leading or trailing whitespace.", 2,  \
27          6, 0, cmPolicies::WARN)                                              \
28   SELECT(POLICY, CMP0005,                                                     \
29          "Preprocessor definition values are now escaped automatically.", 2,  \
30          6, 0, cmPolicies::WARN)                                              \
31   SELECT(POLICY, CMP0006,                                                     \
32          "Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION.",   \
33          2, 6, 0, cmPolicies::WARN)                                           \
34   SELECT(POLICY, CMP0007, "list command no longer ignores empty elements.",   \
35          2, 6, 0, cmPolicies::WARN)                                           \
36   SELECT(                                                                     \
37     POLICY, CMP0008,                                                          \
38     "Libraries linked by full-path must have a valid library file name.", 2,  \
39     6, 1, cmPolicies::WARN)                                                   \
40   SELECT(POLICY, CMP0009,                                                     \
41          "FILE GLOB_RECURSE calls should not follow symlinks by default.", 2, \
42          6, 2, cmPolicies::WARN)                                              \
43   SELECT(POLICY, CMP0010, "Bad variable reference syntax is an error.", 2, 6, \
44          3, cmPolicies::WARN)                                                 \
45   SELECT(POLICY, CMP0011,                                                     \
46          "Included scripts do automatic cmake_policy PUSH and POP.", 2, 6, 3, \
47          cmPolicies::WARN)                                                    \
48   SELECT(POLICY, CMP0012, "if() recognizes numbers and boolean constants.",   \
49          2, 8, 0, cmPolicies::WARN)                                           \
50   SELECT(POLICY, CMP0013, "Duplicate binary directories are not allowed.", 2, \
51          8, 0, cmPolicies::WARN)                                              \
52   SELECT(POLICY, CMP0014, "Input directories must have CMakeLists.txt.", 2,   \
53          8, 0, cmPolicies::WARN)                                              \
54   SELECT(POLICY, CMP0015,                                                     \
55          "link_directories() treats paths relative to the source dir.", 2, 8, \
56          1, cmPolicies::WARN)                                                 \
57   SELECT(POLICY, CMP0016,                                                     \
58          "target_link_libraries() reports error if its only argument "        \
59          "is not a target.",                                                  \
60          2, 8, 3, cmPolicies::WARN)                                           \
61   SELECT(POLICY, CMP0017,                                                     \
62          "Prefer files from the CMake module directory when including from "  \
63          "there.",                                                            \
64          2, 8, 4, cmPolicies::WARN)                                           \
65   SELECT(POLICY, CMP0018,                                                     \
66          "Ignore CMAKE_SHARED_LIBRARY_<Lang>_FLAGS variable.", 2, 8, 9,       \
67          cmPolicies::WARN)                                                    \
68   SELECT(POLICY, CMP0019,                                                     \
69          "Do not re-expand variables in include and link information.", 2, 8, \
70          11, cmPolicies::WARN)                                                \
71   SELECT(POLICY, CMP0020,                                                     \
72          "Automatically link Qt executables to qtmain target on Windows.", 2, \
73          8, 11, cmPolicies::WARN)                                             \
74   SELECT(                                                                     \
75     POLICY, CMP0021,                                                          \
76     "Fatal error on relative paths in INCLUDE_DIRECTORIES target property.",  \
77     2, 8, 12, cmPolicies::WARN)                                               \
78   SELECT(POLICY, CMP0022,                                                     \
79          "INTERFACE_LINK_LIBRARIES defines the link interface.", 2, 8, 12,    \
80          cmPolicies::WARN)                                                    \
81   SELECT(                                                                     \
82     POLICY, CMP0023,                                                          \
83     "Plain and keyword target_link_libraries signatures cannot be mixed.", 2, \
84     8, 12, cmPolicies::WARN)                                                  \
85   SELECT(POLICY, CMP0024, "Disallow include export result.", 3, 0, 0,         \
86          cmPolicies::WARN)                                                    \
87   SELECT(POLICY, CMP0025, "Compiler id for Apple Clang is now AppleClang.",   \
88          3, 0, 0, cmPolicies::WARN)                                           \
89   SELECT(POLICY, CMP0026, "Disallow use of the LOCATION target property.", 3, \
90          0, 0, cmPolicies::WARN)                                              \
91   SELECT(POLICY, CMP0027,                                                     \
92          "Conditionally linked imported targets with missing include "        \
93          "directories.",                                                      \
94          3, 0, 0, cmPolicies::WARN)                                           \
95   SELECT(POLICY, CMP0028,                                                     \
96          "Double colon in target name means ALIAS or IMPORTED target.", 3, 0, \
97          0, cmPolicies::WARN)                                                 \
98   SELECT(POLICY, CMP0029, "The subdir_depends command should not be called.", \
99          3, 0, 0, cmPolicies::WARN)                                           \
100   SELECT(POLICY, CMP0030,                                                     \
101          "The use_mangled_mesa command should not be called.", 3, 0, 0,       \
102          cmPolicies::WARN)                                                    \
103   SELECT(POLICY, CMP0031, "The load_command command should not be called.",   \
104          3, 0, 0, cmPolicies::WARN)                                           \
105   SELECT(POLICY, CMP0032,                                                     \
106          "The output_required_files command should not be called.", 3, 0, 0,  \
107          cmPolicies::WARN)                                                    \
108   SELECT(POLICY, CMP0033,                                                     \
109          "The export_library_dependencies command should not be called.", 3,  \
110          0, 0, cmPolicies::WARN)                                              \
111   SELECT(POLICY, CMP0034, "The utility_source command should not be called.", \
112          3, 0, 0, cmPolicies::WARN)                                           \
113   SELECT(POLICY, CMP0035,                                                     \
114          "The variable_requires command should not be called.", 3, 0, 0,      \
115          cmPolicies::WARN)                                                    \
116   SELECT(POLICY, CMP0036, "The build_name command should not be called.", 3,  \
117          0, 0, cmPolicies::WARN)                                              \
118   SELECT(POLICY, CMP0037,                                                     \
119          "Target names should not be reserved and should match a validity "   \
120          "pattern.",                                                          \
121          3, 0, 0, cmPolicies::WARN)                                           \
122   SELECT(POLICY, CMP0038, "Targets may not link directly to themselves.", 3,  \
123          0, 0, cmPolicies::WARN)                                              \
124   SELECT(POLICY, CMP0039, "Utility targets may not have link dependencies.",  \
125          3, 0, 0, cmPolicies::WARN)                                           \
126   SELECT(POLICY, CMP0040,                                                     \
127          "The target in the TARGET signature of add_custom_command() must "   \
128          "exist and must be defined in the current directory.",               \
129          3, 0, 0, cmPolicies::WARN)                                           \
130   SELECT(POLICY, CMP0041,                                                     \
131          "Error on relative include with generator expression.", 3, 0, 0,     \
132          cmPolicies::WARN)                                                    \
133   SELECT(POLICY, CMP0042, "MACOSX_RPATH is enabled by default.", 3, 0, 0,     \
134          cmPolicies::WARN)                                                    \
135   SELECT(POLICY, CMP0043, "Ignore COMPILE_DEFINITIONS_<Config> properties.",  \
136          3, 0, 0, cmPolicies::WARN)                                           \
137   SELECT(POLICY, CMP0044,                                                     \
138          "Case sensitive <LANG>_COMPILER_ID generator expressions.", 3, 0, 0, \
139          cmPolicies::WARN)                                                    \
140   SELECT(POLICY, CMP0045,                                                     \
141          "Error on non-existent target in get_target_property.", 3, 0, 0,     \
142          cmPolicies::WARN)                                                    \
143   SELECT(POLICY, CMP0046,                                                     \
144          "Error on non-existent dependency in add_dependencies.", 3, 0, 0,    \
145          cmPolicies::WARN)                                                    \
146   SELECT(POLICY, CMP0047, "Use QCC compiler id for the qcc drivers on QNX.",  \
147          3, 0, 0, cmPolicies::WARN)                                           \
148   SELECT(POLICY, CMP0048, "project() command manages VERSION variables.", 3,  \
149          0, 0, cmPolicies::WARN)                                              \
150   SELECT(POLICY, CMP0049,                                                     \
151          "Do not expand variables in target source entries.", 3, 0, 0,        \
152          cmPolicies::WARN)                                                    \
153   SELECT(POLICY, CMP0050, "Disallow add_custom_command SOURCE signatures.",   \
154          3, 0, 0, cmPolicies::WARN)                                           \
155   SELECT(POLICY, CMP0051, "List TARGET_OBJECTS in SOURCES target property.",  \
156          3, 1, 0, cmPolicies::WARN)                                           \
157   SELECT(POLICY, CMP0052,                                                     \
158          "Reject source and build dirs in installed "                         \
159          "INTERFACE_INCLUDE_DIRECTORIES.",                                    \
160          3, 1, 0, cmPolicies::WARN)                                           \
161   SELECT(POLICY, CMP0053,                                                     \
162          "Simplify variable reference and escape sequence evaluation.", 3, 1, \
163          0, cmPolicies::WARN)                                                 \
164   SELECT(                                                                     \
165     POLICY, CMP0054,                                                          \
166     "Only interpret if() arguments as variables or keywords when unquoted.",  \
167     3, 1, 0, cmPolicies::WARN)                                                \
168   SELECT(POLICY, CMP0055, "Strict checking for break() command.", 3, 2, 0,    \
169          cmPolicies::WARN)                                                    \
170   SELECT(POLICY, CMP0056,                                                     \
171          "Honor link flags in try_compile() source-file signature.", 3, 2, 0, \
172          cmPolicies::WARN)                                                    \
173   SELECT(POLICY, CMP0057, "Support new IN_LIST if() operator.", 3, 3, 0,      \
174          cmPolicies::WARN)                                                    \
175   SELECT(POLICY, CMP0058,                                                     \
176          "Ninja requires custom command byproducts to be explicit.", 3, 3, 0, \
177          cmPolicies::WARN)                                                    \
178   SELECT(POLICY, CMP0059,                                                     \
179          "Do not treat DEFINITIONS as a built-in directory property.", 3, 3,  \
180          0, cmPolicies::WARN)                                                 \
181   SELECT(POLICY, CMP0060,                                                     \
182          "Link libraries by full path even in implicit directories.", 3, 3,   \
183          0, cmPolicies::WARN)                                                 \
184   SELECT(POLICY, CMP0061,                                                     \
185          "CTest does not by default tell make to ignore errors (-i).", 3, 3,  \
186          0, cmPolicies::WARN)                                                 \
187   SELECT(POLICY, CMP0062, "Disallow install() of export() result.", 3, 3, 0,  \
188          cmPolicies::WARN)                                                    \
189   SELECT(POLICY, CMP0063,                                                     \
190          "Honor visibility properties for all target types.", 3, 3, 0,        \
191          cmPolicies::WARN)                                                    \
192   SELECT(POLICY, CMP0064, "Support new TEST if() operator.", 3, 4, 0,         \
193          cmPolicies::WARN)                                                    \
194   SELECT(POLICY, CMP0065,                                                     \
195          "Do not add flags to export symbols from executables without "       \
196          "the ENABLE_EXPORTS target property.",                               \
197          3, 4, 0, cmPolicies::WARN)                                           \
198   SELECT(POLICY, CMP0066,                                                     \
199          "Honor per-config flags in try_compile() source-file signature.", 3, \
200          7, 0, cmPolicies::WARN)                                              \
201   SELECT(POLICY, CMP0067,                                                     \
202          "Honor language standard in try_compile() source-file signature.",   \
203          3, 8, 0, cmPolicies::WARN)                                           \
204   SELECT(POLICY, CMP0068,                                                     \
205          "RPATH settings on macOS do not affect install_name.", 3, 9, 0,      \
206          cmPolicies::WARN)                                                    \
207   SELECT(POLICY, CMP0069,                                                     \
208          "INTERPROCEDURAL_OPTIMIZATION is enforced when enabled.", 3, 9, 0,   \
209          cmPolicies::WARN)                                                    \
210   SELECT(POLICY, CMP0070,                                                     \
211          "Define file(GENERATE) behavior for relative paths.", 3, 10, 0,      \
212          cmPolicies::WARN)                                                    \
213   SELECT(POLICY, CMP0071, "Let AUTOMOC and AUTOUIC process GENERATED files.", \
214          3, 10, 0, cmPolicies::WARN)                                          \
215   SELECT(POLICY, CMP0072,                                                     \
216          "FindOpenGL prefers GLVND by default when available.", 3, 11, 0,     \
217          cmPolicies::WARN)                                                    \
218   SELECT(POLICY, CMP0073,                                                     \
219          "Do not produce legacy _LIB_DEPENDS cache entries.", 3, 12, 0,       \
220          cmPolicies::WARN)                                                    \
221   SELECT(POLICY, CMP0074, "find_package uses <PackageName>_ROOT variables.",  \
222          3, 12, 0, cmPolicies::WARN)                                          \
223   SELECT(POLICY, CMP0075,                                                     \
224          "Include file check macros honor CMAKE_REQUIRED_LIBRARIES.", 3, 12,  \
225          0, cmPolicies::WARN)                                                 \
226   SELECT(POLICY, CMP0076,                                                     \
227          "target_sources() command converts relative paths to absolute.", 3,  \
228          13, 0, cmPolicies::WARN)                                             \
229   SELECT(POLICY, CMP0077, "option() honors normal variables.", 3, 13, 0,      \
230          cmPolicies::WARN)                                                    \
231   SELECT(POLICY, CMP0078, "UseSWIG generates standard target names.", 3, 13,  \
232          0, cmPolicies::WARN)                                                 \
233   SELECT(                                                                     \
234     POLICY, CMP0079,                                                          \
235     "target_link_libraries allows use with targets in other directories.", 3, \
236     13, 0, cmPolicies::WARN)                                                  \
237   SELECT(POLICY, CMP0080,                                                     \
238          "BundleUtilities cannot be included at configure time.", 3, 13, 0,   \
239          cmPolicies::WARN)                                                    \
240   SELECT(POLICY, CMP0081,                                                     \
241          "Relative paths not allowed in LINK_DIRECTORIES target property.",   \
242          3, 13, 0, cmPolicies::WARN)                                          \
243   SELECT(POLICY, CMP0082,                                                     \
244          "Install rules from add_subdirectory() are interleaved with those "  \
245          "in caller.",                                                        \
246          3, 14, 0, cmPolicies::WARN)                                          \
247   SELECT(POLICY, CMP0083, "Add PIE options when linking executable.", 3, 14,  \
248          0, cmPolicies::WARN)                                                 \
249   SELECT(POLICY, CMP0084,                                                     \
250          "The FindQt module does not exist for find_package().", 3, 14, 0,    \
251          cmPolicies::WARN)                                                    \
252   SELECT(POLICY, CMP0085, "$<IN_LIST:...> handles empty list items.", 3, 14,  \
253          0, cmPolicies::WARN)                                                 \
254   SELECT(POLICY, CMP0086,                                                     \
255          "UseSWIG honors SWIG_MODULE_NAME via -module flag.", 3, 14, 0,       \
256          cmPolicies::WARN)                                                    \
257   SELECT(POLICY, CMP0087,                                                     \
258          "Install CODE|SCRIPT allow the use of generator "                    \
259          "expressions.",                                                      \
260          3, 14, 0, cmPolicies::WARN)                                          \
261   SELECT(POLICY, CMP0088,                                                     \
262          "FindBISON runs bison in CMAKE_CURRENT_BINARY_DIR when executing.",  \
263          3, 14, 0, cmPolicies::WARN)                                          \
264   SELECT(POLICY, CMP0089,                                                     \
265          "Compiler id for IBM Clang-based XL compilers is now XLClang.", 3,   \
266          15, 0, cmPolicies::WARN)                                             \
267   SELECT(POLICY, CMP0090,                                                     \
268          "export(PACKAGE) does not populate package registry by default.", 3, \
269          15, 0, cmPolicies::WARN)                                             \
270   SELECT(POLICY, CMP0091,                                                     \
271          "MSVC runtime library flags are selected by an abstraction.", 3, 15, \
272          0, cmPolicies::WARN)                                                 \
273   SELECT(POLICY, CMP0092,                                                     \
274          "MSVC warning flags are not in CMAKE_<LANG>_FLAGS by default.", 3,   \
275          15, 0, cmPolicies::WARN)                                             \
276   SELECT(POLICY, CMP0093, "FindBoost reports Boost_VERSION in x.y.z format.", \
277          3, 15, 0, cmPolicies::WARN)                                          \
278   SELECT(POLICY, CMP0094,                                                     \
279          "FindPython3,  FindPython2 and FindPyton use "                       \
280          "LOCATION for lookup strategy.",                                     \
281          3, 15, 0, cmPolicies::WARN)                                          \
282   SELECT(POLICY, CMP0095,                                                     \
283          "RPATH entries are properly escaped in the intermediary CMake "      \
284          "install script.",                                                   \
285          3, 16, 0, cmPolicies::WARN)                                          \
286   SELECT(POLICY, CMP0096,                                                     \
287          "project() preserves leading zeros in version components.", 3, 16,   \
288          0, cmPolicies::WARN)                                                 \
289   SELECT(POLICY, CMP0097,                                                     \
290          "ExternalProject_Add with GIT_SUBMODULES \"\" initializes no "       \
291          "submodules.",                                                       \
292          3, 16, 0, cmPolicies::WARN)                                          \
293   SELECT(POLICY, CMP0098,                                                     \
294          "FindFLEX runs flex in CMAKE_CURRENT_BINARY_DIR when executing.", 3, \
295          17, 0, cmPolicies::WARN)                                             \
296   SELECT(POLICY, CMP0099,                                                     \
297          "Link properties are transitive over private dependency on static "  \
298          "libraries.",                                                        \
299          3, 17, 0, cmPolicies::WARN)                                          \
300   SELECT(POLICY, CMP0100, "Let AUTOMOC and AUTOUIC process .hh files.", 3,    \
301          17, 0, cmPolicies::WARN)                                             \
302   SELECT(POLICY, CMP0101,                                                     \
303          "target_compile_options honors BEFORE keyword in all scopes.", 3,    \
304          17, 0, cmPolicies::WARN)                                             \
305   SELECT(POLICY, CMP0102,                                                     \
306          "mark_as_advanced() does nothing if a cache entry does not exist.",  \
307          3, 17, 0, cmPolicies::WARN)                                          \
308   SELECT(POLICY, CMP0103,                                                     \
309          "Multiple export() with same FILE without APPEND is not allowed.",   \
310          3, 18, 0, cmPolicies::WARN)                                          \
311   SELECT(POLICY, CMP0104,                                                     \
312          "CMAKE_CUDA_ARCHITECTURES now detected for NVCC, empty "             \
313          "CUDA_ARCHITECTURES not allowed.",                                   \
314          3, 18, 0, cmPolicies::WARN)                                          \
315   SELECT(POLICY, CMP0105, "Device link step uses the link options.", 3, 18,   \
316          0, cmPolicies::WARN)                                                 \
317   SELECT(POLICY, CMP0106, "The Documentation module is removed.", 3, 18, 0,   \
318          cmPolicies::WARN)                                                    \
319   SELECT(POLICY, CMP0107, "An ALIAS target cannot overwrite another target.", \
320          3, 18, 0, cmPolicies::WARN)                                          \
321   SELECT(POLICY, CMP0108, "A target cannot link to itself through an alias.", \
322          3, 18, 0, cmPolicies::WARN)                                          \
323   SELECT(POLICY, CMP0109,                                                     \
324          "find_program() requires permission to execute but not to read.", 3, \
325          19, 0, cmPolicies::WARN)                                             \
326   SELECT(POLICY, CMP0110,                                                     \
327          "add_test() supports arbitrary characters in test names.", 3, 19, 0, \
328          cmPolicies::WARN)                                                    \
329   SELECT(POLICY, CMP0111,                                                     \
330          "An imported target missing its location property fails during "     \
331          "generation.",                                                       \
332          3, 19, 0, cmPolicies::WARN)                                          \
333   SELECT(POLICY, CMP0112,                                                     \
334          "Target file component generator expressions do not add target "     \
335          "dependencies.",                                                     \
336          3, 19, 0, cmPolicies::WARN)                                          \
337   SELECT(POLICY, CMP0113,                                                     \
338          "Makefile generators do not repeat custom commands from target "     \
339          "dependencies.",                                                     \
340          3, 19, 0, cmPolicies::WARN)                                          \
341   SELECT(POLICY, CMP0114,                                                     \
342          "ExternalProject step targets fully adopt their steps.", 3, 19, 0,   \
343          cmPolicies::WARN)                                                    \
344   SELECT(POLICY, CMP0115, "Source file extensions must be explicit.", 3, 20,  \
345          0, cmPolicies::WARN)                                                 \
346   SELECT(POLICY, CMP0116,                                                     \
347          "Ninja generators transform DEPFILEs from add_custom_command().", 3, \
348          20, 0, cmPolicies::WARN)                                             \
349   SELECT(POLICY, CMP0117,                                                     \
350          "MSVC RTTI flag /GR is not added to CMAKE_CXX_FLAGS by default.", 3, \
351          20, 0, cmPolicies::WARN)                                             \
352   SELECT(                                                                     \
353     POLICY, CMP0118,                                                          \
354     "The GENERATED source file property is now visible in all directories.",  \
355     3, 20, 0, cmPolicies::WARN)                                               \
356   SELECT(POLICY, CMP0119,                                                     \
357          "LANGUAGE source file property explicitly compiles as specified "    \
358          "language.",                                                         \
359          3, 20, 0, cmPolicies::WARN)                                          \
360   SELECT(POLICY, CMP0120,                                                     \
361          "The WriteCompilerDetectionHeader module is removed.", 3, 20, 0,     \
362          cmPolicies::WARN)                                                    \
363   SELECT(POLICY, CMP0121,                                                     \
364          "The list() command now validates parsing of index arguments.", 3,   \
365          21, 0, cmPolicies::WARN)                                             \
366   SELECT(                                                                     \
367     POLICY, CMP0122,                                                          \
368     "UseSWIG use standard library name conventions for csharp language.", 3,  \
369     21, 0, cmPolicies::WARN)                                                  \
370   SELECT(POLICY, CMP0123,                                                     \
371          "ARMClang cpu/arch compile and link flags must be set explicitly.",  \
372          3, 21, 0, cmPolicies::WARN)                                          \
373   SELECT(POLICY, CMP0124,                                                     \
374          "foreach() loop variables are only available in the loop scope.", 3, \
375          21, 0, cmPolicies::WARN)                                             \
376   SELECT(POLICY, CMP0125,                                                     \
377          "find_(path|file|library|program) have consistent behavior for "     \
378          "cache variables.",                                                  \
379          3, 21, 0, cmPolicies::WARN)                                          \
380   SELECT(POLICY, CMP0126,                                                     \
381          "set(CACHE) does not remove a normal variable of the same name.", 3, \
382          21, 0, cmPolicies::WARN)                                             \
383   SELECT(POLICY, CMP0127,                                                     \
384          "cmake_dependent_option() supports full Condition Syntax.", 3, 22,   \
385          0, cmPolicies::WARN)                                                 \
386   SELECT(POLICY, CMP0128,                                                     \
387          "Selection of language standard and extension flags improved.", 3,   \
388          22, 0, cmPolicies::WARN)                                             \
389   SELECT(POLICY, CMP0129,                                                     \
390          "Compiler id for MCST LCC compilers is now LCC, not GNU.", 3, 23, 0, \
391          cmPolicies::WARN)                                                    \
392   SELECT(POLICY, CMP0130, "while() diagnoses condition evaluation errors.",   \
393          3, 24, 0, cmPolicies::WARN)                                          \
394   SELECT(POLICY, CMP0131,                                                     \
395          "LINK_LIBRARIES supports the LINK_ONLY generator expression.", 3,    \
396          24, 0, cmPolicies::WARN)                                             \
397   SELECT(POLICY, CMP0132,                                                     \
398          "Do not set compiler environment variables on first run", 3, 24, 0,  \
399          cmPolicies::WARN)                                                    \
400   SELECT(POLICY, CMP0133,                                                     \
401          "The CPack module disables SLA by default in the CPack DragNDrop "   \
402          "Generator.",                                                        \
403          3, 24, 0, cmPolicies::WARN)                                          \
404   SELECT(POLICY, CMP0134,                                                     \
405          "Fallback to \"HOST\" Windows registry view when \"TARGET\" view "   \
406          "is not usable.",                                                    \
407          3, 24, 0, cmPolicies::WARN)                                          \
408   SELECT(POLICY, CMP0135,                                                     \
409          "ExternalProject ignores timestamps in archives by default for the " \
410          "URL download method",                                               \
411          3, 24, 0, cmPolicies::WARN)                                          \
412   SELECT(POLICY, CMP0136,                                                     \
413          "Watcom runtime library flags are selected by an abstraction.", 3,   \
414          24, 0, cmPolicies::WARN)                                             \
415   SELECT(POLICY, CMP0137,                                                     \
416          "try_compile() passes platform variables in project mode", 3, 24, 0, \
417          cmPolicies::WARN)                                                    \
418   SELECT(POLICY, CMP0138,                                                     \
419          "CheckIPOSupported uses flags from calling project.", 3, 24, 0,      \
420          cmPolicies::WARN)                                                    \
421   SELECT(                                                                     \
422     POLICY, CMP0139,                                                          \
423     "The if() command supports path comparisons using PATH_EQUAL operator.",  \
424     3, 24, 0, cmPolicies::WARN)
425
426 #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
427 #define CM_FOR_EACH_POLICY_ID(POLICY)                                         \
428   CM_FOR_EACH_POLICY_TABLE(POLICY, CM_SELECT_ID)
429
430 #define CM_FOR_EACH_TARGET_POLICY(F)                                          \
431   F(CMP0003)                                                                  \
432   F(CMP0004)                                                                  \
433   F(CMP0008)                                                                  \
434   F(CMP0020)                                                                  \
435   F(CMP0021)                                                                  \
436   F(CMP0022)                                                                  \
437   F(CMP0027)                                                                  \
438   F(CMP0037)                                                                  \
439   F(CMP0038)                                                                  \
440   F(CMP0041)                                                                  \
441   F(CMP0042)                                                                  \
442   F(CMP0046)                                                                  \
443   F(CMP0052)                                                                  \
444   F(CMP0060)                                                                  \
445   F(CMP0063)                                                                  \
446   F(CMP0065)                                                                  \
447   F(CMP0068)                                                                  \
448   F(CMP0069)                                                                  \
449   F(CMP0073)                                                                  \
450   F(CMP0076)                                                                  \
451   F(CMP0081)                                                                  \
452   F(CMP0083)                                                                  \
453   F(CMP0095)                                                                  \
454   F(CMP0099)                                                                  \
455   F(CMP0104)                                                                  \
456   F(CMP0105)                                                                  \
457   F(CMP0108)                                                                  \
458   F(CMP0112)                                                                  \
459   F(CMP0113)                                                                  \
460   F(CMP0119)                                                                  \
461   F(CMP0131)
462
463 /** \class cmPolicies
464  * \brief Handles changes in CMake behavior and policies
465  *
466  * See the cmake-policies(7) manual for an overview of this class's purpose.
467  */
468 class cmPolicies
469 {
470 public:
471   /// Status of a policy
472   enum PolicyStatus
473   {
474     OLD,  ///< Use old behavior
475     WARN, ///< Use old behavior but issue a warning
476     NEW,  ///< Use new behavior
477     /// Issue an error if user doesn't set policy status to NEW and hits the
478     /// check
479     REQUIRED_IF_USED,
480     REQUIRED_ALWAYS ///< Issue an error unless user sets policy status to NEW.
481   };
482
483   /// Policy identifiers
484   enum PolicyID
485   {
486 #define POLICY_ENUM(POLICY_ID) POLICY_ID,
487     CM_FOR_EACH_POLICY_ID(POLICY_ENUM)
488 #undef POLICY_ENUM
489
490     /** \brief Always the last entry.
491      *
492      * Useful mostly to avoid adding a comma the last policy when adding a new
493      * one.
494      */
495     CMPCOUNT
496   };
497
498   //! convert a string policy ID into a number
499   static bool GetPolicyID(const char* id, /* out */ cmPolicies::PolicyID& pid);
500
501   //! Get the default status for a policy
502   static cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id);
503
504   enum class WarnCompat
505   {
506     Off,
507     On
508   };
509
510   //! Set a policy level for this listfile
511   static bool ApplyPolicyVersion(cmMakefile* mf,
512                                  std::string const& version_min,
513                                  std::string const& version_max,
514                                  WarnCompat warnCompat);
515   static bool ApplyPolicyVersion(cmMakefile* mf, unsigned int majorVer,
516                                  unsigned int minorVer, unsigned int patchVer,
517                                  WarnCompat warnCompat);
518
519   //! return a warning string for a given policy
520   static std::string GetPolicyWarning(cmPolicies::PolicyID id);
521   static std::string GetPolicyDeprecatedWarning(cmPolicies::PolicyID id);
522
523   //! return an error string for when a required policy is unspecified
524   static std::string GetRequiredPolicyError(cmPolicies::PolicyID id);
525
526   //! return an error string for when a required policy is unspecified
527   static std::string GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id);
528
529   /** Represent a set of policy values.  */
530   struct PolicyMap
531   {
532     PolicyStatus Get(PolicyID id) const;
533     void Set(PolicyID id, PolicyStatus status);
534     bool IsDefined(PolicyID id) const;
535     bool IsEmpty() const;
536
537   private:
538 #define POLICY_STATUS_COUNT 3
539     std::bitset<cmPolicies::CMPCOUNT * POLICY_STATUS_COUNT> Status;
540   };
541 };