Drop compatibility with CMake < 2.4

Drop all behavior activated by setting CMAKE_BACKWARDS_COMPATIBILITY to
a value lower than 2.4, and generate an error when projects or the user
attempt to do so.  In the error suggest using a CMake 2.8.x release.

Teach cmake_minimum_required to warn about projects that do not require
at least CMake 2.4.  They are not supported by CMake >= 3.0.

Replace the documentation of CMAKE_BACKWARDS_COMPATIBILITY with a
reference to policy CMP0001.
This commit is contained in:
Brad King 2013-10-18 11:25:49 -04:00
parent c7c44fc7f4
commit 7d47c69365
35 changed files with 71 additions and 309 deletions

View File

@ -1,11 +1,4 @@
CMAKE_BACKWARDS_COMPATIBILITY CMAKE_BACKWARDS_COMPATIBILITY
----------------------------- -----------------------------
Version of cmake required to build project Deprecated. See CMake Policy :policy:`CMP0001` documentation.
From the point of view of backwards compatibility, this specifies what
version of CMake should be supported. By default this value is the
version number of CMake that you are running. You can set this to an
older version of CMake to support deprecated commands of CMake in
projects that were written to use older versions of CMake. This can
be set by the user or set at the beginning of a CMakeLists file.

View File

@ -60,12 +60,6 @@ if(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
CACHE STRING "Build architectures for OSX") CACHE STRING "Build architectures for OSX")
endif() endif()
if("${CMAKE_BACKWARDS_COMPATIBILITY}" MATCHES "^1\\.[0-6]$")
set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS
"${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -flat_namespace -undefined suppress")
endif()
if(NOT XCODE) if(NOT XCODE)
# Enable shared library versioning. This flag is not actually referenced # Enable shared library versioning. This flag is not actually referenced
# but the fact that the setting exists will cause the generators to support # but the fact that the setting exists will cause the generators to support

View File

@ -223,11 +223,6 @@ if(CMAKE_OSX_DEPLOYMENT_TARGET)
endif() endif()
endif() endif()
if("${CMAKE_BACKWARDS_COMPATIBILITY}" MATCHES "^1\\.[0-6]$")
set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS
"${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -flat_namespace -undefined suppress")
endif()
# Enable shared library versioning. # Enable shared library versioning.
set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name") set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name")

View File

@ -25,17 +25,12 @@ bool cmAddCustomTargetCommand
// Check the target name. // Check the target name.
if(args[0].find_first_of("/\\") != args[0].npos) if(args[0].find_first_of("/\\") != args[0].npos)
{ {
if(!this->Makefile->NeedBackwardsCompatibility(2,2)) cmOStringStream e;
{ e << "called with invalid target name \"" << args[0]
cmOStringStream e; << "\". Target names may not contain a slash. "
e << "called with invalid target name \"" << args[0] << "Use ADD_CUSTOM_COMMAND to generate files.";
<< "\". Target names may not contain a slash. " this->SetError(e.str().c_str());
<< "Use ADD_CUSTOM_COMMAND to generate files. " return false;
<< "Set CMAKE_BACKWARDS_COMPATIBILITY to 2.2 "
<< "or lower to skip this check.";
this->SetError(e.str().c_str());
return false;
}
} }
// Accumulate one command line at a time. // Accumulate one command line at a time.

View File

@ -114,6 +114,9 @@ bool cmCMakeMinimumRequired
if (required_major < 2 || (required_major == 2 && required_minor < 4)) if (required_major < 2 || (required_major == 2 && required_minor < 4))
{ {
this->Makefile->IssueMessage(
cmake::AUTHOR_WARNING,
"Compatibility with CMake < 2.4 is not supported by CMake >= 3.0.");
this->Makefile->SetPolicyVersion("2.4"); this->Makefile->SetPolicyVersion("2.4");
} }
else else

View File

@ -74,10 +74,6 @@ bool cmConfigureFileCommand
this->CopyOnly = false; this->CopyOnly = false;
this->EscapeQuotes = false; this->EscapeQuotes = false;
// for CMake 2.0 and earlier CONFIGURE_FILE defaults to the FinalPass,
// after 2.0 it only does InitialPass
this->Immediate = !this->Makefile->NeedBackwardsCompatibility(2,0);
this->AtOnly = false; this->AtOnly = false;
for(unsigned int i=2;i < args.size();++i) for(unsigned int i=2;i < args.size();++i)
{ {
@ -101,32 +97,19 @@ bool cmConfigureFileCommand
} }
else if(args[i] == "IMMEDIATE") else if(args[i] == "IMMEDIATE")
{ {
this->Immediate = true; /* Ignore legacy option. */
} }
} }
// If we were told to copy the file immediately, then do it on the if ( !this->ConfigureFile() )
// first pass (now).
if(this->Immediate)
{ {
if ( !this->ConfigureFile() ) this->SetError("Problem configuring file");
{ return false;
this->SetError("Problem configuring file");
return false;
}
} }
return true; return true;
} }
void cmConfigureFileCommand::FinalPass()
{
if(!this->Immediate)
{
this->ConfigureFile();
}
}
int cmConfigureFileCommand::ConfigureFile() int cmConfigureFileCommand::ConfigureFile()
{ {
return this->Makefile->ConfigureFile( return this->Makefile->ConfigureFile(

View File

@ -41,9 +41,6 @@ public:
*/ */
virtual bool IsScriptable() const { return true; } virtual bool IsScriptable() const { return true; }
virtual void FinalPass();
virtual bool HasFinalPass() const { return !this->Immediate; }
private: private:
int ConfigureFile(); int ConfigureFile();
@ -53,7 +50,6 @@ private:
std::string OutputFile; std::string OutputFile;
bool CopyOnly; bool CopyOnly;
bool EscapeQuotes; bool EscapeQuotes;
bool Immediate;
bool AtOnly; bool AtOnly;
}; };

View File

@ -28,11 +28,6 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
return false; return false;
} }
// CMake versions below 2.3 did not search all these extra
// locations. Preserve compatibility unless a modern argument is
// passed.
bool compatibility = this->Makefile->NeedBackwardsCompatibility(2,3);
// copy argsIn into args so it can be modified, // copy argsIn into args so it can be modified,
// in the process extract the DOC "documentation" // in the process extract the DOC "documentation"
size_t size = argsIn.size(); size_t size = argsIn.size();
@ -112,7 +107,6 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
else if (args[j] == "PATH_SUFFIXES") else if (args[j] == "PATH_SUFFIXES")
{ {
doing = DoingPathSuffixes; doing = DoingPathSuffixes;
compatibility = false;
newStyle = true; newStyle = true;
} }
else if (args[j] == "NAMES_PER_DIR") else if (args[j] == "NAMES_PER_DIR")
@ -136,7 +130,6 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
else if (this->CheckCommonArgument(args[j])) else if (this->CheckCommonArgument(args[j]))
{ {
doing = DoingNone; doing = DoingNone;
compatibility = false;
// Some common arguments were accidentally supported by CMake // Some common arguments were accidentally supported by CMake
// 2.4 and 2.6.0 in the short-hand form of the command, so we // 2.4 and 2.6.0 in the short-hand form of the command, so we
// must support it even though it is not documented. // must support it even though it is not documented.
@ -159,17 +152,6 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
} }
} }
// Now that arguments have been parsed check the compatibility
// setting. If we need to be compatible with CMake 2.2 and earlier
// do not add the CMake system paths. It is safe to add the CMake
// environment paths and system environment paths because that
// existed in 2.2. It is safe to add the CMake user variable paths
// because the user or project has explicitly set them.
if(compatibility)
{
this->NoCMakeSystemPath = true;
}
if(this->VariableDocumentation.size() == 0) if(this->VariableDocumentation.size() == 0)
{ {
this->VariableDocumentation = "Where can "; this->VariableDocumentation = "Where can ";

View File

@ -24,32 +24,6 @@
#include <StorageDefs.h> #include <StorageDefs.h>
#endif #endif
void cmFindPackageNeedBackwardsCompatibility(const std::string& variable,
int access_type, void*, const char* newValue,
const cmMakefile*)
{
(void)newValue;
#ifdef CMAKE_BUILD_WITH_CMAKE
if(access_type == cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS)
{
std::string message = "An attempt was made to access a variable: ";
message += variable;
message +=
" that has not been defined. This variable is created by the "
"FIND_PACKAGE command. CMake version 1.6 always converted the "
"variable name to upper-case, but this behavior is no longer the "
"case. To fix this you might need to set the cache value of "
"CMAKE_BACKWARDS_COMPATIBILITY to 1.6 or less. If you are writing a "
"CMake listfile, you should change the variable reference to use "
"the case of the argument to FIND_PACKAGE.";
cmSystemTools::Error(message.c_str());
}
#else
(void)variable;
(void)access_type;
#endif
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmFindPackageCommand::cmFindPackageCommand() cmFindPackageCommand::cmFindPackageCommand()
{ {
@ -128,11 +102,6 @@ bool cmFindPackageCommand
std::set<std::string> requiredComponents; std::set<std::string> requiredComponents;
std::set<std::string> optionalComponents; std::set<std::string> optionalComponents;
// Check ancient compatibility.
this->Compatibility_1_6 =
this->Makefile->GetLocalGenerator()
->NeedBackwardsCompatibility(1, 6);
// Always search directly in a generated path. // Always search directly in a generated path.
this->SearchPathSuffixes.push_back(""); this->SearchPathSuffixes.push_back("");
@ -154,7 +123,6 @@ bool cmFindPackageCommand
else if(args[i] == "EXACT") else if(args[i] == "EXACT")
{ {
this->VersionExact = true; this->VersionExact = true;
this->Compatibility_1_6 = false;
doing = DoingNone; doing = DoingNone;
} }
else if(args[i] == "MODULE") else if(args[i] == "MODULE")
@ -179,75 +147,63 @@ bool cmFindPackageCommand
} }
else if(args[i] == "COMPONENTS") else if(args[i] == "COMPONENTS")
{ {
this->Compatibility_1_6 = false;
doing = DoingComponents; doing = DoingComponents;
} }
else if(args[i] == "OPTIONAL_COMPONENTS") else if(args[i] == "OPTIONAL_COMPONENTS")
{ {
this->Compatibility_1_6 = false;
doing = DoingOptionalComponents; doing = DoingOptionalComponents;
} }
else if(args[i] == "NAMES") else if(args[i] == "NAMES")
{ {
configArgs.insert(i); configArgs.insert(i);
this->Compatibility_1_6 = false;
doing = DoingNames; doing = DoingNames;
} }
else if(args[i] == "PATHS") else if(args[i] == "PATHS")
{ {
configArgs.insert(i); configArgs.insert(i);
this->Compatibility_1_6 = false;
doing = DoingPaths; doing = DoingPaths;
} }
else if(args[i] == "HINTS") else if(args[i] == "HINTS")
{ {
configArgs.insert(i); configArgs.insert(i);
this->Compatibility_1_6 = false;
doing = DoingHints; doing = DoingHints;
} }
else if(args[i] == "PATH_SUFFIXES") else if(args[i] == "PATH_SUFFIXES")
{ {
configArgs.insert(i); configArgs.insert(i);
this->Compatibility_1_6 = false;
doing = DoingPathSuffixes; doing = DoingPathSuffixes;
} }
else if(args[i] == "CONFIGS") else if(args[i] == "CONFIGS")
{ {
configArgs.insert(i); configArgs.insert(i);
this->Compatibility_1_6 = false;
doing = DoingConfigs; doing = DoingConfigs;
} }
else if(args[i] == "NO_POLICY_SCOPE") else if(args[i] == "NO_POLICY_SCOPE")
{ {
this->PolicyScope = false; this->PolicyScope = false;
this->Compatibility_1_6 = false;
doing = DoingNone; doing = DoingNone;
} }
else if(args[i] == "NO_CMAKE_PACKAGE_REGISTRY") else if(args[i] == "NO_CMAKE_PACKAGE_REGISTRY")
{ {
this->NoUserRegistry = true; this->NoUserRegistry = true;
configArgs.insert(i); configArgs.insert(i);
this->Compatibility_1_6 = false;
doing = DoingNone; doing = DoingNone;
} }
else if(args[i] == "NO_CMAKE_SYSTEM_PACKAGE_REGISTRY") else if(args[i] == "NO_CMAKE_SYSTEM_PACKAGE_REGISTRY")
{ {
this->NoSystemRegistry = true; this->NoSystemRegistry = true;
configArgs.insert(i); configArgs.insert(i);
this->Compatibility_1_6 = false;
doing = DoingNone; doing = DoingNone;
} }
else if(args[i] == "NO_CMAKE_BUILDS_PATH") else if(args[i] == "NO_CMAKE_BUILDS_PATH")
{ {
this->NoBuilds = true; this->NoBuilds = true;
configArgs.insert(i); configArgs.insert(i);
this->Compatibility_1_6 = false;
doing = DoingNone; doing = DoingNone;
} }
else if(this->CheckCommonArgument(args[i])) else if(this->CheckCommonArgument(args[i]))
{ {
configArgs.insert(i); configArgs.insert(i);
this->Compatibility_1_6 = false;
doing = DoingNone; doing = DoingNone;
} }
else if((doing == DoingComponents) || (doing == DoingOptionalComponents)) else if((doing == DoingComponents) || (doing == DoingOptionalComponents))
@ -642,24 +598,9 @@ bool cmFindPackageCommand::HandlePackageMode()
std::string upperFound = cmSystemTools::UpperCase(this->Name); std::string upperFound = cmSystemTools::UpperCase(this->Name);
upperDir += "_DIR"; upperDir += "_DIR";
upperFound += "_FOUND"; upperFound += "_FOUND";
if(upperDir == this->Variable)
{
this->Compatibility_1_6 = false;
}
// Try to find the config file. // Try to find the config file.
const char* def = this->Makefile->GetDefinition(this->Variable.c_str()); const char* def = this->Makefile->GetDefinition(this->Variable.c_str());
if(this->Compatibility_1_6 && cmSystemTools::IsOff(def))
{
// Use the setting of the old name of the variable to provide the
// value of the new.
const char* oldDef = this->Makefile->GetDefinition(upperDir.c_str());
if(!cmSystemTools::IsOff(oldDef))
{
this->Makefile->AddDefinition(this->Variable.c_str(), oldDef);
def = this->Makefile->GetDefinition(this->Variable.c_str());
}
}
// Try to load the config file if the directory is known // Try to load the config file if the directory is known
bool fileFound = false; bool fileFound = false;
@ -881,43 +822,6 @@ bool cmFindPackageCommand::HandlePackageMode()
this->Makefile->RemoveDefinition(fileVar.c_str()); this->Makefile->RemoveDefinition(fileVar.c_str());
} }
// Handle some ancient compatibility stuff.
if(this->Compatibility_1_6)
{
// Listfiles will be looking for the capitalized version of the
// name. Provide it.
this->Makefile->AddDefinition
(upperDir.c_str(),
this->Makefile->GetDefinition(this->Variable.c_str()));
this->Makefile->AddDefinition
(upperFound.c_str(),
this->Makefile->GetDefinition(foundVar.c_str()));
}
#ifdef CMAKE_BUILD_WITH_CMAKE
if(!(upperDir == this->Variable))
{
if(this->Compatibility_1_6)
{
// Listfiles may use the capitalized version of the name.
// Remove any previously added watch.
this->Makefile->GetVariableWatch()->RemoveWatch(
upperDir.c_str(),
cmFindPackageNeedBackwardsCompatibility
);
}
else
{
// Listfiles should not be using the capitalized version of the
// name. Add a watch to warn the user.
this->Makefile->GetVariableWatch()->AddWatch(
upperDir.c_str(),
cmFindPackageNeedBackwardsCompatibility
);
}
}
#endif
std::string consideredConfigsVar = this->Name; std::string consideredConfigsVar = this->Name;
consideredConfigsVar += "_CONSIDERED_CONFIGS"; consideredConfigsVar += "_CONSIDERED_CONFIGS";
std::string consideredVersionsVar = this->Name; std::string consideredVersionsVar = this->Name;

View File

@ -117,7 +117,6 @@ private:
unsigned int RequiredCMakeVersion; unsigned int RequiredCMakeVersion;
bool Quiet; bool Quiet;
bool Required; bool Required;
bool Compatibility_1_6;
bool UseConfigFiles; bool UseConfigFiles;
bool UseFindModules; bool UseFindModules;
bool NoUserRegistry; bool NoUserRegistry;

View File

@ -624,29 +624,6 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
{ {
cmSystemTools::RemoveFile(compilerLangFile.c_str()); cmSystemTools::RemoveFile(compilerLangFile.c_str());
} }
else
{
// load backwards compatibility stuff for C and CXX
// for old versions of CMake ListFiles C and CXX had some
// backwards compatibility files they have to load
// These files have a bunch of try compiles in them so
// should only be done
if (mf->NeedBackwardsCompatibility(1,4))
{
if(strcmp(lang, "C") == 0)
{
ifpath =
mf->GetModulesFile("CMakeBackwardCompatibilityC.cmake");
mf->ReadListFile(0,ifpath.c_str());
}
if(strcmp(lang, "CXX") == 0)
{
ifpath =
mf->GetModulesFile("CMakeBackwardCompatibilityCXX.cmake");
mf->ReadListFile(0,ifpath.c_str());
}
}
}
} // end if in try compile } // end if in try compile
} // end need test language } // end need test language
// Store the shared library flags so that we can satisfy CMP0018 // Store the shared library flags so that we can satisfy CMP0018

View File

@ -1412,13 +1412,6 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
includeBinaryDir = true; includeBinaryDir = true;
} }
// CMake versions below 2.0 would add the source tree to the -I path
// automatically. Preserve compatibility.
if(this->NeedBackwardsCompatibility(1,9))
{
includeSourceDir = true;
}
// Hack for VTK 4.0 - 4.4 which depend on the old behavior but do // Hack for VTK 4.0 - 4.4 which depend on the old behavior but do
// not set the backwards compatibility level automatically. // not set the backwards compatibility level automatically.
const char* vtkSourceDir = const char* vtkSourceDir =
@ -3071,7 +3064,7 @@ cmLocalGenerator
// Decide whether this language wants to replace the source // Decide whether this language wants to replace the source
// extension with the object extension. For CMake 2.4 // extension with the object extension. For CMake 2.4
// compatibility do this by default. // compatibility do this by default.
bool replaceExt = this->NeedBackwardsCompatibility(2, 4); bool replaceExt = this->NeedBackwardsCompatibility_2_4();
if(!replaceExt) if(!replaceExt)
{ {
if(const char* lang = source.GetLanguage()) if(const char* lang = source.GetLanguage())
@ -3318,9 +3311,7 @@ unsigned int cmLocalGenerator::GetBackwardsCompatibility()
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmLocalGenerator::NeedBackwardsCompatibility(unsigned int major, bool cmLocalGenerator::NeedBackwardsCompatibility_2_4()
unsigned int minor,
unsigned int patch)
{ {
// Check the policy to decide whether to pay attention to this // Check the policy to decide whether to pay attention to this
// variable. // variable.
@ -3348,7 +3339,7 @@ bool cmLocalGenerator::NeedBackwardsCompatibility(unsigned int major,
// equal to or lower than the given version. // equal to or lower than the given version.
unsigned int actual_compat = this->GetBackwardsCompatibility(); unsigned int actual_compat = this->GetBackwardsCompatibility();
return (actual_compat && return (actual_compat &&
actual_compat <= CMake_VERSION_ENCODE(major, minor, patch)); actual_compat <= CMake_VERSION_ENCODE(2, 4, 255));
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -324,9 +324,7 @@ public:
/** /**
* Test whether compatibility is set to a given version or lower. * Test whether compatibility is set to a given version or lower.
*/ */
bool NeedBackwardsCompatibility(unsigned int major, bool NeedBackwardsCompatibility_2_4();
unsigned int minor,
unsigned int patch = 0xFFu);
/** /**
* Generate a Mac OS X application bundle Info.plist file. * Generate a Mac OS X application bundle Info.plist file.

View File

@ -799,22 +799,6 @@ void cmMakefile::SetLocalGenerator(cmLocalGenerator* lg)
this->CheckSystemVars = this->GetCMakeInstance()->GetCheckSystemVars(); this->CheckSystemVars = this->GetCMakeInstance()->GetCheckSystemVars();
} }
bool cmMakefile::NeedBackwardsCompatibility(unsigned int major,
unsigned int minor,
unsigned int patch)
{
if(this->LocalGenerator)
{
return
this->LocalGenerator->NeedBackwardsCompatibility(major, minor, patch);
}
else
{
return false;
}
}
namespace namespace
{ {
struct file_not_persistent struct file_not_persistent
@ -871,13 +855,15 @@ void cmMakefile::ConfigureFinalPass()
this->FinalPass(); this->FinalPass();
const char* oldValue const char* oldValue
= this->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY"); = this->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY");
if (oldValue && atof(oldValue) <= 1.2) if (oldValue && cmSystemTools::VersionCompare(
cmSystemTools::OP_LESS, oldValue, "2.4"))
{ {
cmSystemTools::Error("You have requested backwards compatibility " this->IssueMessage(
"with CMake version 1.2 or earlier. This version " cmake::FATAL_ERROR,
"of CMake only supports backwards compatibility " "You have set CMAKE_BACKWARDS_COMPATIBILITY to a CMake version less "
"with CMake 1.4 or later. For compatibility with " "than 2.4. This version of CMake only supports backwards compatibility "
"1.2 or earlier please use CMake 2.0"); "with CMake 2.4 or later. For compatibility with older versions please "
"use any CMake 2.8.x release or lower.");
} }
for (cmTargets::iterator l = this->Targets.begin(); for (cmTargets::iterator l = this->Targets.begin();
l != this->Targets.end(); l++) l != this->Targets.end(); l++)
@ -1456,8 +1442,6 @@ void cmMakefile::AddLinkLibraryForTarget(const char *target,
this->GetCMakeInstance()->GetGlobalGenerator()->FindTarget(0,lib); this->GetCMakeInstance()->GetGlobalGenerator()->FindTarget(0,lib);
if(tgt) if(tgt)
{ {
// CMake versions below 2.4 allowed linking to modules.
bool allowModules = this->NeedBackwardsCompatibility(2,2);
// if it is not a static or shared library then you can not link to it // if it is not a static or shared library then you can not link to it
if(!((tgt->GetType() == cmTarget::STATIC_LIBRARY) || if(!((tgt->GetType() == cmTarget::STATIC_LIBRARY) ||
(tgt->GetType() == cmTarget::SHARED_LIBRARY) || (tgt->GetType() == cmTarget::SHARED_LIBRARY) ||
@ -1470,24 +1454,7 @@ void cmMakefile::AddLinkLibraryForTarget(const char *target,
<< " may not be linked into another target. " << " may not be linked into another target. "
<< "One may link only to STATIC or SHARED libraries, or " << "One may link only to STATIC or SHARED libraries, or "
<< "to executables with the ENABLE_EXPORTS property set."; << "to executables with the ENABLE_EXPORTS property set.";
// in older versions of cmake linking to modules was allowed this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
if( tgt->GetType() == cmTarget::MODULE_LIBRARY )
{
e << "\n"
<< "If you are developing a new project, re-organize it to avoid "
<< "linking to modules. "
<< "If you are just trying to build an existing project, "
<< "set CMAKE_BACKWARDS_COMPATIBILITY to 2.2 or lower to allow "
<< "linking to modules.";
}
// if no modules are allowed then this is always an error
if(!allowModules ||
// if we allow modules but the type is not a module then it is
// still an error
(allowModules && tgt->GetType() != cmTarget::MODULE_LIBRARY))
{
this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
}
} }
} }
i->second.AddLinkLibrary( *this, target, lib, llt ); i->second.AddLinkLibrary( *this, target, lib, llt );

View File

@ -145,13 +145,6 @@ public:
cmLocalGenerator* GetLocalGenerator() cmLocalGenerator* GetLocalGenerator()
{ return this->LocalGenerator;} { return this->LocalGenerator;}
/**
* Test whether compatibility is set to a given version or lower.
*/
bool NeedBackwardsCompatibility(unsigned int major,
unsigned int minor,
unsigned int patch = 0xFFu);
/** /**
* Help enforce global target name uniqueness. * Help enforce global target name uniqueness.
*/ */

View File

@ -357,15 +357,9 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
if (majorVer < 2 || (majorVer == 2 && minorVer < 4)) if (majorVer < 2 || (majorVer == 2 && minorVer < 4))
{ {
mf->IssueMessage(cmake::FATAL_ERROR, mf->IssueMessage(cmake::FATAL_ERROR,
"An attempt was made to set the policy version of CMake to something " "Compatibility with CMake < 2.4 is not supported by CMake >= 3.0. "
"earlier than \"2.4\". " "For compatibility with older versions please use any CMake 2.8.x "
"In CMake 2.4 and below backwards compatibility was handled with the " "release or lower.");
"CMAKE_BACKWARDS_COMPATIBILITY variable. "
"In order to get compatibility features supporting versions earlier "
"than 2.4 set policy CMP0001 to OLD to tell CMake to check the "
"CMAKE_BACKWARDS_COMPATIBILITY variable. "
"One way to do this is to set the policy version to 2.4 exactly."
);
return false; return false;
} }

View File

@ -5376,11 +5376,9 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
// There is no implicit link interface for executables or modules // There is no implicit link interface for executables or modules
// so if none was explicitly set then there is no link interface. // so if none was explicitly set then there is no link interface.
// Note that CMake versions 2.2 and below allowed linking to modules.
bool canLinkModules = this->Makefile->NeedBackwardsCompatibility(2,2);
if(!explicitLibraries && if(!explicitLibraries &&
(this->GetType() == cmTarget::EXECUTABLE || (this->GetType() == cmTarget::EXECUTABLE ||
(this->GetType() == cmTarget::MODULE_LIBRARY && !canLinkModules))) (this->GetType() == cmTarget::MODULE_LIBRARY)))
{ {
return false; return false;
} }

View File

@ -99,30 +99,6 @@
static bool cmakeCheckStampFile(const char* stampName); static bool cmakeCheckStampFile(const char* stampName);
static bool cmakeCheckStampList(const char* stampName); static bool cmakeCheckStampList(const char* stampName);
void cmNeedBackwardsCompatibility(const std::string& variable,
int access_type, void*, const char*, const cmMakefile*)
{
#ifdef CMAKE_BUILD_WITH_CMAKE
if (access_type == cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS)
{
std::string message = "An attempt was made to access a variable: ";
message += variable;
message +=
" that has not been defined. Some variables were always defined "
"by CMake in versions prior to 1.6. To fix this you might need to set "
"the cache value of CMAKE_BACKWARDS_COMPATIBILITY to 1.4 or less. If "
"you are writing a CMakeLists file, (or have already set "
"CMAKE_BACKWARDS_COMPATIBILITY to 1.4 or less) then you probably need "
"to include a CMake module to test for the feature this variable "
"defines.";
cmSystemTools::Error(message.c_str());
}
#else
(void)variable;
(void)access_type;
#endif
}
void cmWarnUnusedCliWarning(const std::string& variable, void cmWarnUnusedCliWarning(const std::string& variable,
int, void* ctx, const char*, const cmMakefile*) int, void* ctx, const char*, const cmMakefile*)
{ {
@ -169,12 +145,6 @@ cmake::cmake()
#ifdef CMAKE_BUILD_WITH_CMAKE #ifdef CMAKE_BUILD_WITH_CMAKE
this->VariableWatch = new cmVariableWatch; this->VariableWatch = new cmVariableWatch;
this->VariableWatch->AddWatch("CMAKE_WORDS_BIGENDIAN",
cmNeedBackwardsCompatibility);
this->VariableWatch->AddWatch("CMAKE_SIZEOF_INT",
cmNeedBackwardsCompatibility);
this->VariableWatch->AddWatch("CMAKE_X_LIBS",
cmNeedBackwardsCompatibility);
#endif #endif
this->AddDefaultGenerators(); this->AddDefaultGenerators();

View File

@ -1,7 +1,7 @@
# #
# A more complex test case # A more complex test case
# #
set(CMAKE_BACKWARDS_COMPATIBILITY 1.4) cmake_minimum_required(VERSION 2.4)
project (Complex) project (Complex)
# Try setting a new policy. The IF test is for coverage. # Try setting a new policy. The IF test is for coverage.

View File

@ -1,4 +1,3 @@
cmake_minimum_required(VERSION 1.3)
# #
# Create exe. # Create exe.
# #

View File

@ -838,13 +838,13 @@ int main()
#endif #endif
#endif // defined(_WIN32) && !defined(__CYGWIN__) #endif // defined(_WIN32) && !defined(__CYGWIN__)
if(strcmp(CMAKE_MINIMUM_REQUIRED_VERSION, "1.3") == 0) if(strcmp(CMAKE_MINIMUM_REQUIRED_VERSION, "2.4") == 0)
{ {
cmPassed("CMAKE_MINIMUM_REQUIRED_VERSION is set to 1.3"); cmPassed("CMAKE_MINIMUM_REQUIRED_VERSION is set to 2.4");
} }
else else
{ {
cmFailed("CMAKE_MINIMUM_REQUIRED_VERSION is not set to the expected 1.3"); cmFailed("CMAKE_MINIMUM_REQUIRED_VERSION is not set to the expected 2.4");
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------

View File

@ -1,7 +1,7 @@
# #
# A more complex test case # A more complex test case
# #
set(CMAKE_BACKWARDS_COMPATIBILITY 1.4) cmake_minimum_required(VERSION 2.4)
project (Complex) project (Complex)
# Try setting a new policy. The IF test is for coverage. # Try setting a new policy. The IF test is for coverage.

View File

@ -1,4 +1,3 @@
cmake_minimum_required(VERSION 1.3)
# #
# Create exe. # Create exe.
# #

View File

@ -838,13 +838,13 @@ int main()
#endif #endif
#endif // defined(_WIN32) && !defined(__CYGWIN__) #endif // defined(_WIN32) && !defined(__CYGWIN__)
if(strcmp(CMAKE_MINIMUM_REQUIRED_VERSION, "1.3") == 0) if(strcmp(CMAKE_MINIMUM_REQUIRED_VERSION, "2.4") == 0)
{ {
cmPassed("CMAKE_MINIMUM_REQUIRED_VERSION is set to 1.3"); cmPassed("CMAKE_MINIMUM_REQUIRED_VERSION is set to 2.4");
} }
else else
{ {
cmFailed("CMAKE_MINIMUM_REQUIRED_VERSION is not set to the expected 1.3"); cmFailed("CMAKE_MINIMUM_REQUIRED_VERSION is not set to the expected 2.4");
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------

View File

@ -93,6 +93,7 @@ add_RunCMake_test(Syntax)
add_RunCMake_test(add_dependencies) add_RunCMake_test(add_dependencies)
add_RunCMake_test(build_command) add_RunCMake_test(build_command)
add_RunCMake_test(cmake_minimum_required)
add_RunCMake_test(find_package) add_RunCMake_test(find_package)
add_RunCMake_test(get_filename_component) add_RunCMake_test(get_filename_component)
add_RunCMake_test(if) add_RunCMake_test(if)

View File

@ -0,0 +1,5 @@
CMake Warning \(dev\) at Before24.cmake:1 \(cmake_minimum_required\):
Compatibility with CMake < 2.4 is not supported by CMake >= 3.0.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.

View File

@ -0,0 +1 @@
cmake_minimum_required(VERSION 2.2)

View File

@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 2.8)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,5 @@
CMake Error in CMakeLists.txt:
You have set CMAKE_BACKWARDS_COMPATIBILITY to a CMake version less than
2.4. This version of CMake only supports backwards compatibility with
CMake 2.4 or later. For compatibility with older versions please use any
CMake 2.8.x release or lower.

View File

@ -0,0 +1,2 @@
cmake_minimum_required(VERSION 2.4)
set(CMAKE_BACKWARDS_COMPATIBILITY 2.2)

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,6 @@
CMake Error at PolicyBefore24.cmake:2 \(cmake_policy\):
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.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -0,0 +1,2 @@
cmake_minimum_required(VERSION 2.4)
cmake_policy(VERSION 2.2)

View File

@ -0,0 +1,5 @@
include(RunCMake)
run_cmake(Before24)
run_cmake(CompatBefore24)
run_cmake(PolicyBefore24)