summaryrefslogtreecommitdiffstats
path: root/Source/cmListFileCache.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-03-19 19:18:21 (GMT)
committerBrad King <brad.king@kitware.com>2008-03-19 19:18:21 (GMT)
commit01033b5d567c90d24a500bd5605f2a1924cd88a4 (patch)
tree28ba6f59a9ef62178c5923f0f72231d852cae278 /Source/cmListFileCache.cxx
parentdb228dd6d26b5acb6bac541edeb1e2d1c5b500fd (diff)
downloadCMake-01033b5d567c90d24a500bd5605f2a1924cd88a4.zip
CMake-01033b5d567c90d24a500bd5605f2a1924cd88a4.tar.gz
CMake-01033b5d567c90d24a500bd5605f2a1924cd88a4.tar.bz2
ENH: Improve warning about specifying a cmake version
- Update policy CMP0000 to require use of the command cmake_minimum_required and not cmake_policy so there is only one way to avoid it. - Explicitly specify the line users should add. - Reference policy CMP0000 only at the end. - Fix policy CMP0000 documentation to not suggest use of the cmake_policy command.
Diffstat (limited to 'Source/cmListFileCache.cxx')
-rw-r--r--Source/cmListFileCache.cxx47
1 files changed, 24 insertions, 23 deletions
diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index 5711da2..f09ab10 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -19,6 +19,7 @@
#include "cmListFileLexer.h"
#include "cmSystemTools.h"
#include "cmMakefile.h"
+#include "cmVersion.h"
#include <cmsys/RegularExpression.hxx>
@@ -121,46 +122,46 @@ bool cmListFile::ParseFile(const char* filename,
// do we need a cmake_policy(VERSION call?
if(topLevel)
{
- bool hasPolicy = false;
+ bool hasVersion = false;
// search for the right policy command
for(std::vector<cmListFileFunction>::iterator i
= this->Functions.begin();
i != this->Functions.end(); ++i)
{
- if (cmSystemTools::LowerCase(i->Name) == "cmake_policy" &&
- i->Arguments.size() &&
- cmSystemTools::LowerCase(i->Arguments[0].Value) == "version")
- {
- hasPolicy = true;
- break;
- }
if (cmSystemTools::LowerCase(i->Name) == "cmake_minimum_required")
{
- hasPolicy = true;
+ hasVersion = true;
break;
}
}
- // if no policy command is found this is an error
- if(!hasPolicy)
- {
- switch (mf->GetPolicyStatus(cmPolicies::CMP0000))
+ // if no version command is found this is a warning or error
+ if(!hasVersion)
{
+ cmOStringStream msg;
+ msg << "No cmake_minimum_required command is present. "
+ << "A line of code such as\n"
+ << " cmake_minimum_required(VERSION "
+ << cmVersion::GetMajorVersion() << "."
+ << cmVersion::GetMinorVersion()
+ << ")\n"
+ << "should be added at the top of the file. "
+ << "The version specified may be lower if you wish to "
+ << "support older CMake versions for this project. "
+ << "For more information run "
+ << "\"cmake --help-policy CMP0000\".";
+ switch (mf->GetPolicyStatus(cmPolicies::CMP0000))
+ {
case cmPolicies::WARN:
- mf->IssueMessage(cmake::AUTHOR_WARNING,
- mf->GetPolicies()->GetPolicyWarning(cmPolicies::CMP0000)
- );
-
+ mf->IssueMessage(cmake::AUTHOR_WARNING, msg.str().c_str());
+ case cmPolicies::OLD:
// Implicitly set the version for the user.
mf->SetPolicyVersion("2.4");
- case cmPolicies::OLD:
- break;
+ break;
default:
- mf->IssueMessage(cmake::FATAL_ERROR,
- mf->GetPolicies()->GetRequiredPolicyError(cmPolicies::CMP0000)
- );
+ mf->IssueMessage(cmake::FATAL_ERROR, msg.str().c_str());
return false;
+ }
}
- }
}
if(topLevel)