summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-03-31 17:33:09 (GMT)
committerBrad King <brad.king@kitware.com>2008-03-31 17:33:09 (GMT)
commite3666a1de575c7a2c4ef757b3f6e9a63fdfa2b8e (patch)
treee521de165a8ed09b010cc148b82f8b972555ae30 /Source/cmMakefile.cxx
parent3652a8e913eab6befcbdc74cbd985763ed27db33 (diff)
downloadCMake-e3666a1de575c7a2c4ef757b3f6e9a63fdfa2b8e.zip
CMake-e3666a1de575c7a2c4ef757b3f6e9a63fdfa2b8e.tar.gz
CMake-e3666a1de575c7a2c4ef757b3f6e9a63fdfa2b8e.tar.bz2
ENH: Allow policy CMP0000 to be set explicitly
- Message for missing cmake_minimum_required is not issued until the end of processing the top CMakeLists.txt file - During processing a cmake_policy command may set behavior - OLD behavior is to silently ignore the problem - NEW behavior is to issue an error instead of a warning
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx67
1 files changed, 56 insertions, 11 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index f09c605..135dc28 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -146,6 +146,10 @@ void cmMakefile::Initialize()
// Enter a policy level for this directory.
this->PushPolicy();
+
+ // By default the check is not done. It is enabled by
+ // cmListFileCache in the top level if necessary.
+ this->CheckCMP0000 = false;
}
unsigned int cmMakefile::GetCacheMajorVersion()
@@ -561,19 +565,11 @@ bool cmMakefile::ReadListFile(const char* filename_in,
}
}
- // If this is the directory-level CMakeLists.txt file then enforce
- // policy stack depth.
+ // If this is the directory-level CMakeLists.txt file then perform
+ // some extra checks.
if(this->ListFileStack.size() == 1)
{
- while(this->PolicyStack.size() > 1)
- {
- if(endScopeNicely)
- {
- this->IssueMessage(cmake::FATAL_ERROR,
- "cmake_policy PUSH without matching POP");
- }
- this->PopPolicy(false);
- }
+ this->EnforceDirectoryLevelRules(endScopeNicely);
}
this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentParentFile.c_str());
@@ -585,6 +581,55 @@ bool cmMakefile::ReadListFile(const char* filename_in,
return true;
}
+//----------------------------------------------------------------------------
+void cmMakefile::EnforceDirectoryLevelRules(bool endScopeNicely)
+{
+ // Enforce policy stack depth.
+ while(this->PolicyStack.size() > 1)
+ {
+ if(endScopeNicely)
+ {
+ this->IssueMessage(cmake::FATAL_ERROR,
+ "cmake_policy PUSH without matching POP");
+ }
+ this->PopPolicy(false);
+ }
+
+ // Diagnose a violation of CMP0000 if necessary.
+ if(this->CheckCMP0000)
+ {
+ 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 (this->GetPolicyStatus(cmPolicies::CMP0000))
+ {
+ case cmPolicies::WARN:
+ // Warn because the user did not provide a mimimum required
+ // version.
+ this->IssueMessage(cmake::AUTHOR_WARNING, msg.str().c_str());
+ case cmPolicies::OLD:
+ // OLD behavior is to use policy version 2.4 set in
+ // cmListFileCache.
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::NEW:
+ // NEW behavior is to issue an error.
+ this->IssueMessage(cmake::FATAL_ERROR, msg.str().c_str());
+ cmSystemTools::SetFatalErrorOccured();
+ return;
+ }
+ }
+}
void cmMakefile::AddCommand(cmCommand* wg)
{