Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmPolicies.cxx
blob169814ac4767e1a4ff30765ac722a73bb82fddb3
1 #include "cmPolicies.h"
2 #include "cmake.h"
3 #include "cmMakefile.h"
4 #include "cmSourceFile.h"
5 #include "cmVersion.h"
6 #include <map>
7 #include <set>
8 #include <queue>
9 #include <assert.h>
11 const char* cmPolicies::PolicyStatusNames[] = {
12 "OLD", "WARN", "NEW", "REQUIRED_IF_USED", "REQUIRED_ALWAYS"
15 class cmPolicy
17 public:
18 cmPolicy(cmPolicies::PolicyID iD,
19 const char *idString,
20 const char *shortDescription,
21 const char *longDescription,
22 unsigned int majorVersionIntroduced,
23 unsigned int minorVersionIntroduced,
24 unsigned int patchVersionIntroduced,
25 cmPolicies::PolicyStatus status)
27 if (!idString || !shortDescription || ! longDescription)
29 cmSystemTools::Error("Attempt to define a policy without "
30 "all parameters being specified!");
31 return;
33 this->ID = iD;
34 this->IDString = idString;
35 this->ShortDescription = shortDescription;
36 this->LongDescription = longDescription;
37 this->MajorVersionIntroduced = majorVersionIntroduced;
38 this->MinorVersionIntroduced = minorVersionIntroduced;
39 this->PatchVersionIntroduced = patchVersionIntroduced;
40 this->Status = status;
43 std::string GetVersionString()
45 cmOStringStream error;
46 error << this->MajorVersionIntroduced << "." <<
47 this->MinorVersionIntroduced << "." <<
48 this->PatchVersionIntroduced;
49 return error.str();
52 bool IsPolicyNewerThan(unsigned int majorV,
53 unsigned int minorV,
54 unsigned int patchV)
56 if (majorV < this->MajorVersionIntroduced)
58 return true;
60 if (majorV > this->MajorVersionIntroduced)
62 return false;
64 if (minorV < this->MinorVersionIntroduced)
66 return true;
68 if (minorV > this->MinorVersionIntroduced)
70 return false;
72 return (patchV < this->PatchVersionIntroduced);
75 cmPolicies::PolicyID ID;
76 std::string IDString;
77 std::string ShortDescription;
78 std::string LongDescription;
79 unsigned int MajorVersionIntroduced;
80 unsigned int MinorVersionIntroduced;
81 unsigned int PatchVersionIntroduced;
82 cmPolicies::PolicyStatus Status;
85 cmPolicies::cmPolicies()
87 // define all the policies
88 this->DefinePolicy(
89 CMP0000, "CMP0000",
90 "A minimum required CMake version must be specified.",
91 "CMake requires that projects specify the version of CMake to which "
92 "they have been written. "
93 "This policy has been put in place so users trying to build the project "
94 "may be told when they need to update their CMake. "
95 "Specifying a version also helps the project build with CMake versions "
96 "newer than that specified. "
97 "Use the cmake_minimum_required command at the top of your main "
98 " CMakeLists.txt file:\n"
99 " cmake_minimum_required(VERSION <major>.<minor>)\n"
100 "where \"<major>.<minor>\" is the version of CMake you want to support "
101 "(such as \"2.6\"). "
102 "The command will ensure that at least the given version of CMake is "
103 "running and help newer versions be compatible with the project. "
104 "See documentation of cmake_minimum_required for details.\n"
105 "Note that the command invocation must appear in the CMakeLists.txt "
106 "file itself; a call in an included file is not sufficient. "
107 "However, the cmake_policy command may be called to set policy "
108 "CMP0000 to OLD or NEW behavior explicitly. "
109 "The OLD behavior is to silently ignore the missing invocation. "
110 "The NEW behavior is to issue an error instead of a warning. "
111 "An included file may set CMP0000 explicitly to affect how this "
112 "policy is enforced for the main CMakeLists.txt file.",
113 2,6,0, cmPolicies::WARN
116 this->DefinePolicy(
117 CMP0001, "CMP0001",
118 "CMAKE_BACKWARDS_COMPATIBILITY should no longer be used.",
119 "The OLD behavior is to check CMAKE_BACKWARDS_COMPATIBILITY and present "
120 "it to the user. "
121 "The NEW behavior is to ignore CMAKE_BACKWARDS_COMPATIBILITY "
122 "completely.\n"
123 "In CMake 2.4 and below the variable CMAKE_BACKWARDS_COMPATIBILITY was "
124 "used to request compatibility with earlier versions of CMake. "
125 "In CMake 2.6 and above all compatibility issues are handled by policies "
126 "and the cmake_policy command. "
127 "However, CMake must still check CMAKE_BACKWARDS_COMPATIBILITY for "
128 "projects written for CMake 2.4 and below.",
129 2,6,0, cmPolicies::WARN
132 this->DefinePolicy(
133 CMP0002, "CMP0002",
134 "Logical target names must be globally unique.",
135 "Targets names created with "
136 "add_executable, add_library, or add_custom_target "
137 "are logical build target names. "
138 "Logical target names must be globally unique because:\n"
139 " - Unique names may be referenced unambiguously both in CMake\n"
140 " code and on make tool command lines.\n"
141 " - Logical names are used by Xcode and VS IDE generators\n"
142 " to produce meaningful project names for the targets.\n"
143 "The logical name of executable and library targets does not "
144 "have to correspond to the physical file names built. "
145 "Consider using the OUTPUT_NAME target property to create two "
146 "targets with the same physical name while keeping logical "
147 "names distinct. "
148 "Custom targets must simply have globally unique names (unless one "
149 "uses the global property ALLOW_DUPLICATE_CUSTOM_TARGETS with a "
150 "Makefiles generator).",
151 2,6,0, cmPolicies::WARN
154 this->DefinePolicy(
155 CMP0003, "CMP0003",
156 "Libraries linked via full path no longer produce linker search paths.",
157 "This policy affects how libraries whose full paths are NOT known "
158 "are found at link time, but was created due to a change in how CMake "
159 "deals with libraries whose full paths are known. "
160 "Consider the code\n"
161 " target_link_libraries(myexe /path/to/libA.so)\n"
162 "CMake 2.4 and below implemented linking to libraries whose full paths "
163 "are known by splitting them on the link line into separate components "
164 "consisting of the linker search path and the library name. "
165 "The example code might have produced something like\n"
166 " ... -L/path/to -lA ...\n"
167 "in order to link to library A. "
168 "An analysis was performed to order multiple link directories such that "
169 "the linker would find library A in the desired location, but there "
170 "are cases in which this does not work. "
171 "CMake versions 2.6 and above use the more reliable approach of passing "
172 "the full path to libraries directly to the linker in most cases. "
173 "The example code now produces something like\n"
174 " ... /path/to/libA.so ....\n"
175 "Unfortunately this change can break code like\n"
176 " target_link_libraries(myexe /path/to/libA.so B)\n"
177 "where \"B\" is meant to find \"/path/to/libB.so\". "
178 "This code is wrong because the user is asking the linker to find "
179 "library B but has not provided a linker search path (which may be "
180 "added with the link_directories command). "
181 "However, with the old linking implementation the code would work "
182 "accidentally because the linker search path added for library A "
183 "allowed library B to be found."
184 "\n"
185 "In order to support projects depending on linker search paths "
186 "added by linking to libraries with known full paths, the OLD "
187 "behavior for this policy will add the linker search paths even "
188 "though they are not needed for their own libraries. "
189 "When this policy is set to OLD, CMake will produce a link line such as\n"
190 " ... -L/path/to /path/to/libA.so -lB ...\n"
191 "which will allow library B to be found as it was previously. "
192 "When this policy is set to NEW, CMake will produce a link line such as\n"
193 " ... /path/to/libA.so -lB ...\n"
194 "which more accurately matches what the project specified."
195 "\n"
196 "The setting for this policy used when generating the link line is that "
197 "in effect when the target is created by an add_executable or "
198 "add_library command. For the example described above, the code\n"
199 " cmake_policy(SET CMP0003 OLD) # or cmake_policy(VERSION 2.4)\n"
200 " add_executable(myexe myexe.c)\n"
201 " target_link_libraries(myexe /path/to/libA.so B)\n"
202 "will work and suppress the warning for this policy. "
203 "It may also be updated to work with the corrected linking approach:\n"
204 " cmake_policy(SET CMP0003 NEW) # or cmake_policy(VERSION 2.6)\n"
205 " link_directories(/path/to) # needed to find library B\n"
206 " add_executable(myexe myexe.c)\n"
207 " target_link_libraries(myexe /path/to/libA.so B)\n"
208 "Even better, library B may be specified with a full path:\n"
209 " add_executable(myexe myexe.c)\n"
210 " target_link_libraries(myexe /path/to/libA.so /path/to/libB.so)\n"
211 "When all items on the link line have known paths CMake does not check "
212 "this policy so it has no effect.\n"
213 "Note that the warning for this policy will be issued for at most "
214 "one target. This avoids flooding users with messages for every "
215 "target when setting the policy once will probably fix all targets.",
216 2,6,0, cmPolicies::WARN);
218 this->DefinePolicy(
219 CMP0004, "CMP0004",
220 "Libraries linked may not have leading or trailing whitespace.",
221 "CMake versions 2.4 and below silently removed leading and trailing "
222 "whitespace from libraries linked with code like\n"
223 " target_link_libraries(myexe \" A \")\n"
224 "This could lead to subtle errors in user projects.\n"
225 "The OLD behavior for this policy is to silently remove leading and "
226 "trailing whitespace. "
227 "The NEW behavior for this policy is to diagnose the existence of "
228 "such whitespace as an error. "
229 "The setting for this policy used when checking the library names is "
230 "that in effect when the target is created by an add_executable or "
231 "add_library command.",
232 2,6,0, cmPolicies::WARN);
234 this->DefinePolicy(
235 CMP0005, "CMP0005",
236 "Preprocessor definition values are now escaped automatically.",
237 "This policy determines whether or not CMake should generate escaped "
238 "preprocessor definition values added via add_definitions. "
239 "CMake versions 2.4 and below assumed that only trivial values would "
240 "be given for macros in add_definitions calls. "
241 "It did not attempt to escape non-trivial values such as string "
242 "literals in generated build rules. "
243 "CMake versions 2.6 and above support escaping of most values, but "
244 "cannot assume the user has not added escapes already in an attempt to "
245 "work around limitations in earlier versions.\n"
246 "The OLD behavior for this policy is to place definition values given "
247 "to add_definitions directly in the generated build rules without "
248 "attempting to escape anything. "
249 "The NEW behavior for this policy is to generate correct escapes "
250 "for all native build tools automatically. "
251 "See documentation of the COMPILE_DEFINITIONS target property for "
252 "limitations of the escaping implementation.",
253 2,6,0, cmPolicies::WARN);
255 this->DefinePolicy(
256 CMP0006, "CMP0006",
257 "Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION.",
258 "This policy determines whether the install(TARGETS) command must be "
259 "given a BUNDLE DESTINATION when asked to install a target with the "
260 "MACOSX_BUNDLE property set. "
261 "CMake 2.4 and below did not distinguish application bundles from "
262 "normal executables when installing targets. "
263 "CMake 2.6 provides a BUNDLE option to the install(TARGETS) command "
264 "that specifies rules specific to application bundles on the Mac. "
265 "Projects should use this option when installing a target with the "
266 "MACOSX_BUNDLE property set.\n"
267 "The OLD behavior for this policy is to fall back to the RUNTIME "
268 "DESTINATION if a BUNDLE DESTINATION is not given. "
269 "The NEW behavior for this policy is to produce an error if a bundle "
270 "target is installed without a BUNDLE DESTINATION.",
271 2,6,0, cmPolicies::WARN);
273 this->DefinePolicy(
274 CMP0007, "CMP0007",
275 "list command no longer ignores empty elements.",
276 "This policy determines whether the list command will "
277 "ignore empty elements in the list. "
278 "CMake 2.4 and below list commands ignored all empty elements"
279 " in the list. For example, a;b;;c would have length 3 and not 4. "
280 "The OLD behavior for this policy is to ignore empty list elements. "
281 "The NEW behavior for this policy is to correctly count empty "
282 "elements in a list. ",
283 2,6,0, cmPolicies::WARN);
285 this->DefinePolicy(
286 CMP0008, "CMP0008",
287 "Libraries linked by full-path must have a valid library file name.",
288 "In CMake 2.4 and below it is possible to write code like\n"
289 " target_link_libraries(myexe /full/path/to/somelib)\n"
290 "where \"somelib\" is supposed to be a valid library file name "
291 "such as \"libsomelib.a\" or \"somelib.lib\". "
292 "For Makefile generators this produces an error at build time "
293 "because the dependency on the full path cannot be found. "
294 "For VS IDE and Xcode generators this used to work by accident because "
295 "CMake would always split off the library directory and ask the "
296 "linker to search for the library by name (-lsomelib or somelib.lib). "
297 "Despite the failure with Makefiles, some projects have code like this "
298 "and build only with VS and/or Xcode. "
299 "This version of CMake prefers to pass the full path directly to the "
300 "native build tool, which will fail in this case because it does "
301 "not name a valid library file."
302 "\n"
303 "This policy determines what to do with full paths that do not appear "
304 "to name a valid library file. "
305 "The OLD behavior for this policy is to split the library name from the "
306 "path and ask the linker to search for it. "
307 "The NEW behavior for this policy is to trust the given path and "
308 "pass it directly to the native build tool unchanged.",
309 2,6,1, cmPolicies::WARN);
311 this->DefinePolicy(
312 CMP0009, "CMP0009",
313 "FILE GLOB_RECURSE calls should not follow symlinks by default.",
314 "In CMake 2.6.1 and below, FILE GLOB_RECURSE calls would follow "
315 "through symlinks, sometimes coming up with unexpectedly large "
316 "result sets because of symlinks to top level directories that "
317 "contain hundreds of thousands of files."
318 "\n"
319 "This policy determines whether or not to follow symlinks "
320 "encountered during a FILE GLOB_RECURSE call. "
321 "The OLD behavior for this policy is to follow the symlinks. "
322 "The NEW behavior for this policy is not to follow the symlinks "
323 "by default, but only if FOLLOW_SYMLINKS is given as an additional "
324 "argument to the FILE command.",
325 2,6,2, cmPolicies::WARN);
327 this->DefinePolicy(
328 CMP0010, "CMP0010",
329 "Bad variable reference syntax is an error.",
330 "In CMake 2.6.2 and below, incorrect variable reference syntax such as "
331 "a missing close-brace (\"${FOO\") was reported but did not stop "
332 "processing of CMake code. "
333 "This policy determines whether a bad variable reference is an error. "
334 "The OLD behavior for this policy is to warn about the error, leave "
335 "the string untouched, and continue. "
336 "The NEW behavior for this policy is to report an error.",
337 2,6,3, cmPolicies::WARN);
339 this->DefinePolicy(
340 CMP0011, "CMP0011",
341 "Included scripts do automatic cmake_policy PUSH and POP.",
342 "In CMake 2.6.2 and below, CMake Policy settings in scripts loaded by "
343 "the include() and find_package() commands would affect the includer. "
344 "Explicit invocations of cmake_policy(PUSH) and cmake_policy(POP) were "
345 "required to isolate policy changes and protect the includer. "
346 "While some scripts intend to affect the policies of their includer, "
347 "most do not. "
348 "In CMake 2.6.3 and above, include() and find_package() by default PUSH "
349 "and POP an entry on the policy stack around an included script, "
350 "but provide a NO_POLICY_SCOPE option to disable it. "
351 "This policy determines whether or not to imply NO_POLICY_SCOPE for "
352 "compatibility. "
353 "The OLD behavior for this policy is to imply NO_POLICY_SCOPE for "
354 "include() and find_package() commands. "
355 "The NEW behavior for this policy is to allow the commands to do their "
356 "default cmake_policy PUSH and POP.",
357 2,6,3, cmPolicies::WARN);
360 cmPolicies::~cmPolicies()
362 // free the policies
363 std::map<cmPolicies::PolicyID,cmPolicy *>::iterator i
364 = this->Policies.begin();
365 for (;i != this->Policies.end(); ++i)
367 delete i->second;
371 void cmPolicies::DefinePolicy(cmPolicies::PolicyID iD,
372 const char *idString,
373 const char *shortDescription,
374 const char *longDescription,
375 unsigned int majorVersionIntroduced,
376 unsigned int minorVersionIntroduced,
377 unsigned int patchVersionIntroduced,
378 cmPolicies::PolicyStatus status)
380 // a policy must be unique and can only be defined once
381 if (this->Policies.find(iD) != this->Policies.end())
383 cmSystemTools::Error("Attempt to redefine a CMake policy for policy "
384 "ID ", this->GetPolicyIDString(iD).c_str());
385 return;
388 this->Policies[iD] = new cmPolicy(iD, idString,
389 shortDescription,
390 longDescription,
391 majorVersionIntroduced,
392 minorVersionIntroduced,
393 patchVersionIntroduced,
394 status);
395 this->PolicyStringMap[idString] = iD;
398 //----------------------------------------------------------------------------
399 bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
400 const char *version)
402 std::string ver = "2.4.0";
404 if (version && strlen(version) > 0)
406 ver = version;
409 unsigned int majorVer = 2;
410 unsigned int minorVer = 0;
411 unsigned int patchVer = 0;
413 // parse the string
414 if(sscanf(ver.c_str(), "%u.%u.%u",
415 &majorVer, &minorVer, &patchVer) < 2)
417 cmOStringStream e;
418 e << "Invalid policy version value \"" << ver << "\". "
419 << "A numeric major.minor[.patch] must be given.";
420 mf->IssueMessage(cmake::FATAL_ERROR, e.str());
421 return false;
424 // it is an error if the policy version is less than 2.4
425 if (majorVer < 2 || majorVer == 2 && minorVer < 4)
427 mf->IssueMessage(cmake::FATAL_ERROR,
428 "An attempt was made to set the policy version of CMake to something "
429 "earlier than \"2.4\". "
430 "In CMake 2.4 and below backwards compatibility was handled with the "
431 "CMAKE_BACKWARDS_COMPATIBILITY variable. "
432 "In order to get compatibility features supporting versions earlier "
433 "than 2.4 set policy CMP0001 to OLD to tell CMake to check the "
434 "CMAKE_BACKWARDS_COMPATIBILITY variable. "
435 "One way to do this is to set the policy version to 2.4 exactly."
437 return false;
440 // It is an error if the policy version is greater than the running
441 // CMake.
442 if (majorVer > cmVersion::GetMajorVersion() ||
443 (majorVer == cmVersion::GetMajorVersion() &&
444 minorVer > cmVersion::GetMinorVersion()) ||
445 (majorVer == cmVersion::GetMajorVersion() &&
446 minorVer == cmVersion::GetMinorVersion() &&
447 patchVer > cmVersion::GetPatchVersion()))
449 cmOStringStream e;
450 e << "An attempt was made to set the policy version of CMake to \""
451 << version << "\" which is greater than this version of CMake. "
452 << "This is not allowed because the greater version may have new "
453 << "policies not known to this CMake. "
454 << "You may need a newer CMake version to build this project.";
455 mf->IssueMessage(cmake::FATAL_ERROR, e.str());
456 return false;
459 // now loop over all the policies and set them as appropriate
460 std::vector<cmPolicies::PolicyID> ancientPolicies;
461 std::map<cmPolicies::PolicyID,cmPolicy *>::iterator i
462 = this->Policies.begin();
463 for (;i != this->Policies.end(); ++i)
465 if (i->second->IsPolicyNewerThan(majorVer,minorVer,patchVer))
467 if(i->second->Status == cmPolicies::REQUIRED_ALWAYS)
469 ancientPolicies.push_back(i->first);
471 else if (!mf->SetPolicy(i->second->ID, cmPolicies::WARN))
473 return false;
476 else
478 if (!mf->SetPolicy(i->second->ID, cmPolicies::NEW))
480 return false;
485 // Make sure the project does not use any ancient policies.
486 if(!ancientPolicies.empty())
488 this->DiagnoseAncientPolicies(ancientPolicies,
489 majorVer, minorVer, patchVer, mf);
490 cmSystemTools::SetFatalErrorOccured();
491 return false;
494 return true;
497 bool cmPolicies::GetPolicyID(const char *id, cmPolicies::PolicyID &pid)
499 if (!id || strlen(id) < 1)
501 return false;
503 std::map<std::string,cmPolicies::PolicyID>::iterator pos =
504 this->PolicyStringMap.find(id);
505 if (pos == this->PolicyStringMap.end())
507 return false;
509 pid = pos->second;
510 return true;
513 std::string cmPolicies::GetPolicyIDString(cmPolicies::PolicyID pid)
515 std::map<cmPolicies::PolicyID,cmPolicy *>::iterator pos =
516 this->Policies.find(pid);
517 if (pos == this->Policies.end())
519 return "";
521 return pos->second->IDString;
525 ///! return a warning string for a given policy
526 std::string cmPolicies::GetPolicyWarning(cmPolicies::PolicyID id)
528 std::map<cmPolicies::PolicyID,cmPolicy *>::iterator pos =
529 this->Policies.find(id);
530 if (pos == this->Policies.end())
532 cmSystemTools::Error(
533 "Request for warning text for undefined policy!");
534 return "Request for warning text for undefined policy!";
537 cmOStringStream msg;
538 msg <<
539 "Policy " << pos->second->IDString << " is not set: "
540 "" << pos->second->ShortDescription << " "
541 "Run \"cmake --help-policy " << pos->second->IDString << "\" for "
542 "policy details. "
543 "Use the cmake_policy command to set the policy "
544 "and suppress this warning.";
545 return msg.str();
549 ///! return an error string for when a required policy is unspecified
550 std::string cmPolicies::GetRequiredPolicyError(cmPolicies::PolicyID id)
552 std::map<cmPolicies::PolicyID,cmPolicy *>::iterator pos =
553 this->Policies.find(id);
554 if (pos == this->Policies.end())
556 cmSystemTools::Error(
557 "Request for error text for undefined policy!");
558 return "Request for warning text for undefined policy!";
561 cmOStringStream error;
562 error <<
563 "Policy " << pos->second->IDString << " is not set to NEW: "
564 "" << pos->second->ShortDescription << " "
565 "Run \"cmake --help-policy " << pos->second->IDString << "\" for "
566 "policy details. "
567 "CMake now requires this policy to be set to NEW by the project. "
568 "The policy may be set explicitly using the code\n"
569 " cmake_policy(SET " << pos->second->IDString << " NEW)\n"
570 "or by upgrading all policies with the code\n"
571 " cmake_policy(VERSION " << pos->second->GetVersionString() <<
572 ") # or later\n"
573 "Run \"cmake --help-command cmake_policy\" for more information.";
574 return error.str();
577 ///! Get the default status for a policy
578 cmPolicies::PolicyStatus
579 cmPolicies::GetPolicyStatus(cmPolicies::PolicyID id)
581 // if the policy is not know then what?
582 std::map<cmPolicies::PolicyID,cmPolicy *>::iterator pos =
583 this->Policies.find(id);
584 if (pos == this->Policies.end())
586 // TODO is this right?
587 return cmPolicies::WARN;
590 return pos->second->Status;
593 void cmPolicies::GetDocumentation(std::vector<cmDocumentationEntry>& v)
595 // now loop over all the policies and set them as appropriate
596 std::map<cmPolicies::PolicyID,cmPolicy *>::iterator i
597 = this->Policies.begin();
598 for (;i != this->Policies.end(); ++i)
600 cmOStringStream full;
601 full << i->second->LongDescription;
602 full << "\nThis policy was introduced in CMake version ";
603 full << i->second->GetVersionString() << ".";
604 if(i->first != cmPolicies::CMP0000)
606 full << " "
607 << "CMake version " << cmVersion::GetMajorVersion()
608 << "." << cmVersion::GetMinorVersion() << " ";
609 // add in some more text here based on status
610 switch (i->second->Status)
612 case cmPolicies::WARN:
613 full << "warns when the policy is not set and uses OLD behavior. "
614 << "Use the cmake_policy command to set it to OLD or NEW "
615 << "explicitly.";
616 break;
617 case cmPolicies::OLD:
618 full << "defaults to the OLD behavior for this policy.";
619 break;
620 case cmPolicies::NEW:
621 full << "defaults to the NEW behavior for this policy.";
622 break;
623 case cmPolicies::REQUIRED_IF_USED:
624 full << "requires the policy to be set to NEW if you use it. "
625 << "Use the cmake_policy command to set it to NEW.";
626 break;
627 case cmPolicies::REQUIRED_ALWAYS:
628 full << "requires the policy to be set to NEW. "
629 << "Use the cmake_policy command to set it to NEW.";
630 break;
633 cmDocumentationEntry e(i->second->IDString.c_str(),
634 i->second->ShortDescription.c_str(),
635 full.str().c_str());
636 v.push_back(e);
640 //----------------------------------------------------------------------------
641 std::string
642 cmPolicies::GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id)
644 std::string pid = this->GetPolicyIDString(id);
645 cmOStringStream e;
646 e << "Policy " << pid << " may not be set to OLD behavior because this "
647 << "version of CMake no longer supports it. "
648 << "The policy was introduced in "
649 << "CMake version " << this->Policies[id]->GetVersionString()
650 << ", and use of NEW behavior is now required."
651 << "\n"
652 << "Please either update your CMakeLists.txt files to conform to "
653 << "the new behavior or use an older version of CMake that still "
654 << "supports the old behavior. "
655 << "Run cmake --help-policy " << pid << " for more information.";
656 return e.str();
659 //----------------------------------------------------------------------------
660 void
661 cmPolicies::DiagnoseAncientPolicies(std::vector<PolicyID> const& ancient,
662 unsigned int majorVer,
663 unsigned int minorVer,
664 unsigned int patchVer,
665 cmMakefile* mf)
667 cmOStringStream e;
668 e << "The project requests behavior compatible with CMake version \""
669 << majorVer << "." << minorVer << "." << patchVer
670 << "\", which requires OLD the behavior for some policies:\n";
671 for(std::vector<PolicyID>::const_iterator
672 i = ancient.begin(); i != ancient.end(); ++i)
674 cmPolicy const* policy = this->Policies[*i];
675 e << " " << policy->IDString << ": " << policy->ShortDescription << "\n";
677 e << "However, this version of CMake no longer supports the OLD "
678 << "behavior for these policies. "
679 << "Please either update your CMakeLists.txt files to conform to "
680 << "the new behavior or use an older version of CMake that still "
681 << "supports the old behavior.";
682 mf->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());