new command

This commit is contained in:
Ken Martin 2001-04-23 16:33:24 -04:00
parent 8852ed9d2f
commit b49204ab0d
2 changed files with 121 additions and 0 deletions

View File

@ -0,0 +1,43 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2000 National Library of Medicine
All rights reserved.
See COPYRIGHT.txt for copyright details.
=========================================================================*/
#include "cmOptionCommand.h"
// cmOptionCommand
bool cmOptionCommand::Invoke(std::vector<std::string>& args)
{
if(args.size() < 1)
{
this->SetError("called with incorrect number of arguments");
return false;
}
// Now check and see if the value has been stored in the cache
// already, if so use that value and don't look for the program
const char* cacheValue
= cmCacheManager::GetInstance()->GetCacheValue(args[0].c_str());
if(!cacheValue)
{
cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),"0",
cmCacheManager::BOOL);
m_Makefile->AddDefinition(args[0].c_str(), "0");
}
else
{
m_Makefile->AddDefinition("WRAP_TCL", cacheValue);
}
return true;
}

78
Source/cmOptionCommand.h Normal file
View File

@ -0,0 +1,78 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2000 National Library of Medicine
All rights reserved.
See COPYRIGHT.txt for copyright details.
=========================================================================*/
#ifndef cmOptionCommand_h
#define cmOptionCommand_h
#include "cmStandardIncludes.h"
#include "cmCommand.h"
/** \class cmOptionCommand
* \brief Provide an option to the user
*
* cmOptionCommand provides an option for the user to select
*/
class cmOptionCommand : public cmCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
{
return new cmOptionCommand;
}
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool Invoke(std::vector<std::string>& args);
/**
* This determines if the command gets propagated down
* to makefiles located in subdirectories.
*/
virtual bool IsInherited() {return true;}
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName() {return "OPTION";}
/**
* Succinct documentation.
*/
virtual const char* GetTerseDocumentation()
{
return "Provides an option that the user can optionally select";
}
/**
* More documentation.
*/
virtual const char* GetFullDocumentation()
{
return
"OPTION(USE_MPI)\n"
"Provide an option for the user to select";
}
cmTypeMacro(cmOptionCommand, cmCommand);
};
#endif