cmPolicies.cxx 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. #include "cmPolicies.h"
  2. #include "cmake.h"
  3. #include "cmMakefile.h"
  4. #include "cmSourceFile.h"
  5. #include "cmVersion.h"
  6. #include "cmVersionMacros.h"
  7. #include <map>
  8. #include <set>
  9. #include <queue>
  10. #include <assert.h>
  11. const char* cmPolicies::PolicyStatusNames[] = {
  12. "OLD", "WARN", "NEW", "REQUIRED_IF_USED", "REQUIRED_ALWAYS"
  13. };
  14. class cmPolicy
  15. {
  16. public:
  17. cmPolicy(cmPolicies::PolicyID iD,
  18. const char *idString,
  19. const char *shortDescription,
  20. unsigned int majorVersionIntroduced,
  21. unsigned int minorVersionIntroduced,
  22. unsigned int patchVersionIntroduced,
  23. cmPolicies::PolicyStatus status)
  24. {
  25. if (!idString || !shortDescription)
  26. {
  27. cmSystemTools::Error("Attempt to define a policy without "
  28. "all parameters being specified!");
  29. return;
  30. }
  31. this->ID = iD;
  32. this->IDString = idString;
  33. this->ShortDescription = shortDescription;
  34. this->MajorVersionIntroduced = majorVersionIntroduced;
  35. this->MinorVersionIntroduced = minorVersionIntroduced;
  36. this->PatchVersionIntroduced = patchVersionIntroduced;
  37. this->Status = status;
  38. }
  39. std::string GetVersionString()
  40. {
  41. cmOStringStream v;
  42. v << this->MajorVersionIntroduced << "." << this->MinorVersionIntroduced;
  43. if(this->PatchVersionIntroduced > 0)
  44. {
  45. v << "." << this->PatchVersionIntroduced;
  46. }
  47. return v.str();
  48. }
  49. bool IsPolicyNewerThan(unsigned int majorV,
  50. unsigned int minorV,
  51. unsigned int patchV)
  52. {
  53. if (majorV < this->MajorVersionIntroduced)
  54. {
  55. return true;
  56. }
  57. if (majorV > this->MajorVersionIntroduced)
  58. {
  59. return false;
  60. }
  61. if (minorV < this->MinorVersionIntroduced)
  62. {
  63. return true;
  64. }
  65. if (minorV > this->MinorVersionIntroduced)
  66. {
  67. return false;
  68. }
  69. return (patchV < this->PatchVersionIntroduced);
  70. }
  71. cmPolicies::PolicyID ID;
  72. std::string IDString;
  73. std::string ShortDescription;
  74. unsigned int MajorVersionIntroduced;
  75. unsigned int MinorVersionIntroduced;
  76. unsigned int PatchVersionIntroduced;
  77. cmPolicies::PolicyStatus Status;
  78. };
  79. cmPolicies::cmPolicies()
  80. {
  81. // define all the policies
  82. this->DefinePolicy(
  83. CMP0000, "CMP0000",
  84. "A minimum required CMake version must be specified.",
  85. 2,6,0, cmPolicies::WARN
  86. );
  87. this->DefinePolicy(
  88. CMP0001, "CMP0001",
  89. "CMAKE_BACKWARDS_COMPATIBILITY should no longer be used.",
  90. 2,6,0, cmPolicies::WARN
  91. );
  92. this->DefinePolicy(
  93. CMP0002, "CMP0002",
  94. "Logical target names must be globally unique.",
  95. 2,6,0, cmPolicies::WARN
  96. );
  97. this->DefinePolicy(
  98. CMP0003, "CMP0003",
  99. "Libraries linked via full path no longer produce linker search paths.",
  100. 2,6,0, cmPolicies::WARN);
  101. this->DefinePolicy(
  102. CMP0004, "CMP0004",
  103. "Libraries linked may not have leading or trailing whitespace.",
  104. 2,6,0, cmPolicies::WARN);
  105. this->DefinePolicy(
  106. CMP0005, "CMP0005",
  107. "Preprocessor definition values are now escaped automatically.",
  108. 2,6,0, cmPolicies::WARN);
  109. this->DefinePolicy(
  110. CMP0006, "CMP0006",
  111. "Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION.",
  112. 2,6,0, cmPolicies::WARN);
  113. this->DefinePolicy(
  114. CMP0007, "CMP0007",
  115. "list command no longer ignores empty elements.",
  116. 2,6,0, cmPolicies::WARN);
  117. this->DefinePolicy(
  118. CMP0008, "CMP0008",
  119. "Libraries linked by full-path must have a valid library file name.",
  120. 2,6,1, cmPolicies::WARN);
  121. this->DefinePolicy(
  122. CMP0009, "CMP0009",
  123. "FILE GLOB_RECURSE calls should not follow symlinks by default.",
  124. 2,6,2, cmPolicies::WARN);
  125. this->DefinePolicy(
  126. CMP0010, "CMP0010",
  127. "Bad variable reference syntax is an error.",
  128. 2,6,3, cmPolicies::WARN);
  129. this->DefinePolicy(
  130. CMP0011, "CMP0011",
  131. "Included scripts do automatic cmake_policy PUSH and POP.",
  132. 2,6,3, cmPolicies::WARN);
  133. this->DefinePolicy(
  134. CMP0012, "CMP0012",
  135. "if() recognizes numbers and boolean constants.",
  136. 2,8,0, cmPolicies::WARN);
  137. this->DefinePolicy(
  138. CMP0013, "CMP0013",
  139. "Duplicate binary directories are not allowed.",
  140. 2,8,0, cmPolicies::WARN);
  141. this->DefinePolicy(
  142. CMP0014, "CMP0014",
  143. "Input directories must have CMakeLists.txt.",
  144. 2,8,0, cmPolicies::WARN);
  145. this->DefinePolicy(
  146. CMP0015, "CMP0015",
  147. "link_directories() treats paths relative to the source dir.",
  148. 2,8,1, cmPolicies::WARN);
  149. this->DefinePolicy(
  150. CMP0016, "CMP0016",
  151. "target_link_libraries() reports error if its only argument "
  152. "is not a target.",
  153. 2,8,3, cmPolicies::WARN);
  154. this->DefinePolicy(
  155. CMP0017, "CMP0017",
  156. "Prefer files from the CMake module directory when including from there.",
  157. 2,8,4, cmPolicies::WARN);
  158. this->DefinePolicy(
  159. CMP0018, "CMP0018",
  160. "Ignore CMAKE_SHARED_LIBRARY_<Lang>_FLAGS variable.",
  161. 2,8,9, cmPolicies::WARN);
  162. this->DefinePolicy(
  163. CMP0019, "CMP0019",
  164. "Do not re-expand variables in include and link information.",
  165. 2,8,11, cmPolicies::WARN);
  166. this->DefinePolicy(
  167. CMP0020, "CMP0020",
  168. "Automatically link Qt executables to qtmain target on Windows.",
  169. 2,8,11, cmPolicies::WARN);
  170. this->DefinePolicy(
  171. CMP0021, "CMP0021",
  172. "Fatal error on relative paths in INCLUDE_DIRECTORIES target property.",
  173. 2,8,12, cmPolicies::WARN);
  174. this->DefinePolicy(
  175. CMP0022, "CMP0022",
  176. "INTERFACE_LINK_LIBRARIES defines the link interface.",
  177. 2,8,12, cmPolicies::WARN);
  178. this->DefinePolicy(
  179. CMP0023, "CMP0023",
  180. "Plain and keyword target_link_libraries signatures cannot be mixed.",
  181. 2,8,12, cmPolicies::WARN);
  182. this->DefinePolicy(
  183. CMP0024, "CMP0024",
  184. "Disallow include export result.",
  185. 3,0,0, cmPolicies::WARN);
  186. this->DefinePolicy(
  187. CMP0025, "CMP0025",
  188. "Compiler id for Apple Clang is now AppleClang.",
  189. 3,0,0, cmPolicies::WARN);
  190. this->DefinePolicy(
  191. CMP0026, "CMP0026",
  192. "Disallow use of the LOCATION target property.",
  193. 3,0,0, cmPolicies::WARN);
  194. this->DefinePolicy(
  195. CMP0027, "CMP0027",
  196. "Conditionally linked imported targets with missing include directories.",
  197. 3,0,0, cmPolicies::WARN);
  198. this->DefinePolicy(
  199. CMP0028, "CMP0028",
  200. "Double colon in target name means ALIAS or IMPORTED target.",
  201. 3,0,0, cmPolicies::WARN);
  202. this->DefinePolicy(
  203. CMP0029, "CMP0029",
  204. "The subdir_depends command should not be called.",
  205. 3,0,0, cmPolicies::WARN);
  206. this->DefinePolicy(
  207. CMP0030, "CMP0030",
  208. "The use_mangled_mesa command should not be called.",
  209. 3,0,0, cmPolicies::WARN);
  210. this->DefinePolicy(
  211. CMP0031, "CMP0031",
  212. "The load_command command should not be called.",
  213. 3,0,0, cmPolicies::WARN);
  214. this->DefinePolicy(
  215. CMP0032, "CMP0032",
  216. "The output_required_files command should not be called.",
  217. 3,0,0, cmPolicies::WARN);
  218. this->DefinePolicy(
  219. CMP0033, "CMP0033",
  220. "The export_library_dependencies command should not be called.",
  221. 3,0,0, cmPolicies::WARN);
  222. this->DefinePolicy(
  223. CMP0034, "CMP0034",
  224. "The utility_source command should not be called.",
  225. 3,0,0, cmPolicies::WARN);
  226. this->DefinePolicy(
  227. CMP0035, "CMP0035",
  228. "The variable_requires command should not be called.",
  229. 3,0,0, cmPolicies::WARN);
  230. this->DefinePolicy(
  231. CMP0036, "CMP0036",
  232. "The build_name command should not be called.",
  233. 3,0,0, cmPolicies::WARN);
  234. this->DefinePolicy(
  235. CMP0037, "CMP0037",
  236. "Target names should not be reserved and should match a validity pattern.",
  237. 3,0,0, cmPolicies::WARN);
  238. this->DefinePolicy(
  239. CMP0038, "CMP0038",
  240. "Targets may not link directly to themselves.",
  241. 3,0,0, cmPolicies::WARN);
  242. this->DefinePolicy(
  243. CMP0039, "CMP0039",
  244. "Utility targets may not have link dependencies.",
  245. 3,0,0, cmPolicies::WARN);
  246. this->DefinePolicy(
  247. CMP0040, "CMP0040",
  248. "The target in the TARGET signature of add_custom_command() must exist.",
  249. 3,0,0, cmPolicies::WARN);
  250. this->DefinePolicy(
  251. CMP0041, "CMP0041",
  252. "Error on relative include with generator expression.",
  253. 3,0,0, cmPolicies::WARN);
  254. this->DefinePolicy(
  255. CMP0042, "CMP0042",
  256. "MACOSX_RPATH is enabled by default.",
  257. 3,0,0, cmPolicies::WARN);
  258. this->DefinePolicy(
  259. CMP0043, "CMP0043",
  260. "Ignore COMPILE_DEFINITIONS_<Config> properties.",
  261. 3,0,0, cmPolicies::WARN);
  262. this->DefinePolicy(
  263. CMP0044, "CMP0044",
  264. "Case sensitive <LANG>_COMPILER_ID generator expressions.",
  265. 3,0,0, cmPolicies::WARN);
  266. this->DefinePolicy(
  267. CMP0045, "CMP0045",
  268. "Error on non-existent target in get_target_property.",
  269. 3,0,0, cmPolicies::WARN);
  270. this->DefinePolicy(
  271. CMP0046, "CMP0046",
  272. "Error on non-existent dependency in add_dependencies.",
  273. 3,0,0, cmPolicies::WARN);
  274. this->DefinePolicy(
  275. CMP0047, "CMP0047",
  276. "Use QCC compiler id for the qcc drivers on QNX.",
  277. 3,0,0, cmPolicies::WARN);
  278. this->DefinePolicy(
  279. CMP0048, "CMP0048",
  280. "project() command manages VERSION variables.",
  281. 3,0,0, cmPolicies::WARN);
  282. this->DefinePolicy(
  283. CMP0049, "CMP0049",
  284. "Do not expand variables in target source entries.",
  285. 3,0,0, cmPolicies::WARN);
  286. this->DefinePolicy(
  287. CMP0050, "CMP0050",
  288. "Disallow add_custom_command SOURCE signatures.",
  289. 3,0,0, cmPolicies::WARN);
  290. this->DefinePolicy(
  291. CMP0051, "CMP0051",
  292. "List TARGET_OBJECTS in SOURCES target property.",
  293. 3,1,0, cmPolicies::WARN);
  294. }
  295. cmPolicies::~cmPolicies()
  296. {
  297. // free the policies
  298. std::map<cmPolicies::PolicyID,cmPolicy *>::iterator i
  299. = this->Policies.begin();
  300. for (;i != this->Policies.end(); ++i)
  301. {
  302. delete i->second;
  303. }
  304. }
  305. void cmPolicies::DefinePolicy(cmPolicies::PolicyID iD,
  306. const char *idString,
  307. const char *shortDescription,
  308. unsigned int majorVersionIntroduced,
  309. unsigned int minorVersionIntroduced,
  310. unsigned int patchVersionIntroduced,
  311. cmPolicies::PolicyStatus status)
  312. {
  313. // a policy must be unique and can only be defined once
  314. if (this->Policies.find(iD) != this->Policies.end())
  315. {
  316. cmSystemTools::Error("Attempt to redefine a CMake policy for policy "
  317. "ID ", this->GetPolicyIDString(iD).c_str());
  318. return;
  319. }
  320. this->Policies[iD] = new cmPolicy(iD, idString,
  321. shortDescription,
  322. majorVersionIntroduced,
  323. minorVersionIntroduced,
  324. patchVersionIntroduced,
  325. status);
  326. this->PolicyStringMap[idString] = iD;
  327. }
  328. //----------------------------------------------------------------------------
  329. bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
  330. const char *version)
  331. {
  332. std::string ver = "2.4.0";
  333. if (version && strlen(version) > 0)
  334. {
  335. ver = version;
  336. }
  337. unsigned int majorVer = 2;
  338. unsigned int minorVer = 0;
  339. unsigned int patchVer = 0;
  340. unsigned int tweakVer = 0;
  341. // parse the string
  342. if(sscanf(ver.c_str(), "%u.%u.%u.%u",
  343. &majorVer, &minorVer, &patchVer, &tweakVer) < 2)
  344. {
  345. cmOStringStream e;
  346. e << "Invalid policy version value \"" << ver << "\". "
  347. << "A numeric major.minor[.patch[.tweak]] must be given.";
  348. mf->IssueMessage(cmake::FATAL_ERROR, e.str());
  349. return false;
  350. }
  351. // it is an error if the policy version is less than 2.4
  352. if (majorVer < 2 || (majorVer == 2 && minorVer < 4))
  353. {
  354. mf->IssueMessage(cmake::FATAL_ERROR,
  355. "Compatibility with CMake < 2.4 is not supported by CMake >= 3.0. "
  356. "For compatibility with older versions please use any CMake 2.8.x "
  357. "release or lower.");
  358. return false;
  359. }
  360. // It is an error if the policy version is greater than the running
  361. // CMake.
  362. if (majorVer > cmVersion::GetMajorVersion() ||
  363. (majorVer == cmVersion::GetMajorVersion() &&
  364. minorVer > cmVersion::GetMinorVersion()) ||
  365. (majorVer == cmVersion::GetMajorVersion() &&
  366. minorVer == cmVersion::GetMinorVersion() &&
  367. patchVer > cmVersion::GetPatchVersion()) ||
  368. (majorVer == cmVersion::GetMajorVersion() &&
  369. minorVer == cmVersion::GetMinorVersion() &&
  370. patchVer == cmVersion::GetPatchVersion() &&
  371. tweakVer > cmVersion::GetTweakVersion()))
  372. {
  373. cmOStringStream e;
  374. e << "An attempt was made to set the policy version of CMake to \""
  375. << version << "\" which is greater than this version of CMake. "
  376. << "This is not allowed because the greater version may have new "
  377. << "policies not known to this CMake. "
  378. << "You may need a newer CMake version to build this project.";
  379. mf->IssueMessage(cmake::FATAL_ERROR, e.str());
  380. return false;
  381. }
  382. // now loop over all the policies and set them as appropriate
  383. std::vector<cmPolicies::PolicyID> ancientPolicies;
  384. for(std::map<cmPolicies::PolicyID,cmPolicy *>::iterator i
  385. = this->Policies.begin(); i != this->Policies.end(); ++i)
  386. {
  387. if (i->second->IsPolicyNewerThan(majorVer,minorVer,patchVer))
  388. {
  389. if(i->second->Status == cmPolicies::REQUIRED_ALWAYS)
  390. {
  391. ancientPolicies.push_back(i->first);
  392. }
  393. else
  394. {
  395. cmPolicies::PolicyStatus status = cmPolicies::WARN;
  396. if(!this->GetPolicyDefault(mf, i->second->IDString, &status) ||
  397. !mf->SetPolicy(i->second->ID, status))
  398. {
  399. return false;
  400. }
  401. }
  402. }
  403. else
  404. {
  405. if (!mf->SetPolicy(i->second->ID, cmPolicies::NEW))
  406. {
  407. return false;
  408. }
  409. }
  410. }
  411. // Make sure the project does not use any ancient policies.
  412. if(!ancientPolicies.empty())
  413. {
  414. this->DiagnoseAncientPolicies(ancientPolicies,
  415. majorVer, minorVer, patchVer, mf);
  416. cmSystemTools::SetFatalErrorOccured();
  417. return false;
  418. }
  419. return true;
  420. }
  421. //----------------------------------------------------------------------------
  422. bool cmPolicies::GetPolicyDefault(cmMakefile* mf, std::string const& policy,
  423. cmPolicies::PolicyStatus* defaultSetting)
  424. {
  425. std::string defaultVar = "CMAKE_POLICY_DEFAULT_" + policy;
  426. std::string defaultValue = mf->GetSafeDefinition(defaultVar);
  427. if(defaultValue == "NEW")
  428. {
  429. *defaultSetting = cmPolicies::NEW;
  430. }
  431. else if(defaultValue == "OLD")
  432. {
  433. *defaultSetting = cmPolicies::OLD;
  434. }
  435. else if(defaultValue == "")
  436. {
  437. *defaultSetting = cmPolicies::WARN;
  438. }
  439. else
  440. {
  441. cmOStringStream e;
  442. e << defaultVar << " has value \"" << defaultValue
  443. << "\" but must be \"OLD\", \"NEW\", or \"\" (empty).";
  444. mf->IssueMessage(cmake::FATAL_ERROR, e.str());
  445. return false;
  446. }
  447. return true;
  448. }
  449. bool cmPolicies::GetPolicyID(const char *id, cmPolicies::PolicyID &pid)
  450. {
  451. if (!id || strlen(id) < 1)
  452. {
  453. return false;
  454. }
  455. std::map<std::string,cmPolicies::PolicyID>::iterator pos =
  456. this->PolicyStringMap.find(id);
  457. if (pos == this->PolicyStringMap.end())
  458. {
  459. return false;
  460. }
  461. pid = pos->second;
  462. return true;
  463. }
  464. std::string cmPolicies::GetPolicyIDString(cmPolicies::PolicyID pid)
  465. {
  466. std::map<cmPolicies::PolicyID,cmPolicy *>::iterator pos =
  467. this->Policies.find(pid);
  468. if (pos == this->Policies.end())
  469. {
  470. return "";
  471. }
  472. return pos->second->IDString;
  473. }
  474. ///! return a warning string for a given policy
  475. std::string cmPolicies::GetPolicyWarning(cmPolicies::PolicyID id)
  476. {
  477. std::map<cmPolicies::PolicyID,cmPolicy *>::iterator pos =
  478. this->Policies.find(id);
  479. if (pos == this->Policies.end())
  480. {
  481. cmSystemTools::Error(
  482. "Request for warning text for undefined policy!");
  483. return "Request for warning text for undefined policy!";
  484. }
  485. cmOStringStream msg;
  486. msg <<
  487. "Policy " << pos->second->IDString << " is not set: "
  488. "" << pos->second->ShortDescription << " "
  489. "Run \"cmake --help-policy " << pos->second->IDString << "\" for "
  490. "policy details. "
  491. "Use the cmake_policy command to set the policy "
  492. "and suppress this warning.";
  493. return msg.str();
  494. }
  495. ///! return an error string for when a required policy is unspecified
  496. std::string cmPolicies::GetRequiredPolicyError(cmPolicies::PolicyID id)
  497. {
  498. std::map<cmPolicies::PolicyID,cmPolicy *>::iterator pos =
  499. this->Policies.find(id);
  500. if (pos == this->Policies.end())
  501. {
  502. cmSystemTools::Error(
  503. "Request for error text for undefined policy!");
  504. return "Request for error text for undefined policy!";
  505. }
  506. cmOStringStream error;
  507. error <<
  508. "Policy " << pos->second->IDString << " is not set to NEW: "
  509. "" << pos->second->ShortDescription << " "
  510. "Run \"cmake --help-policy " << pos->second->IDString << "\" for "
  511. "policy details. "
  512. "CMake now requires this policy to be set to NEW by the project. "
  513. "The policy may be set explicitly using the code\n"
  514. " cmake_policy(SET " << pos->second->IDString << " NEW)\n"
  515. "or by upgrading all policies with the code\n"
  516. " cmake_policy(VERSION " << pos->second->GetVersionString() <<
  517. ") # or later\n"
  518. "Run \"cmake --help-command cmake_policy\" for more information.";
  519. return error.str();
  520. }
  521. ///! Get the default status for a policy
  522. cmPolicies::PolicyStatus
  523. cmPolicies::GetPolicyStatus(cmPolicies::PolicyID id)
  524. {
  525. // if the policy is not know then what?
  526. std::map<cmPolicies::PolicyID,cmPolicy *>::iterator pos =
  527. this->Policies.find(id);
  528. if (pos == this->Policies.end())
  529. {
  530. // TODO is this right?
  531. return cmPolicies::WARN;
  532. }
  533. return pos->second->Status;
  534. }
  535. //----------------------------------------------------------------------------
  536. std::string
  537. cmPolicies::GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id)
  538. {
  539. std::string pid = this->GetPolicyIDString(id);
  540. cmOStringStream e;
  541. e << "Policy " << pid << " may not be set to OLD behavior because this "
  542. << "version of CMake no longer supports it. "
  543. << "The policy was introduced in "
  544. << "CMake version " << this->Policies[id]->GetVersionString()
  545. << ", and use of NEW behavior is now required."
  546. << "\n"
  547. << "Please either update your CMakeLists.txt files to conform to "
  548. << "the new behavior or use an older version of CMake that still "
  549. << "supports the old behavior. "
  550. << "Run cmake --help-policy " << pid << " for more information.";
  551. return e.str();
  552. }
  553. //----------------------------------------------------------------------------
  554. void
  555. cmPolicies::DiagnoseAncientPolicies(std::vector<PolicyID> const& ancient,
  556. unsigned int majorVer,
  557. unsigned int minorVer,
  558. unsigned int patchVer,
  559. cmMakefile* mf)
  560. {
  561. cmOStringStream e;
  562. e << "The project requests behavior compatible with CMake version \""
  563. << majorVer << "." << minorVer << "." << patchVer
  564. << "\", which requires the OLD behavior for some policies:\n";
  565. for(std::vector<PolicyID>::const_iterator
  566. i = ancient.begin(); i != ancient.end(); ++i)
  567. {
  568. cmPolicy const* policy = this->Policies[*i];
  569. e << " " << policy->IDString << ": " << policy->ShortDescription << "\n";
  570. }
  571. e << "However, this version of CMake no longer supports the OLD "
  572. << "behavior for these policies. "
  573. << "Please either update your CMakeLists.txt files to conform to "
  574. << "the new behavior or use an older version of CMake that still "
  575. << "supports the old behavior.";
  576. mf->IssueMessage(cmake::FATAL_ERROR, e.str());
  577. }