[cmake-commits] martink committed cmDefinePropertyCommand.cxx NONE 1.1 cmDefinePropertyCommand.h NONE 1.1

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Dec 7 09:45:34 EST 2006


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv18605

Added Files:
	cmDefinePropertyCommand.cxx cmDefinePropertyCommand.h 
Log Message:
ENH: make properties a bit more formal with documentation and chaining


--- NEW FILE: cmDefinePropertyCommand.h ---
/*=========================================================================

  Program:   CMake - Cross-Platform Makefile Generator
  Module:    $RCSfile: cmDefinePropertyCommand.h,v $
  Language:  C++
  Date:      $Date: 2006/12/07 14:45:32 $
  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 cmDefinesPropertyCommand_h
#define cmDefinesPropertyCommand_h

#include "cmCommand.h"

class cmDefinePropertyCommand : public cmCommand
{
public:
  virtual cmCommand* Clone() 
    {
      return new cmDefinePropertyCommand;
    }

  /**
   * This is called when the command is first encountered in
   * the input file.
   */
  virtual bool InitialPass(std::vector<std::string> const& args);

  /**
   * The name of the command as specified in CMakeList.txt.
   */
  virtual const char* GetName() { return "DEFINE_PROPERTY";}

  /**
   * Succinct documentation.
   */
  virtual const char* GetTerseDocumentation() 
    {
    return "Define properties used by CMake.";
    }
  
  /**
   * Longer documentation.
   */
  virtual const char* GetFullDocumentation()
    {
      return
        "  DEFINE_PROPERTY(property_name scope_value\n"
        "                  short_description\n"
        "                  full_description chain)\n"
        "Define a property for a scope. The scope_value is either GLOBAL "
        "DIRECTORY, TARGET, TEST, SOURCE_FILE. The short and full "
        "descriptions are used to document the property, chain indicates "
        "if that property chains such that a request for the property "
        "on a target will chain up to the directory if it is not set on the "
        "target. In such cases the property's scope is the most specific. "
        "In that example the scope would be TARGET even though it can "
        "chain up to DIRECTORY and GLOBAL."
        ;
    }
  
  cmTypeMacro(cmDefinePropertyCommand, cmCommand);
};



#endif

--- NEW FILE: cmDefinePropertyCommand.cxx ---
/*=========================================================================

  Program:   CMake - Cross-Platform Makefile Generator
  Module:    $RCSfile: cmDefinePropertyCommand.cxx,v $
  Language:  C++
  Date:      $Date: 2006/12/07 14:45:32 $
  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 "cmDefinePropertyCommand.h"
#include "cmake.h"

// cmDefinePropertiesCommand
bool cmDefinePropertyCommand::InitialPass(
  std::vector<std::string> const& args)
{
  if(args.size() < 5 )
    {
    this->SetError("called with incorrect number of arguments");
    return false;
    }

  // determine the scope
  cmProperty::ScopeType scope;
  if (args[1] == "GLOBAL")
    {
    scope = cmProperty::GLOBAL;
    }
  else if (args[1] == "DIRECTORY")
    {
    scope = cmProperty::DIRECTORY;
    }
  else if (args[1] == "TARGET")
    {
    scope = cmProperty::TARGET;
    }
  else if (args[1] == "SOURCE_FILE")
    {
    scope = cmProperty::SOURCE_FILE;
    }
  else if (args[1] == "TEST")
    {
    scope = cmProperty::TEST;
    }
  else
    {
    this->SetError("called with illegal arguments.");
    return false;
    }

  this->Makefile->GetCMakeInstance()->DefineProperty
    (args[0].c_str(), scope,args[2].c_str(), args[3].c_str(),
     cmSystemTools::IsOn(args[4].c_str()));
  
  return true;
}




More information about the Cmake-commits mailing list