INCLUDE_EXTERNAL_MSPROJECT command

This commit is contained in:
Phil Pritchett 2001-10-31 07:03:32 -05:00
parent 4a8b9ecf98
commit 4ba36ca453
6 changed files with 147 additions and 2 deletions

View File

@ -31,6 +31,7 @@
#include "cmIfCommand.cxx"
#include "cmIncludeCommand.cxx"
#include "cmIncludeDirectoryCommand.cxx"
#include "cmIncludeExternalMSProjectCommand.cxx"
#include "cmIncludeRegularExpressionCommand.cxx"
#include "cmInstallFilesCommand.cxx"
#include "cmInstallProgramsCommand.cxx"
@ -89,6 +90,7 @@ void GetPredefinedCommands(std::list<cmCommand*>& commands)
commands.push_back(new cmIfCommand);
commands.push_back(new cmIncludeCommand);
commands.push_back(new cmIncludeDirectoryCommand);
commands.push_back(new cmIncludeExternalMSProjectCommand);
commands.push_back(new cmIncludeRegularExpressionCommand);
commands.push_back(new cmInstallFilesCommand);
commands.push_back(new cmInstallProgramsCommand);

View File

@ -124,8 +124,11 @@ void cmDSPWriter::OutputDSPFile()
cmSystemTools::Error("Bad target type", l->first.c_str());
break;
}
// INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace
// so don't build a projectfile for it
if ((l->second.GetType() != cmTarget::INSTALL_FILES)
&& (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
&& (l->second.GetType() != cmTarget::INSTALL_PROGRAMS)
&& (l->first != "INCLUDE_EXTERNAL_MSPROJECT"))
{
this->CreateSingleDSP(l->first.c_str(),l->second);
}

View File

@ -172,7 +172,18 @@ void cmDSWWriter::WriteDSWFile(std::ostream& fout)
}
}
// Write the project into the DSW file
if ((l->second.GetType() != cmTarget::INSTALL_FILES)
if (l->first == "INCLUDE_EXTERNAL_MSPROJECT")
{
cmCustomCommand cc = l->second.GetCustomCommands()[0];
// dodgy use of the cmCustomCommand's members to store the
// arguments from the INCLUDE_EXTERNAL_MSPROJECT command
std::vector<std::string> stuff = cc.GetDepends();
std::vector<std::string> depends = cc.GetOutputs();
this->WriteExternalProject(fout, stuff[0].c_str(), stuff[1].c_str(), depends);
++si;
}
else if ((l->second.GetType() != cmTarget::INSTALL_FILES)
&& (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
{
this->WriteProject(fout, si->c_str(), dir.c_str(),
@ -186,6 +197,7 @@ void cmDSWWriter::WriteDSWFile(std::ostream& fout)
delete mf;
}
}
// Write the footer for the DSW file
this->WriteDSWFooter(fout);
}
@ -248,6 +260,39 @@ void cmDSWWriter::WriteProject(std::ostream& fout,
fout << "}}}\n\n";
}
// Write a dsp file into the DSW file,
// Note, that dependencies from executables to
// the libraries it uses are also done here
void cmDSWWriter::WriteExternalProject(std::ostream& fout,
const char* name,
const char* location,
const std::vector<std::string>& dependencies)
{
fout << "#########################################################"
"######################\n\n";
fout << "Project: \"" << name << "\"="
<< location << " - Package Owner=<4>\n\n";
fout << "Package=<5>\n{{{\n}}}\n\n";
fout << "Package=<4>\n";
fout << "{{{\n";
std::vector<std::string>::const_iterator i, end;
// write dependencies.
i = dependencies.begin();
end = dependencies.end();
for(;i!= end; ++i)
{
fout << "Begin Project Dependency\n";
fout << "Project_Dep_Name " << *i << "\n";
fout << "End Project Dependency\n";
}
fout << "}}}\n\n";
}
// Standard end of dsw file
void cmDSWWriter::WriteDSWFooter(std::ostream& fout)
{

View File

@ -71,6 +71,9 @@ private:
void WriteProject(std::ostream& fout,
const char* name, const char* path,
cmDSPWriter* project, const cmTarget &t);
void WriteExternalProject(std::ostream& fout,
const char* name, const char* path,
const std::vector<std::string>& dependencies);
void WriteDSWFooter(std::ostream& fout);
cmMakefile* m_Makefile;
};

View File

@ -0,0 +1,34 @@
#include "cmIncludeExternalMSProjectCommand.h"
// cmIncludeExternalMSProjectCommand
bool cmIncludeExternalMSProjectCommand::InitialPass(std::vector<std::string> const& args)
{
if(args.size() < 2)
{
this->SetError("INCLUDE_EXTERNAL_MSPROJECT called with incorrect number of arguments");
return false;
}
if(m_Makefile->GetDefinition("WIN32")) {
std::string location = args[1];
m_Makefile->ExpandVariablesInString(location);
std::vector<std::string> name_and_location;
name_and_location.push_back(args[0]);
name_and_location.push_back(location);
std::vector<std::string> depends;
if (args.size() > 2) {
for (int i=2; i<args.size(); ++i) {
depends.push_back(args[i]);
}
}
m_Makefile->AddUtilityCommand("INCLUDE_EXTERNAL_MSPROJECT", "echo", "\"Include external project\"",
false, name_and_location, depends);
}
return true;
}

View File

@ -0,0 +1,58 @@
#ifndef cmIncludeExternalMSProjectCommand_h
#define cmIncludeExternalMSProjectCommand_h
#include "cmStandardIncludes.h"
#include "cmCommand.h"
/** \class cmIncludeExternalMSProjectCommand
* \brief Specify an external MS project file for inclusion in the workspace.
*
* cmIncludeExternalMSProjectCommand is used to specify an externally generated
* Microsoft project file for inclusion in the default workspace generated by
* CMake.
*/
class cmIncludeExternalMSProjectCommand : public cmCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
{
return new cmIncludeExternalMSProjectCommand;
}
/**
* This is called when the command is first encountered in
* the CMakeLists.txt 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 "INCLUDE_EXTERNAL_MSPROJECT";}
/**
* Succinct documentation.
*/
virtual const char* GetTerseDocumentation()
{
return "Include an external Microsoft project file in a workspace.";
}
/**
* More documentation.
*/
virtual const char* GetFullDocumentation()
{
return
"INCLUDE_EXTERNAL_MSPROJECT(projectname location dep1 dep2 ...) Includes an external Microsoft project in the workspace file. Does nothing on UNIX currently\n";
}
cmTypeMacro(cmIncludeExternalMSProjectCommand, cmCommand);
};
#endif