2008-02-29 20:28:46 +00:00
|
|
|
#include "cmPolicies.h"
|
|
|
|
#include "cmake.h"
|
|
|
|
#include "cmMakefile.h"
|
|
|
|
#include "cmSourceFile.h"
|
2008-03-08 14:13:13 +00:00
|
|
|
#include "cmVersion.h"
|
2010-04-23 13:50:31 +00:00
|
|
|
#include "cmVersionMacros.h"
|
2008-02-29 20:28:46 +00:00
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
#include <queue>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
const char* cmPolicies::PolicyStatusNames[] = {
|
|
|
|
"OLD", "WARN", "NEW", "REQUIRED_IF_USED", "REQUIRED_ALWAYS"
|
|
|
|
};
|
|
|
|
|
|
|
|
class cmPolicy
|
|
|
|
{
|
2010-08-28 14:01:49 +00:00
|
|
|
public:
|
|
|
|
cmPolicy(cmPolicies::PolicyID iD,
|
2008-02-29 20:28:46 +00:00
|
|
|
const char *idString,
|
|
|
|
const char *shortDescription,
|
|
|
|
unsigned int majorVersionIntroduced,
|
|
|
|
unsigned int minorVersionIntroduced,
|
|
|
|
unsigned int patchVersionIntroduced,
|
|
|
|
cmPolicies::PolicyStatus status)
|
|
|
|
{
|
2013-10-17 18:57:20 +00:00
|
|
|
if (!idString || !shortDescription)
|
2013-08-28 16:06:27 +00:00
|
|
|
{
|
2008-02-29 20:28:46 +00:00
|
|
|
cmSystemTools::Error("Attempt to define a policy without "
|
|
|
|
"all parameters being specified!");
|
|
|
|
return;
|
2013-08-28 16:06:27 +00:00
|
|
|
}
|
2008-02-29 20:28:46 +00:00
|
|
|
this->ID = iD;
|
|
|
|
this->IDString = idString;
|
|
|
|
this->ShortDescription = shortDescription;
|
|
|
|
this->MajorVersionIntroduced = majorVersionIntroduced;
|
|
|
|
this->MinorVersionIntroduced = minorVersionIntroduced;
|
|
|
|
this->PatchVersionIntroduced = patchVersionIntroduced;
|
|
|
|
this->Status = status;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string GetVersionString()
|
|
|
|
{
|
2010-04-23 13:50:31 +00:00
|
|
|
cmOStringStream v;
|
|
|
|
v << this->MajorVersionIntroduced << "." << this->MinorVersionIntroduced;
|
2014-02-04 21:10:15 +00:00
|
|
|
if(this->PatchVersionIntroduced > 0)
|
2010-04-23 13:50:31 +00:00
|
|
|
{
|
2014-02-04 21:10:15 +00:00
|
|
|
v << "." << this->PatchVersionIntroduced;
|
2010-04-23 13:50:31 +00:00
|
|
|
}
|
|
|
|
return v.str();
|
2008-02-29 20:28:46 +00:00
|
|
|
}
|
|
|
|
|
2010-08-28 14:01:49 +00:00
|
|
|
bool IsPolicyNewerThan(unsigned int majorV,
|
2008-02-29 20:28:46 +00:00
|
|
|
unsigned int minorV,
|
2014-02-04 21:10:15 +00:00
|
|
|
unsigned int patchV)
|
2008-02-29 20:28:46 +00:00
|
|
|
{
|
|
|
|
if (majorV < this->MajorVersionIntroduced)
|
2013-08-28 16:06:27 +00:00
|
|
|
{
|
2008-02-29 20:28:46 +00:00
|
|
|
return true;
|
2013-08-28 16:06:27 +00:00
|
|
|
}
|
2008-02-29 20:28:46 +00:00
|
|
|
if (majorV > this->MajorVersionIntroduced)
|
2013-08-28 16:06:27 +00:00
|
|
|
{
|
2008-02-29 20:28:46 +00:00
|
|
|
return false;
|
2013-08-28 16:06:27 +00:00
|
|
|
}
|
2008-02-29 20:28:46 +00:00
|
|
|
if (minorV < this->MinorVersionIntroduced)
|
2013-08-28 16:06:27 +00:00
|
|
|
{
|
2008-02-29 20:28:46 +00:00
|
|
|
return true;
|
2013-08-28 16:06:27 +00:00
|
|
|
}
|
2008-02-29 20:28:46 +00:00
|
|
|
if (minorV > this->MinorVersionIntroduced)
|
2013-08-28 16:06:27 +00:00
|
|
|
{
|
2008-02-29 20:28:46 +00:00
|
|
|
return false;
|
2013-08-28 16:06:27 +00:00
|
|
|
}
|
2014-02-04 21:10:15 +00:00
|
|
|
return (patchV < this->PatchVersionIntroduced);
|
2008-02-29 20:28:46 +00:00
|
|
|
}
|
2010-08-28 14:01:49 +00:00
|
|
|
|
2008-02-29 20:28:46 +00:00
|
|
|
cmPolicies::PolicyID ID;
|
|
|
|
std::string IDString;
|
|
|
|
std::string ShortDescription;
|
|
|
|
unsigned int MajorVersionIntroduced;
|
|
|
|
unsigned int MinorVersionIntroduced;
|
|
|
|
unsigned int PatchVersionIntroduced;
|
|
|
|
cmPolicies::PolicyStatus Status;
|
|
|
|
};
|
|
|
|
|
|
|
|
cmPolicies::cmPolicies()
|
|
|
|
{
|
|
|
|
// define all the policies
|
2008-03-07 20:30:35 +00:00
|
|
|
this->DefinePolicy(
|
2008-03-13 15:38:46 +00:00
|
|
|
CMP0000, "CMP0000",
|
2008-03-19 19:18:21 +00:00
|
|
|
"A minimum required CMake version must be specified.",
|
2014-02-04 21:10:15 +00:00
|
|
|
2,6,0, cmPolicies::WARN
|
2008-03-07 20:30:35 +00:00
|
|
|
);
|
2008-02-29 20:28:46 +00:00
|
|
|
|
2008-03-07 20:30:35 +00:00
|
|
|
this->DefinePolicy(
|
2008-03-13 15:38:46 +00:00
|
|
|
CMP0001, "CMP0001",
|
2008-03-07 20:30:35 +00:00
|
|
|
"CMAKE_BACKWARDS_COMPATIBILITY should no longer be used.",
|
2014-02-04 21:10:15 +00:00
|
|
|
2,6,0, cmPolicies::WARN
|
2008-03-07 20:30:35 +00:00
|
|
|
);
|
2008-03-05 16:41:25 +00:00
|
|
|
|
2008-03-07 20:30:35 +00:00
|
|
|
this->DefinePolicy(
|
2008-03-13 15:38:46 +00:00
|
|
|
CMP0002, "CMP0002",
|
2008-03-07 21:36:57 +00:00
|
|
|
"Logical target names must be globally unique.",
|
2014-02-04 21:10:15 +00:00
|
|
|
2,6,0, cmPolicies::WARN
|
2008-03-07 20:30:35 +00:00
|
|
|
);
|
2008-03-13 20:23:18 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0003, "CMP0003",
|
|
|
|
"Libraries linked via full path no longer produce linker search paths.",
|
2014-02-04 21:10:15 +00:00
|
|
|
2,6,0, cmPolicies::WARN);
|
2008-03-13 20:35:39 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0004, "CMP0004",
|
|
|
|
"Libraries linked may not have leading or trailing whitespace.",
|
2014-02-04 21:10:15 +00:00
|
|
|
2,6,0, cmPolicies::WARN);
|
2008-03-13 21:11:57 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0005, "CMP0005",
|
|
|
|
"Preprocessor definition values are now escaped automatically.",
|
2014-02-04 21:10:15 +00:00
|
|
|
2,6,0, cmPolicies::WARN);
|
2008-04-14 21:53:11 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0006, "CMP0006",
|
|
|
|
"Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION.",
|
2014-02-04 21:10:15 +00:00
|
|
|
2,6,0, cmPolicies::WARN);
|
2010-08-28 14:01:49 +00:00
|
|
|
|
2008-04-21 20:57:11 +00:00
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0007, "CMP0007",
|
|
|
|
"list command no longer ignores empty elements.",
|
2014-02-04 21:10:15 +00:00
|
|
|
2,6,0, cmPolicies::WARN);
|
2008-07-23 16:59:14 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0008, "CMP0008",
|
|
|
|
"Libraries linked by full-path must have a valid library file name.",
|
2014-02-04 21:10:15 +00:00
|
|
|
2,6,1, cmPolicies::WARN);
|
2008-09-11 18:34:04 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0009, "CMP0009",
|
|
|
|
"FILE GLOB_RECURSE calls should not follow symlinks by default.",
|
2014-02-04 21:10:15 +00:00
|
|
|
2,6,2, cmPolicies::WARN);
|
2008-09-24 12:51:19 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0010, "CMP0010",
|
|
|
|
"Bad variable reference syntax is an error.",
|
2014-02-04 21:10:15 +00:00
|
|
|
2,6,3, cmPolicies::WARN);
|
2009-01-22 18:18:40 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0011, "CMP0011",
|
|
|
|
"Included scripts do automatic cmake_policy PUSH and POP.",
|
2014-02-04 21:10:15 +00:00
|
|
|
2,6,3, cmPolicies::WARN);
|
2009-06-12 14:07:05 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0012, "CMP0012",
|
2009-10-27 13:07:39 +00:00
|
|
|
"if() recognizes numbers and boolean constants.",
|
2014-02-04 21:10:15 +00:00
|
|
|
2,8,0, cmPolicies::WARN);
|
2009-06-17 17:40:09 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0013, "CMP0013",
|
|
|
|
"Duplicate binary directories are not allowed.",
|
2014-02-04 21:10:15 +00:00
|
|
|
2,8,0, cmPolicies::WARN);
|
2009-09-03 12:27:12 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0014, "CMP0014",
|
|
|
|
"Input directories must have CMakeLists.txt.",
|
2014-02-04 21:10:15 +00:00
|
|
|
2,8,0, cmPolicies::WARN);
|
2009-11-24 16:16:38 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0015, "CMP0015",
|
|
|
|
"link_directories() treats paths relative to the source dir.",
|
2014-02-04 21:10:15 +00:00
|
|
|
2,8,1, cmPolicies::WARN);
|
2010-08-28 14:01:49 +00:00
|
|
|
|
2010-08-28 14:06:45 +00:00
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0016, "CMP0016",
|
2013-05-01 09:36:14 +00:00
|
|
|
"target_link_libraries() reports error if its only argument "
|
|
|
|
"is not a target.",
|
2014-02-04 21:10:15 +00:00
|
|
|
2,8,3, cmPolicies::WARN);
|
2010-11-17 21:32:53 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0017, "CMP0017",
|
2010-12-15 21:24:05 +00:00
|
|
|
"Prefer files from the CMake module directory when including from there.",
|
2014-02-04 21:10:15 +00:00
|
|
|
2,8,4, cmPolicies::WARN);
|
2012-05-30 18:13:09 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0018, "CMP0018",
|
|
|
|
"Ignore CMAKE_SHARED_LIBRARY_<Lang>_FLAGS variable.",
|
2014-02-04 21:10:15 +00:00
|
|
|
2,8,9, cmPolicies::WARN);
|
2012-12-06 14:59:18 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0019, "CMP0019",
|
|
|
|
"Do not re-expand variables in include and link information.",
|
2014-02-04 21:10:15 +00:00
|
|
|
2,8,11, cmPolicies::WARN);
|
2012-11-20 13:53:41 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0020, "CMP0020",
|
|
|
|
"Automatically link Qt executables to qtmain target on Windows.",
|
2014-02-04 21:10:15 +00:00
|
|
|
2,8,11, cmPolicies::WARN);
|
2013-03-26 17:08:29 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0021, "CMP0021",
|
|
|
|
"Fatal error on relative paths in INCLUDE_DIRECTORIES target property.",
|
2014-02-04 21:10:15 +00:00
|
|
|
2,8,12, cmPolicies::WARN);
|
2013-06-04 14:25:47 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0022, "CMP0022",
|
|
|
|
"INTERFACE_LINK_LIBRARIES defines the link interface.",
|
2014-02-04 21:10:15 +00:00
|
|
|
2,8,12, cmPolicies::WARN);
|
2013-06-04 14:21:33 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0023, "CMP0023",
|
|
|
|
"Plain and keyword target_link_libraries signatures cannot be mixed.",
|
2014-02-04 21:10:15 +00:00
|
|
|
2,8,12, cmPolicies::WARN);
|
2013-06-18 14:33:33 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0024, "CMP0024",
|
|
|
|
"Disallow include export result.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2013-10-02 18:10:38 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0025, "CMP0025",
|
|
|
|
"Compiler id for Apple Clang is now AppleClang.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2013-06-28 14:37:39 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0026, "CMP0026",
|
|
|
|
"Disallow use of the LOCATION target property.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2013-06-18 14:33:33 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0027, "CMP0027",
|
|
|
|
"Conditionally linked imported targets with missing include directories.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2013-07-30 07:51:56 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0028, "CMP0028",
|
|
|
|
"Double colon in target name means ALIAS or IMPORTED target.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2013-10-18 15:54:48 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0029, "CMP0029",
|
|
|
|
"The subdir_depends command should not be called.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2013-10-18 15:55:42 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0030, "CMP0030",
|
|
|
|
"The use_mangled_mesa command should not be called.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2013-10-18 16:41:54 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0031, "CMP0031",
|
|
|
|
"The load_command command should not be called.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2013-10-18 17:00:17 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0032, "CMP0032",
|
|
|
|
"The output_required_files command should not be called.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2013-10-18 17:09:32 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0033, "CMP0033",
|
|
|
|
"The export_library_dependencies command should not be called.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2013-10-21 15:50:47 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0034, "CMP0034",
|
|
|
|
"The utility_source command should not be called.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2013-10-21 15:58:48 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0035, "CMP0035",
|
|
|
|
"The variable_requires command should not be called.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2013-10-21 17:12:18 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0036, "CMP0036",
|
|
|
|
"The build_name command should not be called.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2013-11-05 16:32:30 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0037, "CMP0037",
|
2013-11-16 10:07:24 +00:00
|
|
|
"Target names should not be reserved and should match a validity pattern.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2013-11-05 17:01:09 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0038, "CMP0038",
|
|
|
|
"Targets may not link directly to themselves.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2013-11-05 18:15:53 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0039, "CMP0039",
|
2013-11-11 09:03:59 +00:00
|
|
|
"Utility targets may not have link dependencies.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2013-11-20 08:53:06 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0040, "CMP0040",
|
|
|
|
"The target in the TARGET signature of add_custom_command() must exist.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2013-11-26 10:24:47 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0041, "CMP0041",
|
|
|
|
"Error on relative include with generator expression.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2013-12-19 04:25:29 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0042, "CMP0042",
|
|
|
|
"MACOSX_RPATH is enabled by default.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2013-12-30 12:33:02 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0043, "CMP0043",
|
|
|
|
"Ignore COMPILE_DEFINITIONS_<Config> properties.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2013-12-26 14:59:55 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0044, "CMP0044",
|
|
|
|
"Case sensitive <LANG>_COMPILER_ID generator expressions.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2014-01-08 12:16:33 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0045, "CMP0045",
|
|
|
|
"Error on non-existent target in get_target_property.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2014-01-12 11:58:04 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0046, "CMP0046",
|
|
|
|
"Error on non-existent dependency in add_dependencies.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2014-01-20 16:57:40 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0047, "CMP0047",
|
|
|
|
"Use QCC compiler id for the qcc drivers on QNX.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2014-01-29 14:28:01 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0048, "CMP0048",
|
|
|
|
"project() command manages VERSION variables.",
|
2014-02-04 21:10:15 +00:00
|
|
|
3,0,0, cmPolicies::WARN);
|
2014-02-11 16:41:24 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0049, "CMP0049",
|
|
|
|
"Do not expand variables in target source entries.",
|
|
|
|
3,0,0, cmPolicies::WARN);
|
2014-02-11 17:39:55 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0050, "CMP0050",
|
|
|
|
"Disallow add_custom_command SOURCE signatures.",
|
|
|
|
3,0,0, cmPolicies::WARN);
|
2014-03-18 15:15:15 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0051, "CMP0051",
|
|
|
|
"List TARGET_OBJECTS in SOURCES target property.",
|
|
|
|
3,1,0, cmPolicies::WARN);
|
2014-03-31 15:37:02 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0052, "CMP0052",
|
|
|
|
"Reject source and build dirs in installed "
|
|
|
|
"INTERFACE_INCLUDE_DIRECTORIES.",
|
|
|
|
3,1,0, cmPolicies::WARN);
|
2014-04-28 18:59:11 +00:00
|
|
|
|
|
|
|
this->DefinePolicy(
|
|
|
|
CMP0053, "CMP0053",
|
|
|
|
"Simplify variable reference and escape sequence evaluation.",
|
|
|
|
3,1,0, cmPolicies::WARN);
|
2008-03-07 20:30:35 +00:00
|
|
|
}
|
2008-02-29 20:28:46 +00:00
|
|
|
|
|
|
|
cmPolicies::~cmPolicies()
|
|
|
|
{
|
|
|
|
// free the policies
|
2010-08-28 14:01:49 +00:00
|
|
|
std::map<cmPolicies::PolicyID,cmPolicy *>::iterator i
|
2008-03-02 14:03:33 +00:00
|
|
|
= this->Policies.begin();
|
|
|
|
for (;i != this->Policies.end(); ++i)
|
2013-08-28 16:06:27 +00:00
|
|
|
{
|
2008-02-29 20:28:46 +00:00
|
|
|
delete i->second;
|
2013-08-28 16:06:27 +00:00
|
|
|
}
|
2008-02-29 20:28:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmPolicies::DefinePolicy(cmPolicies::PolicyID iD,
|
2010-08-28 14:01:49 +00:00
|
|
|
const char *idString,
|
2008-02-29 20:28:46 +00:00
|
|
|
const char *shortDescription,
|
|
|
|
unsigned int majorVersionIntroduced,
|
|
|
|
unsigned int minorVersionIntroduced,
|
|
|
|
unsigned int patchVersionIntroduced,
|
|
|
|
cmPolicies::PolicyStatus status)
|
|
|
|
{
|
|
|
|
// a policy must be unique and can only be defined once
|
2008-03-02 14:03:33 +00:00
|
|
|
if (this->Policies.find(iD) != this->Policies.end())
|
2013-08-28 16:06:27 +00:00
|
|
|
{
|
2008-02-29 20:28:46 +00:00
|
|
|
cmSystemTools::Error("Attempt to redefine a CMake policy for policy "
|
|
|
|
"ID ", this->GetPolicyIDString(iD).c_str());
|
|
|
|
return;
|
2013-08-28 16:06:27 +00:00
|
|
|
}
|
2010-08-28 14:01:49 +00:00
|
|
|
|
2008-03-02 14:03:33 +00:00
|
|
|
this->Policies[iD] = new cmPolicy(iD, idString,
|
2008-02-29 20:28:46 +00:00
|
|
|
shortDescription,
|
|
|
|
majorVersionIntroduced,
|
|
|
|
minorVersionIntroduced,
|
|
|
|
patchVersionIntroduced,
|
|
|
|
status);
|
|
|
|
this->PolicyStringMap[idString] = iD;
|
|
|
|
}
|
|
|
|
|
2008-08-18 20:29:00 +00:00
|
|
|
//----------------------------------------------------------------------------
|
2010-08-28 14:01:49 +00:00
|
|
|
bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
|
2008-02-29 20:28:46 +00:00
|
|
|
const char *version)
|
|
|
|
{
|
|
|
|
std::string ver = "2.4.0";
|
|
|
|
|
|
|
|
if (version && strlen(version) > 0)
|
2010-11-23 20:53:35 +00:00
|
|
|
{
|
2008-02-29 20:28:46 +00:00
|
|
|
ver = version;
|
2010-11-23 20:53:35 +00:00
|
|
|
}
|
2008-02-29 20:28:46 +00:00
|
|
|
|
|
|
|
unsigned int majorVer = 2;
|
|
|
|
unsigned int minorVer = 0;
|
|
|
|
unsigned int patchVer = 0;
|
2010-04-23 13:50:31 +00:00
|
|
|
unsigned int tweakVer = 0;
|
2008-03-05 22:26:32 +00:00
|
|
|
|
2008-02-29 20:28:46 +00:00
|
|
|
// parse the string
|
2010-04-23 13:50:31 +00:00
|
|
|
if(sscanf(ver.c_str(), "%u.%u.%u.%u",
|
|
|
|
&majorVer, &minorVer, &patchVer, &tweakVer) < 2)
|
2008-03-05 23:20:20 +00:00
|
|
|
{
|
2008-03-24 14:56:26 +00:00
|
|
|
cmOStringStream e;
|
|
|
|
e << "Invalid policy version value \"" << ver << "\". "
|
2010-04-23 13:50:31 +00:00
|
|
|
<< "A numeric major.minor[.patch[.tweak]] must be given.";
|
2008-03-24 14:56:26 +00:00
|
|
|
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
|
2008-03-05 23:20:20 +00:00
|
|
|
return false;
|
|
|
|
}
|
2010-08-28 14:01:49 +00:00
|
|
|
|
2008-03-07 16:43:47 +00:00
|
|
|
// it is an error if the policy version is less than 2.4
|
2009-09-11 12:18:15 +00:00
|
|
|
if (majorVer < 2 || (majorVer == 2 && minorVer < 4))
|
2008-03-11 14:29:56 +00:00
|
|
|
{
|
|
|
|
mf->IssueMessage(cmake::FATAL_ERROR,
|
2013-10-18 15:25:49 +00:00
|
|
|
"Compatibility with CMake < 2.4 is not supported by CMake >= 3.0. "
|
|
|
|
"For compatibility with older versions please use any CMake 2.8.x "
|
|
|
|
"release or lower.");
|
2008-03-24 14:56:26 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// It is an error if the policy version is greater than the running
|
|
|
|
// CMake.
|
|
|
|
if (majorVer > cmVersion::GetMajorVersion() ||
|
|
|
|
(majorVer == cmVersion::GetMajorVersion() &&
|
|
|
|
minorVer > cmVersion::GetMinorVersion()) ||
|
|
|
|
(majorVer == cmVersion::GetMajorVersion() &&
|
|
|
|
minorVer == cmVersion::GetMinorVersion() &&
|
2010-04-23 13:50:31 +00:00
|
|
|
patchVer > cmVersion::GetPatchVersion()) ||
|
|
|
|
(majorVer == cmVersion::GetMajorVersion() &&
|
|
|
|
minorVer == cmVersion::GetMinorVersion() &&
|
|
|
|
patchVer == cmVersion::GetPatchVersion() &&
|
|
|
|
tweakVer > cmVersion::GetTweakVersion()))
|
2008-03-24 14:56:26 +00:00
|
|
|
{
|
|
|
|
cmOStringStream e;
|
|
|
|
e << "An attempt was made to set the policy version of CMake to \""
|
|
|
|
<< version << "\" which is greater than this version of CMake. "
|
|
|
|
<< "This is not allowed because the greater version may have new "
|
|
|
|
<< "policies not known to this CMake. "
|
|
|
|
<< "You may need a newer CMake version to build this project.";
|
|
|
|
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
|
|
|
|
return false;
|
2008-03-11 14:29:56 +00:00
|
|
|
}
|
2008-03-07 20:30:35 +00:00
|
|
|
|
2008-02-29 20:28:46 +00:00
|
|
|
// now loop over all the policies and set them as appropriate
|
2008-08-18 20:29:00 +00:00
|
|
|
std::vector<cmPolicies::PolicyID> ancientPolicies;
|
2010-11-23 20:53:35 +00:00
|
|
|
for(std::map<cmPolicies::PolicyID,cmPolicy *>::iterator i
|
|
|
|
= this->Policies.begin(); i != this->Policies.end(); ++i)
|
2008-02-29 20:28:46 +00:00
|
|
|
{
|
2014-02-04 21:10:15 +00:00
|
|
|
if (i->second->IsPolicyNewerThan(majorVer,minorVer,patchVer))
|
2008-08-18 20:29:00 +00:00
|
|
|
{
|
2010-11-23 20:53:35 +00:00
|
|
|
if(i->second->Status == cmPolicies::REQUIRED_ALWAYS)
|
|
|
|
{
|
2008-08-18 20:29:00 +00:00
|
|
|
ancientPolicies.push_back(i->first);
|
2010-11-23 20:53:35 +00:00
|
|
|
}
|
2011-01-03 23:04:58 +00:00
|
|
|
else
|
2010-11-23 20:53:35 +00:00
|
|
|
{
|
2011-01-03 23:04:58 +00:00
|
|
|
cmPolicies::PolicyStatus status = cmPolicies::WARN;
|
|
|
|
if(!this->GetPolicyDefault(mf, i->second->IDString, &status) ||
|
|
|
|
!mf->SetPolicy(i->second->ID, status))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2010-11-23 20:53:35 +00:00
|
|
|
}
|
2008-02-29 20:28:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-11-23 20:53:35 +00:00
|
|
|
if (!mf->SetPolicy(i->second->ID, cmPolicies::NEW))
|
|
|
|
{
|
2008-02-29 20:28:46 +00:00
|
|
|
return false;
|
2010-11-23 20:53:35 +00:00
|
|
|
}
|
2008-02-29 20:28:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-18 20:29:00 +00:00
|
|
|
// Make sure the project does not use any ancient policies.
|
|
|
|
if(!ancientPolicies.empty())
|
2008-02-29 20:28:46 +00:00
|
|
|
{
|
2008-08-18 20:29:00 +00:00
|
|
|
this->DiagnoseAncientPolicies(ancientPolicies,
|
|
|
|
majorVer, minorVer, patchVer, mf);
|
|
|
|
cmSystemTools::SetFatalErrorOccured();
|
2008-02-29 20:28:46 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-01-03 23:04:58 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmPolicies::GetPolicyDefault(cmMakefile* mf, std::string const& policy,
|
|
|
|
cmPolicies::PolicyStatus* defaultSetting)
|
|
|
|
{
|
|
|
|
std::string defaultVar = "CMAKE_POLICY_DEFAULT_" + policy;
|
2014-03-10 23:04:11 +00:00
|
|
|
std::string defaultValue = mf->GetSafeDefinition(defaultVar);
|
2011-01-03 23:04:58 +00:00
|
|
|
if(defaultValue == "NEW")
|
|
|
|
{
|
|
|
|
*defaultSetting = cmPolicies::NEW;
|
|
|
|
}
|
|
|
|
else if(defaultValue == "OLD")
|
|
|
|
{
|
|
|
|
*defaultSetting = cmPolicies::OLD;
|
|
|
|
}
|
|
|
|
else if(defaultValue == "")
|
|
|
|
{
|
|
|
|
*defaultSetting = cmPolicies::WARN;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cmOStringStream e;
|
|
|
|
e << defaultVar << " has value \"" << defaultValue
|
|
|
|
<< "\" but must be \"OLD\", \"NEW\", or \"\" (empty).";
|
2014-03-10 23:04:11 +00:00
|
|
|
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
|
2011-01-03 23:04:58 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-02-29 20:28:46 +00:00
|
|
|
bool cmPolicies::GetPolicyID(const char *id, cmPolicies::PolicyID &pid)
|
|
|
|
{
|
|
|
|
if (!id || strlen(id) < 1)
|
2013-08-28 16:06:27 +00:00
|
|
|
{
|
2008-02-29 20:28:46 +00:00
|
|
|
return false;
|
2013-08-28 16:06:27 +00:00
|
|
|
}
|
2010-08-28 14:01:49 +00:00
|
|
|
std::map<std::string,cmPolicies::PolicyID>::iterator pos =
|
2008-02-29 20:28:46 +00:00
|
|
|
this->PolicyStringMap.find(id);
|
|
|
|
if (pos == this->PolicyStringMap.end())
|
2013-08-28 16:06:27 +00:00
|
|
|
{
|
2008-02-29 20:28:46 +00:00
|
|
|
return false;
|
2013-08-28 16:06:27 +00:00
|
|
|
}
|
2008-02-29 20:28:46 +00:00
|
|
|
pid = pos->second;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string cmPolicies::GetPolicyIDString(cmPolicies::PolicyID pid)
|
|
|
|
{
|
2010-08-28 14:01:49 +00:00
|
|
|
std::map<cmPolicies::PolicyID,cmPolicy *>::iterator pos =
|
2008-03-02 14:03:33 +00:00
|
|
|
this->Policies.find(pid);
|
|
|
|
if (pos == this->Policies.end())
|
2013-08-28 16:06:27 +00:00
|
|
|
{
|
2008-02-29 20:28:46 +00:00
|
|
|
return "";
|
2013-08-28 16:06:27 +00:00
|
|
|
}
|
2008-02-29 20:28:46 +00:00
|
|
|
return pos->second->IDString;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///! return a warning string for a given policy
|
|
|
|
std::string cmPolicies::GetPolicyWarning(cmPolicies::PolicyID id)
|
|
|
|
{
|
2010-08-28 14:01:49 +00:00
|
|
|
std::map<cmPolicies::PolicyID,cmPolicy *>::iterator pos =
|
2008-03-02 14:03:33 +00:00
|
|
|
this->Policies.find(id);
|
|
|
|
if (pos == this->Policies.end())
|
2013-08-28 16:06:27 +00:00
|
|
|
{
|
2008-02-29 20:28:46 +00:00
|
|
|
cmSystemTools::Error(
|
|
|
|
"Request for warning text for undefined policy!");
|
|
|
|
return "Request for warning text for undefined policy!";
|
2013-08-28 16:06:27 +00:00
|
|
|
}
|
2008-02-29 20:28:46 +00:00
|
|
|
|
2008-03-05 23:42:46 +00:00
|
|
|
cmOStringStream msg;
|
|
|
|
msg <<
|
2008-03-07 13:40:36 +00:00
|
|
|
"Policy " << pos->second->IDString << " is not set: "
|
2008-03-13 19:01:58 +00:00
|
|
|
"" << pos->second->ShortDescription << " "
|
2008-03-05 23:42:46 +00:00
|
|
|
"Run \"cmake --help-policy " << pos->second->IDString << "\" for "
|
2008-03-08 14:13:13 +00:00
|
|
|
"policy details. "
|
2008-03-07 13:40:36 +00:00
|
|
|
"Use the cmake_policy command to set the policy "
|
2008-03-05 23:42:46 +00:00
|
|
|
"and suppress this warning.";
|
|
|
|
return msg.str();
|
2008-02-29 20:28:46 +00:00
|
|
|
}
|
2010-08-28 14:01:49 +00:00
|
|
|
|
|
|
|
|
2008-02-29 20:28:46 +00:00
|
|
|
///! return an error string for when a required policy is unspecified
|
|
|
|
std::string cmPolicies::GetRequiredPolicyError(cmPolicies::PolicyID id)
|
|
|
|
{
|
2010-08-28 14:01:49 +00:00
|
|
|
std::map<cmPolicies::PolicyID,cmPolicy *>::iterator pos =
|
2008-03-02 14:03:33 +00:00
|
|
|
this->Policies.find(id);
|
|
|
|
if (pos == this->Policies.end())
|
2013-08-28 16:06:27 +00:00
|
|
|
{
|
2008-02-29 20:28:46 +00:00
|
|
|
cmSystemTools::Error(
|
|
|
|
"Request for error text for undefined policy!");
|
2013-05-01 09:36:14 +00:00
|
|
|
return "Request for error text for undefined policy!";
|
2013-08-28 16:06:27 +00:00
|
|
|
}
|
2008-02-29 20:28:46 +00:00
|
|
|
|
|
|
|
cmOStringStream error;
|
2008-03-07 13:40:36 +00:00
|
|
|
error <<
|
|
|
|
"Policy " << pos->second->IDString << " is not set to NEW: "
|
2008-03-13 19:01:58 +00:00
|
|
|
"" << pos->second->ShortDescription << " "
|
2008-03-07 13:40:36 +00:00
|
|
|
"Run \"cmake --help-policy " << pos->second->IDString << "\" for "
|
2008-03-08 14:13:13 +00:00
|
|
|
"policy details. "
|
2008-03-07 13:40:36 +00:00
|
|
|
"CMake now requires this policy to be set to NEW by the project. "
|
|
|
|
"The policy may be set explicitly using the code\n"
|
|
|
|
" cmake_policy(SET " << pos->second->IDString << " NEW)\n"
|
|
|
|
"or by upgrading all policies with the code\n"
|
|
|
|
" cmake_policy(VERSION " << pos->second->GetVersionString() <<
|
|
|
|
") # or later\n"
|
|
|
|
"Run \"cmake --help-command cmake_policy\" for more information.";
|
2008-02-29 20:28:46 +00:00
|
|
|
return error.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
///! Get the default status for a policy
|
2010-08-28 14:01:49 +00:00
|
|
|
cmPolicies::PolicyStatus
|
2008-02-29 20:28:46 +00:00
|
|
|
cmPolicies::GetPolicyStatus(cmPolicies::PolicyID id)
|
|
|
|
{
|
|
|
|
// if the policy is not know then what?
|
2010-08-28 14:01:49 +00:00
|
|
|
std::map<cmPolicies::PolicyID,cmPolicy *>::iterator pos =
|
2008-03-02 14:03:33 +00:00
|
|
|
this->Policies.find(id);
|
|
|
|
if (pos == this->Policies.end())
|
2013-08-28 16:06:27 +00:00
|
|
|
{
|
2008-02-29 20:28:46 +00:00
|
|
|
// TODO is this right?
|
|
|
|
return cmPolicies::WARN;
|
2013-08-28 16:06:27 +00:00
|
|
|
}
|
2010-08-28 14:01:49 +00:00
|
|
|
|
2008-02-29 20:28:46 +00:00
|
|
|
return pos->second->Status;
|
|
|
|
}
|
|
|
|
|
2008-08-18 20:29:00 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string
|
|
|
|
cmPolicies::GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id)
|
|
|
|
{
|
|
|
|
std::string pid = this->GetPolicyIDString(id);
|
|
|
|
cmOStringStream e;
|
|
|
|
e << "Policy " << pid << " may not be set to OLD behavior because this "
|
|
|
|
<< "version of CMake no longer supports it. "
|
|
|
|
<< "The policy was introduced in "
|
|
|
|
<< "CMake version " << this->Policies[id]->GetVersionString()
|
|
|
|
<< ", and use of NEW behavior is now required."
|
|
|
|
<< "\n"
|
|
|
|
<< "Please either update your CMakeLists.txt files to conform to "
|
|
|
|
<< "the new behavior or use an older version of CMake that still "
|
|
|
|
<< "supports the old behavior. "
|
|
|
|
<< "Run cmake --help-policy " << pid << " for more information.";
|
|
|
|
return e.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmPolicies::DiagnoseAncientPolicies(std::vector<PolicyID> const& ancient,
|
|
|
|
unsigned int majorVer,
|
|
|
|
unsigned int minorVer,
|
|
|
|
unsigned int patchVer,
|
|
|
|
cmMakefile* mf)
|
|
|
|
{
|
|
|
|
cmOStringStream e;
|
|
|
|
e << "The project requests behavior compatible with CMake version \""
|
|
|
|
<< majorVer << "." << minorVer << "." << patchVer
|
2009-09-03 12:26:18 +00:00
|
|
|
<< "\", which requires the OLD behavior for some policies:\n";
|
2008-08-18 20:29:00 +00:00
|
|
|
for(std::vector<PolicyID>::const_iterator
|
|
|
|
i = ancient.begin(); i != ancient.end(); ++i)
|
|
|
|
{
|
|
|
|
cmPolicy const* policy = this->Policies[*i];
|
|
|
|
e << " " << policy->IDString << ": " << policy->ShortDescription << "\n";
|
|
|
|
}
|
|
|
|
e << "However, this version of CMake no longer supports the OLD "
|
|
|
|
<< "behavior for these policies. "
|
|
|
|
<< "Please either update your CMakeLists.txt files to conform to "
|
|
|
|
<< "the new behavior or use an older version of CMake that still "
|
|
|
|
<< "supports the old behavior.";
|
2014-03-10 23:04:11 +00:00
|
|
|
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
|
2008-08-18 20:29:00 +00:00
|
|
|
}
|