cmPolicies.h 48 KB

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