[cmake-commits] martink committed cmCommands.cxx 1.104 1.105
cmElseIfCommand.cxx NONE 1.1 cmElseIfCommand.h NONE 1.1
cmIfCommand.cxx 1.68 1.69 cmIfCommand.h 1.36 1.37
cmake-commits at cmake.org
cmake-commits at cmake.org
Fri Sep 22 11:23:54 EDT 2006
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv22485
Modified Files:
cmCommands.cxx cmIfCommand.cxx cmIfCommand.h
Added Files:
cmElseIfCommand.cxx cmElseIfCommand.h
Log Message:
ENH: added elseif
Index: cmCommands.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCommands.cxx,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -d -r1.104 -r1.105
--- cmCommands.cxx 19 Apr 2006 14:50:15 -0000 1.104
+++ cmCommands.cxx 22 Sep 2006 15:23:51 -0000 1.105
@@ -20,6 +20,7 @@
#include "cmAuxSourceDirectoryCommand.cxx"
#include "cmBuildNameCommand.cxx"
#include "cmCreateTestSourceList.cxx"
+#include "cmElseIfCommand.cxx"
#include "cmEnableLanguageCommand.cxx"
#include "cmEndWhileCommand.cxx"
#include "cmExecuteProcessCommand.cxx"
@@ -73,6 +74,7 @@
commands.push_back(new cmAuxSourceDirectoryCommand);
commands.push_back(new cmBuildNameCommand);
commands.push_back(new cmCreateTestSourceList);
+ commands.push_back(new cmElseIfCommand);
commands.push_back(new cmEnableLanguageCommand);
commands.push_back(new cmEndWhileCommand);
commands.push_back(new cmExecuteProcessCommand);
--- NEW FILE: cmElseIfCommand.h ---
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile: cmElseIfCommand.h,v $
Language: C++
Date: $Date: 2006/09/22 15:23:51 $
Version: $Revision: 1.1 $
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef cmElseIfCommand_h
#define cmElseIfCommand_h
#include "cmIfCommand.h"
/** \class cmElseIfCommand
* \brief ends an if block
*
* cmElseIfCommand ends an if block
*/
class cmElseIfCommand : public cmCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
{
return new cmElseIfCommand;
}
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args);
/**
* This determines if the command is invoked when in script mode.
*/
virtual bool IsScriptable() { return true; }
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName() { return "ELSEIF";}
/**
* Succinct documentation.
*/
virtual const char* GetTerseDocumentation()
{
return "Starts the ELSEIF portion of an IF block.";
}
/**
* More documentation.
*/
virtual const char* GetFullDocumentation()
{
return
" ELSEIF(expression)\n"
"See the IF command.";
}
cmTypeMacro(cmElseIfCommand, cmCommand);
};
#endif
--- NEW FILE: cmElseIfCommand.cxx ---
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile: cmElseIfCommand.cxx,v $
Language: C++
Date: $Date: 2006/09/22 15:23:51 $
Version: $Revision: 1.1 $
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "cmElseIfCommand.h"
bool cmElseIfCommand::InitialPass(std::vector<std::string> const&)
{
this->SetError("An ELSEIF command was found outside of a proper "
"IF ENDIF structure.");
return false;
}
Index: cmIfCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmIfCommand.cxx,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- cmIfCommand.cxx 26 Aug 2006 14:28:08 -0000 1.68
+++ cmIfCommand.cxx 22 Sep 2006 15:23:51 -0000 1.69
@@ -29,22 +29,65 @@
}
// watch for our ELSE or ENDIF
- if (!cmSystemTools::Strucmp(lff.Name.c_str(),"else") ||
+ if (!cmSystemTools::Strucmp(lff.Name.c_str(),"else") ||
+ !cmSystemTools::Strucmp(lff.Name.c_str(),"elseif") ||
!cmSystemTools::Strucmp(lff.Name.c_str(),"endif"))
{
// if it was an else statement then we should change state
// and block this Else Command
if (!cmSystemTools::Strucmp(lff.Name.c_str(),"else"))
+ {
+ this->IsBlocking = this->HasRun;
+ return true;
+ }
+ // if it was an elseif statement then we should check state
+ // and possibly block this Else Command
+ if (!cmSystemTools::Strucmp(lff.Name.c_str(),"elseif"))
+ {
+ if (!this->HasRun)
{
- this->IsBlocking = !this->IsBlocking;
- return true;
+ char* errorString = 0;
+
+ std::vector<std::string> expandedArguments;
+ mf.ExpandArguments(lff.Arguments, expandedArguments);
+ bool isTrue =
+ cmIfCommand::IsTrue(expandedArguments,&errorString,&mf);
+
+ if (errorString)
+ {
+ std::string err = "had incorrect arguments: ";
+ unsigned int i;
+ for(i =0; i < lff.Arguments.size(); ++i)
+ {
+ err += (lff.Arguments[i].Quoted?"\"":"");
+ err += lff.Arguments[i].Value;
+ err += (lff.Arguments[i].Quoted?"\"":"");
+ err += " ";
+ }
+ err += "(";
+ err += errorString;
+ err += ").";
+ cmSystemTools::Error(err.c_str());
+ delete [] errorString;
+ return false;
+ }
+
+ if (isTrue)
+ {
+ this->IsBlocking = false;
+ this->HasRun = true;
+ return true;
+ }
}
- // otherwise it must be an ENDIF statement, in that case remove the
- // function blocker
- mf.RemoveFunctionBlocker(lff);
- return true;
- }
-
+ this->IsBlocking = true;
+ return true;
+ }
+ // otherwise it must be an ENDIF statement, in that case remove the
+ // function blocker
+ mf.RemoveFunctionBlocker(lff);
+ return true;
+ }
+
return this->IsBlocking;
}
@@ -113,6 +156,10 @@
cmIfFunctionBlocker *f = new cmIfFunctionBlocker();
// if is isn't true block the commands
f->IsBlocking = !isTrue;
+ if (isTrue)
+ {
+ f->HasRun = true;
+ }
f->Args = args;
this->Makefile->AddFunctionBlocker(f);
Index: cmIfCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmIfCommand.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- cmIfCommand.h 25 Aug 2006 20:31:07 -0000 1.36
+++ cmIfCommand.h 22 Sep 2006 15:23:51 -0000 1.37
@@ -28,7 +28,7 @@
class cmIfFunctionBlocker : public cmFunctionBlocker
{
public:
- cmIfFunctionBlocker() {}
+ cmIfFunctionBlocker() {this->HasRun = false;}
virtual ~cmIfFunctionBlocker() {}
virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
cmMakefile &mf);
@@ -38,6 +38,7 @@
std::vector<cmListFileArgument> Args;
bool IsBlocking;
+ bool HasRun;
};
/** \class cmIfCommand
More information about the Cmake-commits
mailing list