cmPolicies.cxx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  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. this->DefinePolicy(
  295. CMP0052, "CMP0052",
  296. "Reject source and build dirs in installed "
  297. "INTERFACE_INCLUDE_DIRECTORIES.",
  298. 3,1,0, cmPolicies::WARN);
  299. this->DefinePolicy(
  300. CMP0053, "CMP0053",
  301. "Simplify variable reference and escape sequence evaluation.",
  302. 3,1,0, cmPolicies::WARN);
  303. this->DefinePolicy(
  304. CMP0054, "CMP0054",
  305. "Only interpret if() arguments as variables or keywords when unquoted.",
  306. 3,1,0, cmPolicies::WARN);
  307. }
  308. cmPolicies::~cmPolicies()
  309. {
  310. // free the policies
  311. std::map<cmPolicies::PolicyID,cmPolicy *>::iterator i
  312. = this->Policies.begin();
  313. for (;i != this->Policies.end(); ++i)
  314. {
  315. delete i->second;
  316. }
  317. }
  318. void cmPolicies::DefinePolicy(cmPolicies::PolicyID iD,
  319. const char *idString,
  320. const char *shortDescription,
  321. unsigned int majorVersionIntroduced,
  322. unsigned int minorVersionIntroduced,
  323. unsigned int patchVersionIntroduced,
  324. cmPolicies::PolicyStatus status)
  325. {
  326. // a policy must be unique and can only be defined once
  327. if (this->Policies.find(iD) != this->Policies.end())
  328. {
  329. cmSystemTools::Error("Attempt to redefine a CMake policy for policy "
  330. "ID ", this->GetPolicyIDString(iD).c_str());
  331. return;
  332. }
  333. this->Policies[iD] = new cmPolicy(iD, idString,
  334. shortDescription,
  335. majorVersionIntroduced,
  336. minorVersionIntroduced,
  337. patchVersionIntroduced,
  338. status);
  339. this->PolicyStringMap[idString] = iD;
  340. }
  341. //----------------------------------------------------------------------------
  342. bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
  343. const char *version)
  344. {
  345. std::string ver = "2.4.0";
  346. if (version && strlen(version) > 0)
  347. {
  348. ver = version;
  349. }
  350. unsigned int majorVer = 2;
  351. unsigned int minorVer = 0;
  352. unsigned int patchVer = 0;
  353. unsigned int tweakVer = 0;
  354. // parse the string
  355. if(sscanf(ver.c_str(), "%u.%u.%u.%u",
  356. &majorVer, &minorVer, &patchVer, &tweakVer) < 2)
  357. {
  358. cmOStringStream e;
  359. e << "Invalid policy version value \"" << ver << "\". "
  360. << "A numeric major.minor[.patch[.tweak]] must be given.";
  361. mf->IssueMessage(cmake::FATAL_ERROR, e.str());
  362. return false;
  363. }
  364. // it is an error if the policy version is less than 2.4
  365. if (majorVer < 2 || (majorVer == 2 && minorVer < 4))
  366. {
  367. mf->IssueMessage(cmake::FATAL_ERROR,
  368. "Compatibility with CMake < 2.4 is not supported by CMake >= 3.0. "
  369. "For compatibility with older versions please use any CMake 2.8.x "
  370. "release or lower.");
  371. return false;
  372. }
  373. // It is an error if the policy version is greater than the running
  374. // CMake.
  375. if (majorVer > cmVersion::GetMajorVersion() ||
  376. (majorVer == cmVersion::GetMajorVersion() &&
  377. minorVer > cmVersion::GetMinorVersion()) ||
  378. (majorVer == cmVersion::GetMajorVersion() &&
  379. minorVer == cmVersion::GetMinorVersion() &&
  380. patchVer > cmVersion::GetPatchVersion()) ||
  381. (majorVer == cmVersion::GetMajorVersion() &&
  382. minorVer == cmVersion::GetMinorVersion() &&
  383. patchVer == cmVersion::GetPatchVersion() &&
  384. tweakVer > cmVersion::GetTweakVersion()))
  385. {
  386. cmOStringStream e;
  387. e << "An attempt was made to set the policy version of CMake to \""
  388. << version << "\" which is greater than this version of CMake. "
  389. << "This is not allowed because the greater version may have new "
  390. << "policies not known to this CMake. "
  391. << "You may need a newer CMake version to build this project.";
  392. mf->IssueMessage(cmake::FATAL_ERROR, e.str());
  393. return false;
  394. }
  395. // now loop over all the policies and set them as appropriate
  396. std::vector<cmPolicies::PolicyID> ancientPolicies;
  397. for(std::map<cmPolicies::PolicyID,cmPolicy *>::iterator i
  398. = this->Policies.begin(); i != this->Policies.end(); ++i)
  399. {
  400. if (i->second->IsPolicyNewerThan(majorVer,minorVer,patchVer))
  401. {
  402. if(i->second->Status == cmPolicies::REQUIRED_ALWAYS)
  403. {
  404. ancientPolicies.push_back(i->first);
  405. }
  406. else
  407. {
  408. cmPolicies::PolicyStatus status = cmPolicies::WARN;
  409. if(!this->GetPolicyDefault(mf, i->second->IDString, &status) ||
  410. !mf->SetPolicy(i->second->ID, status))
  411. {
  412. return false;
  413. }
  414. }
  415. }
  416. else
  417. {
  418. if (!mf->SetPolicy(i->second->ID, cmPolicies::NEW))
  419. {
  420. return false;
  421. }
  422. }
  423. }
  424. // Make sure the project does not use any ancient policies.
  425. if(!ancientPolicies.empty())
  426. {
  427. this->DiagnoseAncientPolicies(ancientPolicies,
  428. majorVer, minorVer, patchVer, mf);
  429. cmSystemTools::SetFatalErrorOccured();
  430. return false;
  431. }
  432. return true;
  433. }
  434. //----------------------------------------------------------------------------
  435. bool cmPolicies::GetPolicyDefault(cmMakefile* mf, std::string const& policy,
  436. cmPolicies::PolicyStatus* defaultSetting)
  437. {
  438. std::string defaultVar = "CMAKE_POLICY_DEFAULT_" + policy;
  439. std::string defaultValue = mf->GetSafeDefinition(defaultVar);
  440. if(defaultValue == "NEW")
  441. {
  442. *defaultSetting = cmPolicies::NEW;
  443. }
  444. else if(defaultValue == "OLD")
  445. {
  446. *defaultSetting = cmPolicies::OLD;
  447. }
  448. else if(defaultValue == "")
  449. {
  450. *defaultSetting = cmPolicies::WARN;
  451. }
  452. else
  453. {
  454. cmOStringStream e;
  455. e << defaultVar << " has value \"" << defaultValue
  456. << "\" but must be \"OLD\", \"NEW\", or \"\" (empty).";
  457. mf->IssueMessage(cmake::FATAL_ERROR, e.str());
  458. return false;
  459. }
  460. return true;
  461. }
  462. bool cmPolicies::GetPolicyID(const char *id, cmPolicies::PolicyID &pid)
  463. {
  464. if (!id || strlen(id) < 1)
  465. {
  466. return false;
  467. }
  468. std::map<std::string,cmPolicies::PolicyID>::iterator pos =
  469. this->PolicyStringMap.find(id);
  470. if (pos == this->PolicyStringMap.end())
  471. {
  472. return false;
  473. }
  474. pid = pos->second;
  475. return true;
  476. }
  477. std::string cmPolicies::GetPolicyIDString(cmPolicies::PolicyID pid)
  478. {
  479. std::map<cmPolicies::PolicyID,cmPolicy *>::iterator pos =
  480. this->Policies.find(pid);
  481. if (pos == this->Policies.end())
  482. {
  483. return "";
  484. }
  485. return pos->second->IDString;
  486. }
  487. ///! return a warning string for a given policy
  488. std::string cmPolicies::GetPolicyWarning(cmPolicies::PolicyID id)
  489. {
  490. std::map<cmPolicies::PolicyID,cmPolicy *>::iterator pos =
  491. this->Policies.find(id);
  492. if (pos == this->Policies.end())
  493. {
  494. cmSystemTools::Error(
  495. "Request for warning text for undefined policy!");
  496. return "Request for warning text for undefined policy!";
  497. }
  498. cmOStringStream msg;
  499. msg <<
  500. "Policy " << pos->second->IDString << " is not set: "
  501. "" << pos->second->ShortDescription << " "
  502. "Run \"cmake --help-policy " << pos->second->IDString << "\" for "
  503. "policy details. "
  504. "Use the cmake_policy command to set the policy "
  505. "and suppress this warning.";
  506. return msg.str();
  507. }
  508. ///! return an error string for when a required policy is unspecified
  509. std::string cmPolicies::GetRequiredPolicyError(cmPolicies::PolicyID id)
  510. {
  511. std::map<cmPolicies::PolicyID,cmPolicy *>::iterator pos =
  512. this->Policies.find(id);
  513. if (pos == this->Policies.end())
  514. {
  515. cmSystemTools::Error(
  516. "Request for error text for undefined policy!");
  517. return "Request for error text for undefined policy!";
  518. }
  519. cmOStringStream error;
  520. error <<
  521. "Policy " << pos->second->IDString << " is not set to NEW: "
  522. "" << pos->second->ShortDescription << " "
  523. "Run \"cmake --help-policy " << pos->second->IDString << "\" for "
  524. "policy details. "
  525. "CMake now requires this policy to be set to NEW by the project. "
  526. "The policy may be set explicitly using the code\n"
  527. " cmake_policy(SET " << pos->second->IDString << " NEW)\n"
  528. "or by upgrading all policies with the code\n"
  529. " cmake_policy(VERSION " << pos->second->GetVersionString() <<
  530. ") # or later\n"
  531. "Run \"cmake --help-command cmake_policy\" for more information.";
  532. return error.str();
  533. }
  534. ///! Get the default status for a policy
  535. cmPolicies::PolicyStatus
  536. cmPolicies::GetPolicyStatus(cmPolicies::PolicyID id)
  537. {
  538. // if the policy is not know then what?
  539. std::map<cmPolicies::PolicyID,cmPolicy *>::iterator pos =
  540. this->Policies.find(id);
  541. if (pos == this->Policies.end())
  542. {
  543. // TODO is this right?
  544. return cmPolicies::WARN;
  545. }
  546. return pos->second->Status;
  547. }
  548. //----------------------------------------------------------------------------
  549. std::string
  550. cmPolicies::GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id)
  551. {
  552. std::string pid = this->GetPolicyIDString(id);
  553. cmOStringStream e;
  554. e << "Policy " << pid << " may not be set to OLD behavior because this "
  555. << "version of CMake no longer supports it. "
  556. << "The policy was introduced in "
  557. << "CMake version " << this->Policies[id]->GetVersionString()
  558. << ", and use of NEW behavior is now required."
  559. << "\n"
  560. << "Please either update your CMakeLists.txt files to conform to "
  561. << "the new behavior or use an older version of CMake that still "
  562. << "supports the old behavior. "
  563. << "Run cmake --help-policy " << pid << " for more information.";
  564. return e.str();
  565. }
  566. //----------------------------------------------------------------------------
  567. void
  568. cmPolicies::DiagnoseAncientPolicies(std::vector<PolicyID> const& ancient,
  569. unsigned int majorVer,
  570. unsigned int minorVer,
  571. unsigned int patchVer,
  572. cmMakefile* mf)
  573. {
  574. cmOStringStream e;
  575. e << "The project requests behavior compatible with CMake version \""
  576. << majorVer << "." << minorVer << "." << patchVer
  577. << "\", which requires the OLD behavior for some policies:\n";
  578. for(std::vector<PolicyID>::const_iterator
  579. i = ancient.begin(); i != ancient.end(); ++i)
  580. {
  581. cmPolicy const* policy = this->Policies[*i];
  582. e << " " << policy->IDString << ": " << policy->ShortDescription << "\n";
  583. }
  584. e << "However, this version of CMake no longer supports the OLD "
  585. << "behavior for these policies. "
  586. << "Please either update your CMakeLists.txt files to conform to "
  587. << "the new behavior or use an older version of CMake that still "
  588. << "supports the old behavior.";
  589. mf->IssueMessage(cmake::FATAL_ERROR, e.str());
  590. }