[Cmake-commits] [cmake-commits] king committed cmListFileCache.cxx 1.44 1.45 cmMakefile.cxx 1.465 1.466 cmMakefile.h 1.230 1.231 cmPolicies.cxx 1.27 1.28
cmake-commits at cmake.org
cmake-commits at cmake.org
Mon Mar 31 13:33:11 EDT 2008
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv30565/Source
Modified Files:
cmListFileCache.cxx cmMakefile.cxx cmMakefile.h cmPolicies.cxx
Log Message:
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
Index: cmListFileCache.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmListFileCache.cxx,v
retrieving revision 1.44
retrieving revision 1.45
diff -C 2 -d -r1.44 -r1.45
*** cmListFileCache.cxx 20 Mar 2008 14:46:24 -0000 1.44
--- cmListFileCache.cxx 31 Mar 2008 17:33:08 -0000 1.45
***************
*** 172,199 ****
if (isProblem)
{
! 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, msg.str().c_str());
! case cmPolicies::OLD:
! // Implicitly set the version for the user.
! mf->SetPolicyVersion("2.4");
! break;
! default:
! mf->IssueMessage(cmake::FATAL_ERROR, msg.str().c_str());
! return false;
! }
}
}
--- 172,181 ----
if (isProblem)
{
! // Tell the top level cmMakefile to diagnose
! // this violation of CMP0000.
! mf->SetCheckCMP0000(true);
!
! // Implicitly set the version for the user.
! mf->SetPolicyVersion("2.4");
}
}
Index: cmPolicies.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmPolicies.cxx,v
retrieving revision 1.27
retrieving revision 1.28
diff -C 2 -d -r1.27 -r1.28
*** cmPolicies.cxx 24 Mar 2008 14:56:26 -0000 1.27
--- cmPolicies.cxx 31 Mar 2008 17:33:09 -0000 1.28
***************
*** 102,106 ****
"The command will ensure that at least the given version of CMake is "
"running and help newer versions be compatible with the project. "
! "See documentation of cmake_minimum_required for details.",
2,6,0, cmPolicies::WARN
);
--- 102,114 ----
"The command will ensure that at least the given version of CMake is "
"running and help newer versions be compatible with the project. "
! "See documentation of cmake_minimum_required for details.\n"
! "Note that the command invocation must appear in the CMakeLists.txt "
! "file itself; a call in an included file is not sufficient. "
! "However, the cmake_policy command may be called to set policy "
! "CMP0000 to OLD or NEW behavior explicitly. "
! "The OLD behavior is to silently ignore the missing invocation. "
! "The NEW behavior is to issue an error instead of a warning. "
! "An included file may set CMP0000 explicitly to affect how this "
! "policy is enforced for the main CMakeLists.txt file.",
2,6,0, cmPolicies::WARN
);
Index: cmMakefile.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.h,v
retrieving revision 1.230
retrieving revision 1.231
diff -C 2 -d -r1.230 -r1.231
*** cmMakefile.h 13 Mar 2008 17:48:57 -0000 1.230
--- cmMakefile.h 31 Mar 2008 17:33:09 -0000 1.231
***************
*** 794,797 ****
--- 794,800 ----
std::string const& text) const;
+ /** Set whether or not to report a CMP0000 violation. */
+ void SetCheckCMP0000(bool b) { this->CheckCMP0000 = b; }
+
protected:
// add link libraries and directories to the target
***************
*** 905,908 ****
--- 908,916 ----
cmPolicies::PolicyStatus> PolicyMap;
std::vector<PolicyMap> PolicyStack;
+
+ bool CheckCMP0000;
+
+ // Enforce rules about CMakeLists.txt files.
+ void EnforceDirectoryLevelRules(bool endScopeNicely);
};
Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.465
retrieving revision 1.466
diff -C 2 -d -r1.465 -r1.466
*** cmMakefile.cxx 13 Mar 2008 21:38:51 -0000 1.465
--- cmMakefile.cxx 31 Mar 2008 17:33:09 -0000 1.466
***************
*** 147,150 ****
--- 147,154 ----
// 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;
}
***************
*** 562,578 ****
}
! // If this is the directory-level CMakeLists.txt file then enforce
! // policy stack depth.
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);
! }
}
--- 566,574 ----
}
! // If this is the directory-level CMakeLists.txt file then perform
! // some extra checks.
if(this->ListFileStack.size() == 1)
{
! this->EnforceDirectoryLevelRules(endScopeNicely);
}
***************
*** 586,589 ****
--- 582,634 ----
}
+ //----------------------------------------------------------------------------
+ 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)
More information about the Cmake-commits
mailing list