[CMake] Add VisualDSP4 project file generator

Raphael Cotty raphael.cotty at googlemail.com
Thu Jun 14 05:49:38 EDT 2007


Skipped content of type multipart/alternative-------------- next part --------------
#ifndef cmGlobalVisualDSP4Generator_h
#define cmGlobalVisualDSP4Generator_h

#include "cmGlobalGenerator.h"

/** \class cmGlobalVisualDSP4Generator
 * \brief Base class for global Visual Studio generators.
 *
 * cmGlobalVisualDSP4Generator provides functionality common to all
 * global Visual Studio generators.
 */
class cmGlobalVisualDSP4Generator : public cmGlobalGenerator
{
public:
  cmGlobalVisualDSP4Generator();
  static cmGlobalGenerator* New() { return new cmGlobalVisualDSP4Generator; }

  ///! Get the name for the generator.
  virtual const char* GetName() const {
    return cmGlobalVisualDSP4Generator::GetActualName();}
  static const char* GetActualName() {return "VisualDSP4";}

  /** Get the documentation entry for this generator.  */
  virtual void GetDocumentation(cmDocumentationEntry& entry) const;
  
  ///! Create a local generator appropriate to this Global Generator
  virtual cmLocalGenerator *CreateLocalGenerator();

  virtual void Generate();

  virtual void EnableLanguage(std::vector<std::string>const& languages,
                              cmMakefile *);

  virtual ~cmGlobalVisualDSP4Generator();

protected:
private:
};

#endif
-------------- next part --------------
/*=========================================================================

  Program:   CMake - Cross-Platform Makefile Generator
  Module:    $RCSfile: cmLocalVisualDSP4Generator.h,v $
  Language:  C++
  Date:      $Date: 2007/05/09 18:41:38 $
  Version:   $Revision: 1.18 $

  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 cmLocalVisualDSP4Generator_h
#define cmLocalVisualDSP4Generator_h

#include "cmLocalGenerator.h"

class cmMakeDepend;
class cmTarget;
class cmSourceFile;
class cmSourceGroup;
class cmCustomCommand;

/** \class cmLocalVisualDSP4Generator
 *
 */
class cmLocalVisualDSP4Generator : public cmLocalGenerator
{
public:
  ///! Set cache only and recurse to false by default.
  cmLocalVisualDSP4Generator();

  virtual ~cmLocalVisualDSP4Generator();

  /**
   * Generate the makefile for this directory. 
   */
  virtual void Generate();

private:
};

#endif
-------------- next part --------------
#include "cmGlobalVisualDSP4Generator.h"
#include "cmLocalVisualDSP4Generator.h"
#include "cmGeneratedFileStream.h"
#include "cmMakefile.h"
#include "cmTarget.h"
#include "cmSourceFile.h"

#include "cmSystemTools.h"

cmGlobalVisualDSP4Generator::cmGlobalVisualDSP4Generator()
{
  this->FindMakeProgramFile = "CMakeVDSP4FindMake.cmake";
}

//----------------------------------------------------------------------------
cmGlobalVisualDSP4Generator::~cmGlobalVisualDSP4Generator()
{
}

void cmGlobalVisualDSP4Generator
::GetDocumentation(cmDocumentationEntry& entry) const
{
  entry.name = this->GetName();
  entry.brief = "Generates VisualDSP 4 project files.";
  entry.full =
    "TODO";
}

///! Create a local generator appropriate to this Global Generator
cmLocalGenerator *cmGlobalVisualDSP4Generator::CreateLocalGenerator()
{
  cmLocalGenerator *lg = new cmLocalVisualDSP4Generator;
  lg->SetGlobalGenerator(this);
  return lg;
}

void cmGlobalVisualDSP4Generator::Generate()
{
    // Run all the local generators.
    this->cmGlobalGenerator::Generate();

    cmGeneratedFileStream fout;
    bool opened = false;
    if( this->LocalGenerators.size() > 0 )
    {
        cmMakefile* mf = this->LocalGenerators[0]->GetMakefile();
        const char* activeProject = mf->GetDefinition( "CMAKE_ACTIVE_PROJECT" );
        if( activeProject == 0 )
            activeProject = "UNSET";
        std::string outputDir=mf->GetStartOutputDirectory();
        std::string projectName=mf->GetProjectName();
        std::string projectGroupName = outputDir + "/" + projectName + ".dpg";
        fout.open(projectGroupName.c_str());
        fout
            << "<?xml version=\"1.0\" encoding='ISO-8859-1'?>\n"
            << "<visualdsp-project-group generated=\""
            << cmSystemTools::GetCurrentDateTime( "%a %B %d %H:%M:%S %Y" ) << "\" "
            << "version=\"1.0.0.0\" "
            << "active-project=\"" << activeProject << "\">\n";
        opened = true;
    }

    unsigned int i;
    for(i = 0; i < this->LocalGenerators.size(); ++i)
    {
        cmMakefile* mf = this->LocalGenerators[i]->GetMakefile();
        std::string outputDir=mf->GetStartOutputDirectory();

        cmTargets targets = mf->GetTargets();
        for (cmTargets::iterator l = targets.begin();
             l != targets.end(); l++)
        {
            std::string projectNameFile = outputDir + "/" + l->second.GetName() + ".dpj";
            fout
                << "    <project name=\"" << l->second.GetName() << "\" file=\"" << projectNameFile << "\">\n"
                << "        <dependencies>\n";
            const std::set<cmStdString>& deps = l->second.GetUtilities();
            for(std::set<cmStdString>::const_iterator dep = deps.begin();
                dep != deps.end(); ++dep)
            {
                fout
                    << "            <dependent-project>" << *dep << "</dependent-project>\n";
            }
            fout
                << "        </dependencies>\n";
        }
    }

    if( opened )
    {
        fout
            << "    </project>\n"
            << "</visualdsp-project-group>";
    }
}

void 
cmGlobalVisualDSP4Generator::EnableLanguage(
    std::vector<std::string>const& languages,
    cmMakefile *mf)
{
}
-------------- next part --------------
/*=========================================================================

  Program:   CMake - Cross-Platform Makefile Generator
  Module:    $RCSfile: cmLocalVisualDSP4Generator.cxx,v $
  Language:  C++
  Date:      $Date: 2007/05/09 18:41:38 $
  Version:   $Revision: 1.122 $

  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 "cmGlobalGenerator.h"
#include "cmLocalVisualDSP4Generator.h"
#include "cmGeneratedFileStream.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
#include "cmSourceFile.h"
#include "cmCacheManager.h"
#include "cmake.h"

#include <cmsys/RegularExpression.hxx>

cmLocalVisualDSP4Generator::cmLocalVisualDSP4Generator()
{
}

cmLocalVisualDSP4Generator::~cmLocalVisualDSP4Generator()
{
}

void cmLocalVisualDSP4Generator::Generate()
{
    std::string outputDir=this->Makefile->GetStartOutputDirectory();
    std::string projectDir=this->Makefile->GetHomeDirectory();
    std::string projectName=this->Makefile->GetProjectName();

    const char* cpuRev = this->Makefile->GetDefinition( "CMAKE_SYSTEM_VERSION" );
    if( cpuRev == 0 )
        cpuRev = "UNSET";
    const char* cpuName = this->Makefile->GetDefinition( "CMAKE_SYSTEM_NAME" );
    if( cpuName == 0 )
        cpuName = "UNSET";
    const char* buildType = this->Makefile->GetDefinition( "CMAKE_BUILD_TYPE" );
    if( buildType == 0 )
        buildType = "UNSET";
    const char* binaryDir = this->Makefile->GetHomeOutputDirectory();
    if( binaryDir == 0 )
        binaryDir = "UNSET";

    //std::vector<std::string> definitions = GetDefinitions
    std::string compilerFlags( this->Makefile->GetDefineFlags() );

    cmTargets& targets = this->Makefile->GetTargets();
    for (cmTargets::iterator l = targets.begin();
         l != targets.end(); l++)
    {
        std::string targetName = l->second.GetName();
        std::string projectNameFile = outputDir + "/" + targetName + ".dpj";
        cmGeneratedFileStream fout2(projectNameFile.c_str());

        std::string extension( "unset" );
        std::string type( "unset" );
        switch( l->second.GetType() )
        {
            case cmTarget::EXECUTABLE:
                extension = ".ldr";
                type = "Loader file";
                break;
            case cmTarget::STATIC_LIBRARY:
                extension = ".dlb";
                type = "Library file";
                break;
            case cmTarget::SHARED_LIBRARY:
            case cmTarget::MODULE_LIBRARY:
            case cmTarget::UTILITY:
            case cmTarget::GLOBAL_TARGET:
            case cmTarget::INSTALL_FILES:
            case cmTarget::INSTALL_PROGRAMS:
            case cmTarget::INSTALL_DIRECTORY:
                break;
        }

        fout2
            << "<?xml version=\"1.0\" encoding='ISO-8859-1'?>\n"
            << "<visualdsp-project schema=\"16\" name=\""
            << targetName << "\" "
            << "file=\"" << projectNameFile << "\" version=\"1\">\n"
            << "    <target>\n"
            << "        <processor revision=\"" << cpuRev << "\">" << cpuName << "</processor>\n"
            << "        <extension>" << extension << "</extension>\n"
            << "        <type>" << type << "</type>\n"
            << "    </target>\n";

        fout2
            << "    <configurations active=\"" << buildType << "\">\n"
            << "        <configuration name=\"" << buildType << "\">\n"
            << "            <output-dir>.</output-dir>\n"
            << "            <changed-property-page-flags>0</changed-property-page-flags>\n"
            << "            <tools>\n"
            << "                <tool type=\"Compiler\">\n"
			<< "                    <option><![CDATA[" << compilerFlags << "]]></option>\n"
			<< "                </tool>\n"
            << "            </tools>\n"
            << "        </configuration>\n"
            << "    </configurations>\n";

        fout2
            << "    <files>\n";
        const std::vector<cmSourceFile*> sourceFiles = this->Makefile->GetSourceFiles();
        for (std::vector<cmSourceFile*>::const_iterator it=sourceFiles.begin(); 
             it!=sourceFiles.end(); it++)
        {
            fout2
                << "        <file name=\"" << (*it)->GetFullPath() << "\">\n"
                << "        </file>\n";
        }
        fout2
            << "    </files>\n"
            << "</visualdsp-project>";
    }
}


More information about the CMake mailing list