ENH: make CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS the default and remove the property. If any value is specified in an endif, endforeach, endwhile, etc then make sure it matches the start string. If no values are given then it is no longer an error.

This commit is contained in:
Bill Hoffman 2008-02-29 12:18:11 -05:00
parent 03ef00bc93
commit f386c2aae0
6 changed files with 21 additions and 28 deletions

View File

@ -103,10 +103,10 @@ ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf)
{ {
std::vector<std::string> expandedArguments; std::vector<std::string> expandedArguments;
mf.ExpandArguments(lff.Arguments, expandedArguments); mf.ExpandArguments(lff.Arguments, expandedArguments);
if ((!expandedArguments.empty() && // if the endforeach has arguments then make sure
(expandedArguments[0] == this->Args[0])) // they match the begin foreach arguments
|| cmSystemTools::IsOn if ((expandedArguments.empty() ||
(mf.GetPropertyOrDefinition("CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS"))) (expandedArguments[0] == this->Args[0])))
{ {
return true; return true;
} }

View File

@ -253,10 +253,10 @@ ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf)
{ {
std::vector<std::string> expandedArguments; std::vector<std::string> expandedArguments;
mf.ExpandArguments(lff.Arguments, expandedArguments); mf.ExpandArguments(lff.Arguments, expandedArguments);
if ((!expandedArguments.empty() && // if the endfunction has arguments then make sure
(expandedArguments[0] == this->Args[0])) // they match the ones in the openeing function command
|| cmSystemTools::IsOn if ((expandedArguments.empty() ||
(mf.GetPropertyOrDefinition("CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS"))) (expandedArguments[0] == this->Args[0])))
{ {
return true; return true;
} }

View File

@ -145,9 +145,10 @@ bool cmIfFunctionBlocker::ShouldRemove(const cmListFileFunction& lff,
{ {
if (!cmSystemTools::Strucmp(lff.Name.c_str(),"endif")) if (!cmSystemTools::Strucmp(lff.Name.c_str(),"endif"))
{ {
if (cmSystemTools::IsOn // if the endif has arguments, then make sure
(mf.GetPropertyOrDefinition("CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS")) // they match the arguments of the matching if
|| lff.Arguments == this->Args) if (lff.Arguments.size() == 0 ||
lff.Arguments == this->Args)
{ {
return true; return true;
} }

View File

@ -329,10 +329,10 @@ ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf)
{ {
std::vector<std::string> expandedArguments; std::vector<std::string> expandedArguments;
mf.ExpandArguments(lff.Arguments, expandedArguments); mf.ExpandArguments(lff.Arguments, expandedArguments);
if ((!expandedArguments.empty() && // if the endmacro has arguments make sure they
(expandedArguments[0] == this->Args[0])) // match the arguments of the macro
|| cmSystemTools::IsOn if ((expandedArguments.empty() ||
(mf.GetPropertyOrDefinition("CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS"))) (expandedArguments[0] == this->Args[0])))
{ {
return true; return true;
} }

View File

@ -3038,15 +3038,6 @@ void cmMakefile::DefineProperties(cmake *cm)
"If this is true then the outputs of custom commands for this " "If this is true then the outputs of custom commands for this "
"directory will not be removed during the \"make clean\" stage. "); "directory will not be removed during the \"make clean\" stage. ");
cm->DefineProperty
("CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS", cmProperty::DIRECTORY,
"Allow loops to have non-matching closing statements.",
"If this is set then the closing statement of control "
"structures in CMake will not require an exact match to the "
"opening statement. For example IF(foo) will not require "
"ENDIF(foo) but simple ENDIF() will work.",
true);
cm->DefineProperty cm->DefineProperty
("LISTFILE_STACK", cmProperty::DIRECTORY, ("LISTFILE_STACK", cmProperty::DIRECTORY,
"The current stack of listfiles being processed.", "The current stack of listfiles being processed.",

View File

@ -93,9 +93,10 @@ ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf)
{ {
if(!cmSystemTools::Strucmp(lff.Name.c_str(),"endwhile")) if(!cmSystemTools::Strucmp(lff.Name.c_str(),"endwhile"))
{ {
if (lff.Arguments == this->Args // if the endwhile has arguments, then make sure
|| cmSystemTools::IsOn // they match the arguments of the matching while
(mf.GetPropertyOrDefinition("CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS"))) if (lff.Arguments.size() == 0 ||
lff.Arguments == this->Args)
{ {
return true; return true;
} }