New command: INCLUDE(somefile.txt)
This commit is contained in:
parent
2da0c57d46
commit
d6fae5faf0
|
@ -52,6 +52,7 @@
|
|||
#include "cmEndIfCommand.cxx"
|
||||
#include "cmAddDefinitionsCommand.cxx"
|
||||
#include "cmOptionCommand.cxx"
|
||||
#include "cmIncludeCommand.cxx"
|
||||
|
||||
void GetPredefinedCommands(std::list<cmCommand*>& commands)
|
||||
{
|
||||
|
@ -101,6 +102,7 @@ void GetPredefinedCommands(std::list<cmCommand*>& commands)
|
|||
commands.push_back(new cmEndIfCommand);
|
||||
commands.push_back(new cmAddDefinitionsCommand);
|
||||
commands.push_back(new cmOptionCommand);
|
||||
commands.push_back(new cmIncludeCommand);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -121,38 +121,6 @@ void cmDSPMakefile::CreateSingleDSP(const char *lname, cmTarget &target)
|
|||
this->WriteDSPFile(fout,lname,target);
|
||||
}
|
||||
|
||||
void cmDSPMakefile::WriteDSPBuildRule(std::ostream& fout)
|
||||
{
|
||||
std::string dspname = *(m_CreatedProjectNames.end()-1);
|
||||
dspname += ".dsp";
|
||||
std::string makefileIn = "\"";
|
||||
makefileIn += m_Makefile->GetStartDirectory();
|
||||
makefileIn += "/";
|
||||
makefileIn += "CMakeLists.txt\"";
|
||||
std::string dsprule = "\"";
|
||||
dsprule += m_Makefile->GetHomeDirectory();
|
||||
dsprule += "/CMake/Source/CMakeSetupCMD\" ";
|
||||
dsprule += makefileIn;
|
||||
dsprule += " -DSP -H\"";
|
||||
dsprule += m_Makefile->GetHomeDirectory();
|
||||
dsprule += "\" -S\"";
|
||||
dsprule += m_Makefile->GetStartDirectory();
|
||||
dsprule += "\" -O\"";
|
||||
dsprule += m_Makefile->GetStartOutputDirectory();
|
||||
dsprule += "\" -B\"";
|
||||
dsprule += m_Makefile->GetHomeOutputDirectory();
|
||||
dsprule += "\"";
|
||||
|
||||
std::set<std::string> depends;
|
||||
std::set<std::string> outputs;
|
||||
outputs.insert(outputs.begin(), dspname);
|
||||
fout << "# Begin Source File\n\n";
|
||||
fout << "SOURCE=" << makefileIn.c_str() << "\n\n";
|
||||
this->WriteCustomRule(fout, dsprule.c_str(), depends, outputs);
|
||||
fout << "# End Source File\n";
|
||||
}
|
||||
|
||||
|
||||
void cmDSPMakefile::AddDSPBuildRule(cmSourceGroup& sourceGroup)
|
||||
{
|
||||
std::string dspname = *(m_CreatedProjectNames.end()-1);
|
||||
|
@ -174,12 +142,12 @@ void cmDSPMakefile::AddDSPBuildRule(cmSourceGroup& sourceGroup)
|
|||
dsprule += "\" -B\"";
|
||||
dsprule += m_Makefile->GetHomeOutputDirectory();
|
||||
dsprule += "\"";
|
||||
|
||||
std::vector<std::string> depends;
|
||||
|
||||
std::vector<std::string> outputs;
|
||||
outputs.push_back(dspname);
|
||||
cmCustomCommand cc(makefileIn.c_str(), dsprule.c_str(),
|
||||
depends, outputs);
|
||||
m_Makefile->GetListFiles(),
|
||||
outputs);
|
||||
sourceGroup.AddCustomCommand(cc);
|
||||
}
|
||||
|
||||
|
@ -306,6 +274,17 @@ void cmDSPMakefile::WriteCustomRule(std::ostream& fout,
|
|||
{
|
||||
fout << "!ELSEIF \"$(CFG)\" == " << i->c_str() << std::endl;
|
||||
}
|
||||
|
||||
// Write out the dependencies (this seems to be the only way to
|
||||
// get VC6 to actually take these dependencies into account.
|
||||
fout << "USERDEP__HACK= ";
|
||||
for(std::set<std::string>::const_iterator d = depends.begin();
|
||||
d != depends.end(); ++d)
|
||||
{
|
||||
fout << " \"" << d->c_str() << "\"";
|
||||
}
|
||||
fout << "\n";
|
||||
|
||||
fout << "# Begin Custom Build\n\n";
|
||||
|
||||
// Write a rule for every output generated by this command.
|
||||
|
|
|
@ -99,9 +99,11 @@ private:
|
|||
const char* group,
|
||||
const char* filter);
|
||||
void WriteDSPEndGroup(std::ostream& fout);
|
||||
|
||||
void WriteDSPHeader(std::ostream& fout, const char *libName,
|
||||
const cmTarget &tgt);
|
||||
void WriteDSPBuildRule(std::ostream& fout);
|
||||
|
||||
void WriteDSPFooter(std::ostream& fout);
|
||||
void AddDSPBuildRule(cmSourceGroup&);
|
||||
void WriteCustomRule(std::ostream& fout,
|
||||
|
|
|
@ -121,38 +121,6 @@ void cmDSPMakefile::CreateSingleDSP(const char *lname, cmTarget &target)
|
|||
this->WriteDSPFile(fout,lname,target);
|
||||
}
|
||||
|
||||
void cmDSPMakefile::WriteDSPBuildRule(std::ostream& fout)
|
||||
{
|
||||
std::string dspname = *(m_CreatedProjectNames.end()-1);
|
||||
dspname += ".dsp";
|
||||
std::string makefileIn = "\"";
|
||||
makefileIn += m_Makefile->GetStartDirectory();
|
||||
makefileIn += "/";
|
||||
makefileIn += "CMakeLists.txt\"";
|
||||
std::string dsprule = "\"";
|
||||
dsprule += m_Makefile->GetHomeDirectory();
|
||||
dsprule += "/CMake/Source/CMakeSetupCMD\" ";
|
||||
dsprule += makefileIn;
|
||||
dsprule += " -DSP -H\"";
|
||||
dsprule += m_Makefile->GetHomeDirectory();
|
||||
dsprule += "\" -S\"";
|
||||
dsprule += m_Makefile->GetStartDirectory();
|
||||
dsprule += "\" -O\"";
|
||||
dsprule += m_Makefile->GetStartOutputDirectory();
|
||||
dsprule += "\" -B\"";
|
||||
dsprule += m_Makefile->GetHomeOutputDirectory();
|
||||
dsprule += "\"";
|
||||
|
||||
std::set<std::string> depends;
|
||||
std::set<std::string> outputs;
|
||||
outputs.insert(outputs.begin(), dspname);
|
||||
fout << "# Begin Source File\n\n";
|
||||
fout << "SOURCE=" << makefileIn.c_str() << "\n\n";
|
||||
this->WriteCustomRule(fout, dsprule.c_str(), depends, outputs);
|
||||
fout << "# End Source File\n";
|
||||
}
|
||||
|
||||
|
||||
void cmDSPMakefile::AddDSPBuildRule(cmSourceGroup& sourceGroup)
|
||||
{
|
||||
std::string dspname = *(m_CreatedProjectNames.end()-1);
|
||||
|
@ -174,12 +142,12 @@ void cmDSPMakefile::AddDSPBuildRule(cmSourceGroup& sourceGroup)
|
|||
dsprule += "\" -B\"";
|
||||
dsprule += m_Makefile->GetHomeOutputDirectory();
|
||||
dsprule += "\"";
|
||||
|
||||
std::vector<std::string> depends;
|
||||
|
||||
std::vector<std::string> outputs;
|
||||
outputs.push_back(dspname);
|
||||
cmCustomCommand cc(makefileIn.c_str(), dsprule.c_str(),
|
||||
depends, outputs);
|
||||
m_Makefile->GetListFiles(),
|
||||
outputs);
|
||||
sourceGroup.AddCustomCommand(cc);
|
||||
}
|
||||
|
||||
|
@ -306,6 +274,17 @@ void cmDSPMakefile::WriteCustomRule(std::ostream& fout,
|
|||
{
|
||||
fout << "!ELSEIF \"$(CFG)\" == " << i->c_str() << std::endl;
|
||||
}
|
||||
|
||||
// Write out the dependencies (this seems to be the only way to
|
||||
// get VC6 to actually take these dependencies into account.
|
||||
fout << "USERDEP__HACK= ";
|
||||
for(std::set<std::string>::const_iterator d = depends.begin();
|
||||
d != depends.end(); ++d)
|
||||
{
|
||||
fout << " \"" << d->c_str() << "\"";
|
||||
}
|
||||
fout << "\n";
|
||||
|
||||
fout << "# Begin Custom Build\n\n";
|
||||
|
||||
// Write a rule for every output generated by this command.
|
||||
|
|
|
@ -99,9 +99,11 @@ private:
|
|||
const char* group,
|
||||
const char* filter);
|
||||
void WriteDSPEndGroup(std::ostream& fout);
|
||||
|
||||
void WriteDSPHeader(std::ostream& fout, const char *libName,
|
||||
const cmTarget &tgt);
|
||||
void WriteDSPBuildRule(std::ostream& fout);
|
||||
|
||||
void WriteDSPFooter(std::ostream& fout);
|
||||
void AddDSPBuildRule(cmSourceGroup&);
|
||||
void WriteCustomRule(std::ostream& fout,
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/*=========================================================================
|
||||
|
||||
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 "cmIncludeCommand.h"
|
||||
|
||||
#include <iostream.h>
|
||||
|
||||
// cmIncludeCommand
|
||||
bool cmIncludeCommand::Invoke(std::vector<std::string>& args)
|
||||
{
|
||||
if (args.size()< 1)
|
||||
{
|
||||
this->SetError("called with wrong number of arguments.");
|
||||
}
|
||||
|
||||
for( unsigned int i=0; i< args.size(); i++)
|
||||
{
|
||||
m_Makefile->ExpandVariablesInString( args[i]);
|
||||
m_Makefile->ReadListFile( m_Makefile->GetCurrentListFile(),
|
||||
args[i].c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
/*=========================================================================
|
||||
|
||||
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 cmIncludeCommand_h
|
||||
#define cmIncludeCommand_h
|
||||
|
||||
#include "cmStandardIncludes.h"
|
||||
#include "cmCommand.h"
|
||||
|
||||
/** \class cmIncludeCommand
|
||||
* \brief
|
||||
*
|
||||
* cmIncludeCommand defines a list of distant
|
||||
* files that can be "included" in the current list file.
|
||||
* In almost every sense, this is identical to a C/C++
|
||||
* #include command. Arguments are first expended as usual.
|
||||
*/
|
||||
class cmIncludeCommand : public cmCommand
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This is a virtual constructor for the command.
|
||||
*/
|
||||
virtual cmCommand* Clone()
|
||||
{
|
||||
return new cmIncludeCommand;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 "INCLUDE";}
|
||||
|
||||
/**
|
||||
* Succinct documentation.
|
||||
*/
|
||||
virtual const char* GetTerseDocumentation()
|
||||
{
|
||||
return "Basically identical to a C #include \"somthing\" command.";
|
||||
}
|
||||
|
||||
/**
|
||||
* More documentation.
|
||||
*/
|
||||
virtual const char* GetFullDocumentation()
|
||||
{
|
||||
return
|
||||
"INCLUDE(file1 file2)\n";
|
||||
}
|
||||
|
||||
cmTypeMacro(cmIncludeCommand, cmCommand);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -190,48 +190,75 @@ void cmMakefile::Print() const
|
|||
// Parse the given CMakeLists.txt file into a list of classes.
|
||||
// Reads in current CMakeLists file and all parent CMakeLists files
|
||||
// executing all inherited commands in the parents
|
||||
bool cmMakefile::ReadListFile(const char* filename)
|
||||
//
|
||||
// if external is non-zero, this means that we have branched to grab some
|
||||
// commands from a remote list-file (that is, the equivalent of a
|
||||
// #include has been called). We DO NOT look at the parents of this
|
||||
// list-file, and for all other purposes, the name of this list-file
|
||||
// is "filename" and not "external".
|
||||
bool cmMakefile::ReadListFile(const char* filename, const char* external)
|
||||
{
|
||||
// is there a parent CMakeLists file that does not go beyond the
|
||||
// Home directory? if so recurse and read in that List file
|
||||
std::string parentList = this->GetParentListFileName(filename);
|
||||
if (parentList != "")
|
||||
|
||||
// keep track of the current file being read
|
||||
m_cmCurrentListFile= filename;
|
||||
|
||||
// if this is not a remote makefile
|
||||
// (if it were, this would be called from the "filename" call,
|
||||
// rather than the "external" call)
|
||||
if (!external)
|
||||
{
|
||||
// save the current directory
|
||||
std::string srcdir = m_cmCurrentDirectory;
|
||||
std::string bindir = m_CurrentOutputDirectory;
|
||||
// compute the new current directories
|
||||
std::string::size_type pos = m_cmCurrentDirectory.rfind('/');
|
||||
if(pos != std::string::npos)
|
||||
{
|
||||
m_cmCurrentDirectory = m_cmCurrentDirectory.substr(0, pos);
|
||||
}
|
||||
pos = m_CurrentOutputDirectory.rfind('/');
|
||||
if(pos != std::string::npos)
|
||||
{
|
||||
m_CurrentOutputDirectory = m_CurrentOutputDirectory.substr(0, pos);
|
||||
}
|
||||
this->ReadListFile(parentList.c_str());
|
||||
// restore the current directory
|
||||
m_cmCurrentDirectory = srcdir;
|
||||
m_CurrentOutputDirectory = bindir;
|
||||
// is there a parent CMakeLists file that does not go beyond the
|
||||
// Home directory? if so recurse and read in that List file
|
||||
std::string parentList = this->GetParentListFileName(filename);
|
||||
if (parentList != "")
|
||||
{
|
||||
// save the current directory
|
||||
std::string srcdir = m_cmCurrentDirectory;
|
||||
std::string bindir = m_CurrentOutputDirectory;
|
||||
// compute the new current directories
|
||||
std::string::size_type pos = m_cmCurrentDirectory.rfind('/');
|
||||
if(pos != std::string::npos)
|
||||
{
|
||||
m_cmCurrentDirectory = m_cmCurrentDirectory.substr(0, pos);
|
||||
}
|
||||
pos = m_CurrentOutputDirectory.rfind('/');
|
||||
if(pos != std::string::npos)
|
||||
{
|
||||
m_CurrentOutputDirectory = m_CurrentOutputDirectory.substr(0, pos);
|
||||
}
|
||||
this->ReadListFile(parentList.c_str());
|
||||
// restore the current directory
|
||||
m_cmCurrentDirectory = srcdir;
|
||||
m_CurrentOutputDirectory = bindir;
|
||||
}
|
||||
}
|
||||
|
||||
// are we at the start CMakeLists file or are we processing a parent
|
||||
// lists file
|
||||
//
|
||||
// this might, or might not be true, irrespective if we are
|
||||
// off looking at an external makefile.
|
||||
bool inheriting = (m_cmCurrentDirectory != m_cmStartDirectory);
|
||||
|
||||
// Now read the input file
|
||||
std::ifstream fin(filename);
|
||||
const char *filenametoread= filename;
|
||||
|
||||
if( external)
|
||||
filenametoread= external;
|
||||
|
||||
std::ifstream fin(filenametoread);
|
||||
if(!fin)
|
||||
{
|
||||
cmSystemTools::Error("error can not open file ", filename);
|
||||
cmSystemTools::Error("error can not open file ", filenametoread);
|
||||
return false;
|
||||
}
|
||||
std::string name;
|
||||
std::vector<std::string> arguments;
|
||||
while ( fin )
|
||||
{
|
||||
// add this list file to the list of dependencies
|
||||
m_ListFiles.push_back( filenametoread);
|
||||
|
||||
if(cmSystemTools::ParseFunction(fin, name, arguments) &&
|
||||
!this->IsFunctionBlocked(name.c_str(),arguments))
|
||||
{
|
||||
|
|
|
@ -73,7 +73,7 @@ public:
|
|||
/**
|
||||
* Read and parse a CMakeLists.txt file.
|
||||
*/
|
||||
bool ReadListFile(const char* listfile);
|
||||
bool ReadListFile(const char* listfile, const char* external= 0);
|
||||
|
||||
/**
|
||||
* Add a wrapper generator.
|
||||
|
@ -241,7 +241,16 @@ public:
|
|||
{
|
||||
return m_cmHomeDirectory.c_str();
|
||||
}
|
||||
<<<<<<< cmMakefile.h
|
||||
void SetHomeOutputDirectory(const char* lib)
|
||||
{
|
||||
m_HomeOutputDirectory = lib;
|
||||
cmSystemTools::ConvertToUnixSlashes(m_HomeOutputDirectory);
|
||||
this->AddDefinition("CMAKE_BINARY_DIR", this->GetHomeOutputDirectory());
|
||||
}
|
||||
=======
|
||||
void SetHomeOutputDirectory(const char* lib);
|
||||
>>>>>>> 1.31
|
||||
const char* GetHomeOutputDirectory() const
|
||||
{
|
||||
return m_HomeOutputDirectory.c_str();
|
||||
|
@ -302,6 +311,15 @@ public:
|
|||
{
|
||||
return m_CurrentOutputDirectory.c_str();
|
||||
}
|
||||
|
||||
/* Get the current CMakeLists.txt file that is being processed. This
|
||||
* is just used in order to be able to 'branch' from one file to a second
|
||||
* transparently */
|
||||
const char* GetCurrentListFile() const
|
||||
{
|
||||
return m_cmCurrentListFile.c_str();
|
||||
}
|
||||
|
||||
//@}
|
||||
|
||||
/**
|
||||
|
@ -400,6 +418,12 @@ public:
|
|||
*/
|
||||
const std::vector<cmSourceGroup>& GetSourceGroups() const
|
||||
{ return m_SourceGroups; }
|
||||
|
||||
/**
|
||||
* Get the vector of list files on which this makefile depends
|
||||
*/
|
||||
const std::vector<std::string>& GetListFiles() const
|
||||
{ return m_ListFiles; }
|
||||
|
||||
/**
|
||||
* Dump documentation to a file. If 0 is returned, the
|
||||
|
@ -462,6 +486,7 @@ protected:
|
|||
std::string m_StartOutputDirectory;
|
||||
std::string m_cmHomeDirectory;
|
||||
std::string m_HomeOutputDirectory;
|
||||
std::string m_cmCurrentListFile;
|
||||
|
||||
std::string m_ProjectName; // project name
|
||||
|
||||
|
@ -475,7 +500,10 @@ protected:
|
|||
std::vector<std::string> m_LinkDirectories;
|
||||
std::vector<std::string> m_Utilities;
|
||||
std::vector<std::string> m_UtilityDirectories;
|
||||
std::vector<std::string> m_ListFiles; // list of command files loaded
|
||||
|
||||
cmTarget::LinkLibraries m_LinkLibraries;
|
||||
|
||||
std::string m_IncludeFileRegularExpression;
|
||||
std::string m_DefineFlags;
|
||||
std::vector<cmSourceGroup> m_SourceGroups;
|
||||
|
|
Loading…
Reference in New Issue