1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
6 #include "cmConfigure.h" // IWYU pragma: keep
13 #define CM_FOR_EACH_POLICY_TABLE(POLICY, SELECT) \
14 SELECT(POLICY, CMP0000, \
15 "A minimum required CMake version must be specified.", 2, 6, 0, \
17 SELECT(POLICY, CMP0001, \
18 "CMAKE_BACKWARDS_COMPATIBILITY should no longer be used.", 2, 6, 0, \
20 SELECT(POLICY, CMP0002, "Logical target names must be globally unique.", 2, \
21 6, 0, cmPolicies::WARN) \
24 "Libraries linked via full path no longer produce linker search paths.", \
25 2, 6, 0, cmPolicies::WARN) \
26 SELECT(POLICY, CMP0004, \
27 "Libraries linked may not have leading or trailing whitespace.", 2, \
28 6, 0, cmPolicies::WARN) \
29 SELECT(POLICY, CMP0005, \
30 "Preprocessor definition values are now escaped automatically.", 2, \
31 6, 0, cmPolicies::WARN) \
32 SELECT(POLICY, CMP0006, \
33 "Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION.", \
34 2, 6, 0, cmPolicies::WARN) \
35 SELECT(POLICY, CMP0007, "list command no longer ignores empty elements.", \
36 2, 6, 0, cmPolicies::WARN) \
39 "Libraries linked by full-path must have a valid library file name.", 2, \
40 6, 1, cmPolicies::WARN) \
41 SELECT(POLICY, CMP0009, \
42 "FILE GLOB_RECURSE calls should not follow symlinks by default.", 2, \
43 6, 2, cmPolicies::WARN) \
44 SELECT(POLICY, CMP0010, "Bad variable reference syntax is an error.", 2, 6, \
45 3, cmPolicies::WARN) \
46 SELECT(POLICY, CMP0011, \
47 "Included scripts do automatic cmake_policy PUSH and POP.", 2, 6, 3, \
49 SELECT(POLICY, CMP0012, "if() recognizes numbers and boolean constants.", \
50 2, 8, 0, cmPolicies::WARN) \
51 SELECT(POLICY, CMP0013, "Duplicate binary directories are not allowed.", 2, \
52 8, 0, cmPolicies::WARN) \
53 SELECT(POLICY, CMP0014, "Input directories must have CMakeLists.txt.", 2, \
54 8, 0, cmPolicies::WARN) \
55 SELECT(POLICY, CMP0015, \
56 "link_directories() treats paths relative to the source dir.", 2, 8, \
57 1, cmPolicies::WARN) \
58 SELECT(POLICY, CMP0016, \
59 "target_link_libraries() reports error if its only argument " \
61 2, 8, 3, cmPolicies::WARN) \
62 SELECT(POLICY, CMP0017, \
63 "Prefer files from the CMake module directory when including from " \
65 2, 8, 4, cmPolicies::WARN) \
66 SELECT(POLICY, CMP0018, \
67 "Ignore CMAKE_SHARED_LIBRARY_<Lang>_FLAGS variable.", 2, 8, 9, \
69 SELECT(POLICY, CMP0019, \
70 "Do not re-expand variables in include and link information.", 2, 8, \
71 11, cmPolicies::WARN) \
72 SELECT(POLICY, CMP0020, \
73 "Automatically link Qt executables to qtmain target on Windows.", 2, \
74 8, 11, cmPolicies::WARN) \
77 "Fatal error on relative paths in INCLUDE_DIRECTORIES target property.", \
78 2, 8, 12, cmPolicies::WARN) \
79 SELECT(POLICY, CMP0022, \
80 "INTERFACE_LINK_LIBRARIES defines the link interface.", 2, 8, 12, \
84 "Plain and keyword target_link_libraries signatures cannot be mixed.", 2, \
85 8, 12, cmPolicies::WARN) \
86 SELECT(POLICY, CMP0024, "Disallow include export result.", 3, 0, 0, \
88 SELECT(POLICY, CMP0025, "Compiler id for Apple Clang is now AppleClang.", \
89 3, 0, 0, cmPolicies::WARN) \
90 SELECT(POLICY, CMP0026, "Disallow use of the LOCATION target property.", 3, \
91 0, 0, cmPolicies::WARN) \
92 SELECT(POLICY, CMP0027, \
93 "Conditionally linked imported targets with missing include " \
95 3, 0, 0, cmPolicies::WARN) \
96 SELECT(POLICY, CMP0028, \
97 "Double colon in target name means ALIAS or IMPORTED target.", 3, 0, \
98 0, cmPolicies::WARN) \
99 SELECT(POLICY, CMP0029, "The subdir_depends command should not be called.", \
100 3, 0, 0, cmPolicies::WARN) \
101 SELECT(POLICY, CMP0030, \
102 "The use_mangled_mesa command should not be called.", 3, 0, 0, \
104 SELECT(POLICY, CMP0031, "The load_command command should not be called.", \
105 3, 0, 0, cmPolicies::WARN) \
106 SELECT(POLICY, CMP0032, \
107 "The output_required_files command should not be called.", 3, 0, 0, \
109 SELECT(POLICY, CMP0033, \
110 "The export_library_dependencies command should not be called.", 3, \
111 0, 0, cmPolicies::WARN) \
112 SELECT(POLICY, CMP0034, "The utility_source command should not be called.", \
113 3, 0, 0, cmPolicies::WARN) \
114 SELECT(POLICY, CMP0035, \
115 "The variable_requires command should not be called.", 3, 0, 0, \
117 SELECT(POLICY, CMP0036, "The build_name command should not be called.", 3, \
118 0, 0, cmPolicies::WARN) \
119 SELECT(POLICY, CMP0037, \
120 "Target names should not be reserved and should match a validity " \
122 3, 0, 0, cmPolicies::WARN) \
123 SELECT(POLICY, CMP0038, "Targets may not link directly to themselves.", 3, \
124 0, 0, cmPolicies::WARN) \
125 SELECT(POLICY, CMP0039, "Utility targets may not have link dependencies.", \
126 3, 0, 0, cmPolicies::WARN) \
127 SELECT(POLICY, CMP0040, \
128 "The target in the TARGET signature of add_custom_command() must " \
129 "exist and must be defined in the current directory.", \
130 3, 0, 0, cmPolicies::WARN) \
131 SELECT(POLICY, CMP0041, \
132 "Error on relative include with generator expression.", 3, 0, 0, \
134 SELECT(POLICY, CMP0042, "MACOSX_RPATH is enabled by default.", 3, 0, 0, \
136 SELECT(POLICY, CMP0043, "Ignore COMPILE_DEFINITIONS_<Config> properties.", \
137 3, 0, 0, cmPolicies::WARN) \
138 SELECT(POLICY, CMP0044, \
139 "Case sensitive <LANG>_COMPILER_ID generator expressions.", 3, 0, 0, \
141 SELECT(POLICY, CMP0045, \
142 "Error on non-existent target in get_target_property.", 3, 0, 0, \
144 SELECT(POLICY, CMP0046, \
145 "Error on non-existent dependency in add_dependencies.", 3, 0, 0, \
147 SELECT(POLICY, CMP0047, "Use QCC compiler id for the qcc drivers on QNX.", \
148 3, 0, 0, cmPolicies::WARN) \
149 SELECT(POLICY, CMP0048, "project() command manages VERSION variables.", 3, \
150 0, 0, cmPolicies::WARN) \
151 SELECT(POLICY, CMP0049, \
152 "Do not expand variables in target source entries.", 3, 0, 0, \
154 SELECT(POLICY, CMP0050, "Disallow add_custom_command SOURCE signatures.", \
155 3, 0, 0, cmPolicies::WARN) \
156 SELECT(POLICY, CMP0051, "List TARGET_OBJECTS in SOURCES target property.", \
157 3, 1, 0, cmPolicies::WARN) \
158 SELECT(POLICY, CMP0052, \
159 "Reject source and build dirs in installed " \
160 "INTERFACE_INCLUDE_DIRECTORIES.", \
161 3, 1, 0, cmPolicies::WARN) \
162 SELECT(POLICY, CMP0053, \
163 "Simplify variable reference and escape sequence evaluation.", 3, 1, \
164 0, cmPolicies::WARN) \
167 "Only interpret if() arguments as variables or keywords when unquoted.", \
168 3, 1, 0, cmPolicies::WARN) \
169 SELECT(POLICY, CMP0055, "Strict checking for break() command.", 3, 2, 0, \
171 SELECT(POLICY, CMP0056, \
172 "Honor link flags in try_compile() source-file signature.", 3, 2, 0, \
174 SELECT(POLICY, CMP0057, "Support new IN_LIST if() operator.", 3, 3, 0, \
176 SELECT(POLICY, CMP0058, \
177 "Ninja requires custom command byproducts to be explicit.", 3, 3, 0, \
179 SELECT(POLICY, CMP0059, \
180 "Do not treat DEFINITIONS as a built-in directory property.", 3, 3, \
181 0, cmPolicies::WARN) \
182 SELECT(POLICY, CMP0060, \
183 "Link libraries by full path even in implicit directories.", 3, 3, \
184 0, cmPolicies::WARN) \
185 SELECT(POLICY, CMP0061, \
186 "CTest does not by default tell make to ignore errors (-i).", 3, 3, \
187 0, cmPolicies::WARN) \
188 SELECT(POLICY, CMP0062, "Disallow install() of export() result.", 3, 3, 0, \
190 SELECT(POLICY, CMP0063, \
191 "Honor visibility properties for all target types.", 3, 3, 0, \
193 SELECT(POLICY, CMP0064, "Support new TEST if() operator.", 3, 4, 0, \
195 SELECT(POLICY, CMP0065, \
196 "Do not add flags to export symbols from executables without " \
197 "the ENABLE_EXPORTS target property.", \
198 3, 4, 0, cmPolicies::WARN) \
199 SELECT(POLICY, CMP0066, \
200 "Honor per-config flags in try_compile() source-file signature.", 3, \
201 7, 0, cmPolicies::WARN) \
202 SELECT(POLICY, CMP0067, \
203 "Honor language standard in try_compile() source-file signature.", \
204 3, 8, 0, cmPolicies::WARN) \
205 SELECT(POLICY, CMP0068, \
206 "RPATH settings on macOS do not affect install_name.", 3, 9, 0, \
208 SELECT(POLICY, CMP0069, \
209 "INTERPROCEDURAL_OPTIMIZATION is enforced when enabled.", 3, 9, 0, \
211 SELECT(POLICY, CMP0070, \
212 "Define file(GENERATE) behavior for relative paths.", 3, 10, 0, \
214 SELECT(POLICY, CMP0071, "Let AUTOMOC and AUTOUIC process GENERATED files.", \
215 3, 10, 0, cmPolicies::WARN) \
216 SELECT(POLICY, CMP0072, \
217 "FindOpenGL prefers GLVND by default when available.", 3, 11, 0, \
219 SELECT(POLICY, CMP0073, \
220 "Do not produce legacy _LIB_DEPENDS cache entries.", 3, 12, 0, \
222 SELECT(POLICY, CMP0074, "find_package uses <PackageName>_ROOT variables.", \
223 3, 12, 0, cmPolicies::WARN) \
224 SELECT(POLICY, CMP0075, \
225 "Include file check macros honor CMAKE_REQUIRED_LIBRARIES.", 3, 12, \
228 #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
229 #define CM_FOR_EACH_POLICY_ID(POLICY) \
230 CM_FOR_EACH_POLICY_TABLE(POLICY, CM_SELECT_ID)
232 #define CM_FOR_EACH_TARGET_POLICY(F) \
253 /** \class cmPolicies
254 * \brief Handles changes in CMake behavior and policies
256 * See the cmake-policies(7) manual for an overview of this class's purpose.
261 /// Status of a policy
264 OLD, ///< Use old behavior
265 WARN, ///< Use old behavior but issue a warning
266 NEW, ///< Use new behavior
267 /// Issue an error if user doesn't set policy status to NEW and hits the
270 REQUIRED_ALWAYS ///< Issue an error unless user sets policy status to NEW.
273 /// Policy identifiers
276 #define POLICY_ENUM(POLICY_ID) POLICY_ID,
277 CM_FOR_EACH_POLICY_ID(POLICY_ENUM)
280 /** \brief Always the last entry.
282 * Useful mostly to avoid adding a comma the last policy when adding a new
288 ///! convert a string policy ID into a number
289 static bool GetPolicyID(const char* id, /* out */ cmPolicies::PolicyID& pid);
291 ///! Get the default status for a policy
292 static cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id);
294 ///! Set a policy level for this listfile
295 static bool ApplyPolicyVersion(cmMakefile* mf,
296 std::string const& version_min,
297 std::string const& version_max);
298 static bool ApplyPolicyVersion(cmMakefile* mf, unsigned int majorVer,
299 unsigned int minorVer, unsigned int patchVer);
301 ///! return a warning string for a given policy
302 static std::string GetPolicyWarning(cmPolicies::PolicyID id);
303 static std::string GetPolicyDeprecatedWarning(cmPolicies::PolicyID id);
305 ///! return an error string for when a required policy is unspecified
306 static std::string GetRequiredPolicyError(cmPolicies::PolicyID id);
308 ///! return an error string for when a required policy is unspecified
309 static std::string GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id);
311 /** Represent a set of policy values. */
314 PolicyStatus Get(PolicyID id) const;
315 void Set(PolicyID id, PolicyStatus status);
316 bool IsDefined(PolicyID id) const;
317 bool IsEmpty() const;
320 #define POLICY_STATUS_COUNT 3
321 std::bitset<cmPolicies::CMPCOUNT * POLICY_STATUS_COUNT> Status;