summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2001-05-04 15:30:46 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2001-05-04 15:30:46 (GMT)
commitde10cfc72e51094d3a8f3a8d10f09a902330a2f3 (patch)
tree19175a07cd503bb427d1f394dc9a7d555b28246f /Source
parent33e1a4a09aaedfcb869e2f4217815e09f0d3187f (diff)
downloadCMake-de10cfc72e51094d3a8f3a8d10f09a902330a2f3.zip
CMake-de10cfc72e51094d3a8f3a8d10f09a902330a2f3.tar.gz
CMake-de10cfc72e51094d3a8f3a8d10f09a902330a2f3.tar.bz2
ENH: move testing stuff to cmake from configure, good bye dashboard... :)
Diffstat (limited to 'Source')
-rw-r--r--Source/MFCDialog/CMakeSetup.rc2
-rw-r--r--Source/cmAddTargetCommand.cxx56
-rw-r--r--Source/cmAddTargetCommand.h97
-rw-r--r--Source/cmCacheManager.cxx5
-rw-r--r--Source/cmCommands.cxx12
-rw-r--r--Source/cmDSWMakefile.cxx16
-rw-r--r--Source/cmDSWWriter.cxx16
-rw-r--r--Source/cmFindProgramCommand.cxx7
-rw-r--r--Source/cmMakefile.cxx83
-rw-r--r--Source/cmOptionCommand.cxx9
-rw-r--r--Source/cmOptionCommand.h2
-rw-r--r--Source/cmSourceGroup.cxx19
-rw-r--r--Source/cmSourceGroup.h2
-rw-r--r--Source/cmSystemTools.cxx75
-rw-r--r--Source/cmSystemTools.h11
-rw-r--r--Source/cmUnixMakefileGenerator.cxx2
16 files changed, 153 insertions, 261 deletions
diff --git a/Source/MFCDialog/CMakeSetup.rc b/Source/MFCDialog/CMakeSetup.rc
index 28318e7..4f8e45c 100644
--- a/Source/MFCDialog/CMakeSetup.rc
+++ b/Source/MFCDialog/CMakeSetup.rc
@@ -103,7 +103,7 @@ BEGIN
GROUPBOX "Cache Values",IDC_STATIC,9,43,356,141
LISTBOX IDC_LIST2,15,55,344,122,LBS_OWNERDRAWVARIABLE |
LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL |
- WS_TABSTOP
+ WS_HSCROLL | WS_TABSTOP
CTEXT "Right click on cache entries for additional options",
IDC_STATIC,19,190,333,11
END
diff --git a/Source/cmAddTargetCommand.cxx b/Source/cmAddTargetCommand.cxx
deleted file mode 100644
index 71162c3..0000000
--- a/Source/cmAddTargetCommand.cxx
+++ /dev/null
@@ -1,56 +0,0 @@
-/*=========================================================================
-
- Program: Insight Segmentation & Registration Toolkit
- Module: $RCSfile$
- Language: C++
- Date: $Date$
- Version: $Revision$
-
-Copyright (c) 2001 Insight Consortium
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- * The name of the Insight Consortium, nor the names of any consortium members,
- nor of any contributors, may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- * Modified source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-=========================================================================*/
-#include "cmAddTargetCommand.h"
-
-// cmAddTargetCommand
-bool cmAddTargetCommand::Invoke(std::vector<std::string>& args)
-{
- if(args.size() < 2 )
- {
- this->SetError("called with incorrect number of arguments");
- return false;
- }
- std::vector<std::string> dep;
- m_Makefile->AddUtilityCommand(args[0].c_str(),
- args[1].c_str());
- return true;
-}
-
diff --git a/Source/cmAddTargetCommand.h b/Source/cmAddTargetCommand.h
deleted file mode 100644
index 5ba8621..0000000
--- a/Source/cmAddTargetCommand.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*=========================================================================
-
- Program: Insight Segmentation & Registration Toolkit
- Module: $RCSfile$
- Language: C++
- Date: $Date$
- Version: $Revision$
-
-Copyright (c) 2001 Insight Consortium
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- * The name of the Insight Consortium, nor the names of any consortium members,
- nor of any contributors, may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- * Modified source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-=========================================================================*/
-#ifndef cmAddTargetCommand_h
-#define cmAddTargetCommand_h
-
-#include "cmStandardIncludes.h"
-#include "cmCommand.h"
-
-/** \class cmAddTargetCommand
- * \brief Command that adds a target to the build system.
- *
- * cmAddTargetCommand adds an extra target to the build system.
- * This is useful when you would like to add special
- * targets like "install,", "clean," and so on.
- */
-class cmAddTargetCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- virtual cmCommand* Clone()
- {
- return new cmAddTargetCommand;
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- virtual bool Invoke(std::vector<std::string>& args);
-
- /**
- * The name of the command as specified in CMakeList.txt.
- */
- virtual const char* GetName()
- {return "ADD_TARGET";}
-
- /**
- * Succinct documentation.
- */
- virtual const char* GetTerseDocumentation()
- {
- return "Add an extra target to the build system.";
- }
-
- /**
- * More documentation.
- */
- virtual const char* GetFullDocumentation()
- {
- return
- "ADD_TARGET(Name \"command to run\")";
- }
-
- cmTypeMacro(cmAddTargetCommand, cmCommand);
-};
-
-#endif
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index e8ec10e..cdffb56 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -295,6 +295,11 @@ void cmCacheManager::AddCacheEntry(const char* key,
CacheEntry e;
e.m_Value = value;
e.m_Type = type;
+ // make sure we only use unix style paths
+ if(type == FILEPATH || type == PATH)
+ {
+ cmSystemTools::ConvertToUnixSlashes(e.m_Value);
+ }
e.m_HelpString = helpString;
m_Cache[key] = e;
}
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index c56c90d..d65a679 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -6,7 +6,7 @@
#include "cmAbstractFilesCommand.cxx"
#include "cmAddExecutableCommand.cxx"
#include "cmAddLibraryCommand.cxx"
-#include "cmAddTargetCommand.cxx"
+#include "cmAddCustomTargetCommand.cxx"
#include "cmAuxSourceDirectoryCommand.cxx"
#include "cmFindLibraryCommand.cxx"
#include "cmFindProgramCommand.cxx"
@@ -48,13 +48,21 @@
#include "cmAddDefinitionsCommand.cxx"
#include "cmOptionCommand.cxx"
#include "cmIncludeCommand.cxx"
+#include "cmSiteNameCommand.cxx"
+#include "cmBuildNameCommand.cxx"
+#include "cmExecProgram.cxx"
+#include "cmBuildCommand.cxx"
void GetPredefinedCommands(std::list<cmCommand*>& commands)
{
+ commands.push_back(new cmBuildCommand);
+ commands.push_back(new cmExecProgram);
+ commands.push_back(new cmBuildNameCommand);
+ commands.push_back(new cmSiteNameCommand);
commands.push_back(new cmAbstractFilesCommand);
commands.push_back(new cmAddExecutableCommand);
commands.push_back(new cmAddLibraryCommand);
- commands.push_back(new cmAddTargetCommand);
+ commands.push_back(new cmAddCustomTargetCommand);
commands.push_back(new cmAuxSourceDirectoryCommand);
commands.push_back(new cmFindLibraryCommand);
commands.push_back(new cmFindProgramCommand);
diff --git a/Source/cmDSWMakefile.cxx b/Source/cmDSWMakefile.cxx
index cd7c292..723784a 100644
--- a/Source/cmDSWMakefile.cxx
+++ b/Source/cmDSWMakefile.cxx
@@ -122,10 +122,8 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
// than one dsp could have been created per input CMakeLists.txt file
// for each target
std::vector<std::string> dspnames = pg->GetDSPMakefile()->GetCreatedProjectNames();
- const cmTargets &tgts = pg->GetDSPMakefile()->GetMakefile()->GetTargets();
- cmTargets::const_iterator l = tgts.begin();
- std::vector<std::string> originalUtilities;
- bool addedUtilities = false;
+ cmTargets &tgts = pg->GetDSPMakefile()->GetMakefile()->GetTargets();
+ cmTargets::iterator l = tgts.begin();
for(std::vector<std::string>::iterator si = dspnames.begin();
l != tgts.end(); ++l, ++si)
{
@@ -139,8 +137,6 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
// vector on the makefile
if(l->first == "ALL_BUILD")
{
- addedUtilities = true;
- originalUtilities = m_Makefile->GetUtilities();
for(std::vector<cmMakefile*>::iterator a = allListFiles.begin();
a != allListFiles.end(); ++a)
{
@@ -150,7 +146,8 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
{
if(al->second.GetType() != cmTarget::UTILITY)
{
- m_Makefile->GetUtilities().push_back(al->first);
+ l->second.GetLinkLibraries().push_back(
+ cmTarget::LinkLibraries::value_type(al->first, cmTarget::GENERAL));
}
}
}
@@ -159,11 +156,6 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
// Write the project into the DSW file
this->WriteProject(fout, si->c_str(), dir.c_str(),
pg->GetDSPMakefile(),l->second);
- if(addedUtilities)
- {
- m_Makefile->GetUtilities() = originalUtilities;
- }
-
}
// delete the cmMakefile which also deletes the cmMSProjectGenerator
if(mf != m_Makefile)
diff --git a/Source/cmDSWWriter.cxx b/Source/cmDSWWriter.cxx
index cd7c292..723784a 100644
--- a/Source/cmDSWWriter.cxx
+++ b/Source/cmDSWWriter.cxx
@@ -122,10 +122,8 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
// than one dsp could have been created per input CMakeLists.txt file
// for each target
std::vector<std::string> dspnames = pg->GetDSPMakefile()->GetCreatedProjectNames();
- const cmTargets &tgts = pg->GetDSPMakefile()->GetMakefile()->GetTargets();
- cmTargets::const_iterator l = tgts.begin();
- std::vector<std::string> originalUtilities;
- bool addedUtilities = false;
+ cmTargets &tgts = pg->GetDSPMakefile()->GetMakefile()->GetTargets();
+ cmTargets::iterator l = tgts.begin();
for(std::vector<std::string>::iterator si = dspnames.begin();
l != tgts.end(); ++l, ++si)
{
@@ -139,8 +137,6 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
// vector on the makefile
if(l->first == "ALL_BUILD")
{
- addedUtilities = true;
- originalUtilities = m_Makefile->GetUtilities();
for(std::vector<cmMakefile*>::iterator a = allListFiles.begin();
a != allListFiles.end(); ++a)
{
@@ -150,7 +146,8 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
{
if(al->second.GetType() != cmTarget::UTILITY)
{
- m_Makefile->GetUtilities().push_back(al->first);
+ l->second.GetLinkLibraries().push_back(
+ cmTarget::LinkLibraries::value_type(al->first, cmTarget::GENERAL));
}
}
}
@@ -159,11 +156,6 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
// Write the project into the DSW file
this->WriteProject(fout, si->c_str(), dir.c_str(),
pg->GetDSPMakefile(),l->second);
- if(addedUtilities)
- {
- m_Makefile->GetUtilities() = originalUtilities;
- }
-
}
// delete the cmMakefile which also deletes the cmMSProjectGenerator
if(mf != m_Makefile)
diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx
index aef1a74..ce97478 100644
--- a/Source/cmFindProgramCommand.cxx
+++ b/Source/cmFindProgramCommand.cxx
@@ -90,7 +90,10 @@ bool cmFindProgramCommand::Invoke(std::vector<std::string>& args)
m_Makefile->AddDefinition(define, result.c_str());
return true;
}
-
- return false;
+ std::string error = "Faild to find program: \"";
+ error += *i;
+ error += "\" ";
+ this->SetError(error.c_str());
+ return true;
}
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 9be764f..0cfe265 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -155,6 +155,11 @@ void cmMakefile::Print() const
this->PrintStringVector("m_LinkDirectories", m_LinkDirectories);
this->PrintStringVector("m_Utilities", m_Utilities);
this->PrintStringVector("m_UtilityDirectories", m_UtilityDirectories);
+ for( std::vector<cmSourceGroup>::const_iterator i = m_SourceGroups.begin();
+ i != m_SourceGroups.end(); ++i)
+ {
+ i->Print();
+ }
}
// Parse the given CMakeLists.txt file into a list of classes.
@@ -231,63 +236,51 @@ bool cmMakefile::ReadListFile(const char* filename, const char* external)
std::vector<std::string> arguments;
while ( fin )
{
- // add this list file to the list of dependencies
- m_ListFiles.push_back( filenametoread);
+ // 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))
{
- // Special command that needs to be removed when
- // ADD_COMMAND is implemented
- if(name == "VERBATIM")
- {
- if (!inheriting)
- {
- m_MakeVerbatim = arguments;
- }
- }
- else
+ RegisteredCommandsMap::iterator pos = m_Commands.find(name);
+ if(pos != m_Commands.end())
{
- RegisteredCommandsMap::iterator pos = m_Commands.find(name);
- if(pos != m_Commands.end())
+ cmCommand* rm = (*pos).second;
+ cmCommand* usedCommand = rm->Clone();
+ usedCommand->SetMakefile(this);
+ bool keepCommand = false;
+ if(usedCommand->GetEnabled())
{
- cmCommand* rm = (*pos).second;
- cmCommand* usedCommand = rm->Clone();
- usedCommand->SetMakefile(this);
- bool keepCommand = false;
- if(usedCommand->GetEnabled())
+ // if not running in inherit mode or
+ // if the command is inherited then Invoke it.
+ if(!inheriting || usedCommand->IsInherited())
{
- // if not running in inherit mode or
- // if the command is inherited then Invoke it.
- if(!inheriting || usedCommand->IsInherited())
+ if(!usedCommand->Invoke(arguments))
{
- if(!usedCommand->Invoke(arguments))
- {
- cmSystemTools::Error(usedCommand->GetName(),
- ": Error : \n",
- usedCommand->GetError(),
- m_cmCurrentDirectory.c_str());
- }
- else
- {
- // use the command
- keepCommand = true;
- m_UsedCommands.push_back(usedCommand);
- }
+ cmSystemTools::Error(usedCommand->GetName(),
+ ": Error : \n",
+ usedCommand->GetError(),
+ m_cmCurrentDirectory.c_str());
+ }
+ else
+ {
+ // use the command
+ keepCommand = true;
+ m_UsedCommands.push_back(usedCommand);
}
- }
- // if the Cloned command was not used
- // then delete it
- if(!keepCommand)
- {
- delete usedCommand;
}
}
- else
+ // if the Cloned command was not used
+ // then delete it
+ if(!keepCommand)
{
- cmSystemTools::Error("unknown CMake command ", name.c_str());
+ delete usedCommand;
}
}
+ else
+ {
+ cmSystemTools::Error("unknown CMake command ", name.c_str(), filename);
+ }
}
}
@@ -663,11 +656,11 @@ void cmMakefile::RemoveVariablesInString(std::string& source) const
cmRegularExpression var2("(@[A-Za-z_0-9]*@)");
while (var.find(source))
{
- source.erase(var.start(),var.end());
+ source.erase(var.start(),var.end() - var.start());
}
while (var2.find(source))
{
- source.erase(var2.start(),var2.end());
+ source.erase(var2.start(),var2.end() - var2.start());
}
}
diff --git a/Source/cmOptionCommand.cxx b/Source/cmOptionCommand.cxx
index 954762e..4564f02 100644
--- a/Source/cmOptionCommand.cxx
+++ b/Source/cmOptionCommand.cxx
@@ -55,10 +55,15 @@ bool cmOptionCommand::Invoke(std::vector<std::string>& args)
= cmCacheManager::GetInstance()->GetCacheValue(args[0].c_str());
if(!cacheValue)
{
+ const char* initialValue = "Off";
+ if(args.size() == 3)
+ {
+ initialValue = args[2].c_str();
+ }
cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(),
- false,
+ cmSystemTools::IsOn(initialValue),
args[1].c_str());
- m_Makefile->AddDefinition(args[0].c_str(), "Off");
+ m_Makefile->AddDefinition(args[0].c_str(), initialValue);
}
else
{
diff --git a/Source/cmOptionCommand.h b/Source/cmOptionCommand.h
index 1a118f5..ae55bad 100644
--- a/Source/cmOptionCommand.h
+++ b/Source/cmOptionCommand.h
@@ -91,7 +91,7 @@ public:
virtual const char* GetFullDocumentation()
{
return
- "OPTION(USE_MPI \"help string decribing the option\")\n"
+ "OPTION(USE_MPI \"help string decribing the option\" [initial value])\n"
"Provide an option for the user to select";
}
diff --git a/Source/cmSourceGroup.cxx b/Source/cmSourceGroup.cxx
index 8935a07..1ae771c 100644
--- a/Source/cmSourceGroup.cxx
+++ b/Source/cmSourceGroup.cxx
@@ -122,6 +122,24 @@ void cmSourceGroup::AddCustomCommand(const cmCustomCommand &cmd)
commandFiles.m_Outputs.insert(cmd.GetOutputs().begin(), cmd.GetOutputs().end());
}
+void cmSourceGroup::Print() const
+{
+ std::cout << "cmSourceGroup: " << m_Name.c_str() << "\n";
+ for(BuildRules::const_iterator i = m_BuildRules.begin();
+ i != m_BuildRules.end(); ++i)
+ {
+ std::cout << "BuildRule: " << i->first.c_str() << "\n";
+ for(Commands::const_iterator j = i->second.begin();
+ j != i->second.end(); ++j)
+ {
+ std::cout << "Command: " << j->first.c_str() << "\n";
+ std::cout << "Command Outputs " << j->second.m_Outputs.size() << "\n";
+ std::cout << "Command Depends " << j->second.m_Depends.size() << "\n";
+ }
+ }
+}
+
+
void cmSourceGroup::CommandFiles::Merge(const CommandFiles &r)
{
std::set<std::string>::const_iterator dep = r.m_Depends.begin();
@@ -137,3 +155,4 @@ void cmSourceGroup::CommandFiles::Merge(const CommandFiles &r)
}
+
diff --git a/Source/cmSourceGroup.h b/Source/cmSourceGroup.h
index 479abd6..86a7b19 100644
--- a/Source/cmSourceGroup.h
+++ b/Source/cmSourceGroup.h
@@ -90,7 +90,7 @@ public:
{ return m_Name.c_str(); }
const BuildRules& GetBuildRules() const
{ return m_BuildRules; }
-
+ void Print() const;
private:
/**
* The name of the source group.
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 9883621..7e01101 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -105,6 +105,11 @@ void cmSystemTools::GetPath(std::vector<std::string>& path)
done = true;
}
}
+ for(std::vector<std::string>::iterator i = path.begin();
+ i != path.end(); ++i)
+ {
+ cmSystemTools::ConvertToUnixSlashes(*i);
+ }
}
@@ -277,35 +282,6 @@ bool cmSystemTools::ParseFunction(std::ifstream& fin,
cmRegularExpression multiLine("^[ \t]*([A-Za-z_0-9]*)[ \t]*\\((.*)$");
cmRegularExpression lastLine("^(.*)\\)[ \t]*$");
- // BEGIN VERBATIM JUNK SHOULD BE REMOVED
- cmRegularExpression verbatim("BEGIN MAKE VERBATIM");
- if(verbatim.find(inbuffer))
- {
- cmRegularExpression endVerbatim("END MAKE VERBATIM");
- name = "VERBATIM";
- bool done = false;
- while(!done)
- {
- if(fin.getline(inbuffer, BUFFER_SIZE))
- {
- if(endVerbatim.find(inbuffer))
- {
- done = true;
- }
- else
- {
- arguments.push_back(inbuffer);
- }
- }
- else
- {
- done = true;
- }
- }
- return true;
- }
- // END VERBATIM JUNK SHOULD BE REMOVED
-
// check for black line or comment
if(blankLine.find(inbuffer) || comment.find(inbuffer))
{
@@ -584,6 +560,46 @@ bool cmSystemTools::IsOff(const char* val)
}
+bool cmSystemTools::RunCommand(const char* command,
+ std::string& output)
+{
+ std::string commandToFile = command;
+ commandToFile += " > ";
+ std::string tempFile;
+ tempFile += cmSystemTools::TemporaryFileName();
+ commandToFile += tempFile;
+ system(commandToFile.c_str());
+ std::ifstream fin(tempFile.c_str());
+ if(!fin)
+ {
+ cmSystemTools::Error(command, " from RunCommand Faild to create output file",
+ tempFile.c_str());
+ return false;
+ }
+ const int BUFFER_SIZE = 4096;
+ char buffer[BUFFER_SIZE];
+ while(fin)
+ {
+ fin.getline(buffer, BUFFER_SIZE);
+ output += buffer;
+ }
+ cmSystemTools::RemoveFile(tempFile.c_str());
+ return true;
+}
+
+#ifdef _MSC_VER
+#define tempnam _tempnam
+#endif
+
+std::string cmSystemTools::TemporaryFileName()
+{
+ return tempnam(0, "cmake");
+}
+
+
+
+
+
/**
* Find the executable with the given name. Searches the given path and then
* the system search path. Returns the full path to the executable if it is
@@ -718,3 +734,4 @@ std::string cmSystemTools::CollapseFullPath(const char* in_name)
return newPath;
}
+
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 3c6fd45..3830ad3 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -177,6 +177,17 @@ public:
static long int ModifiedTime(const char* filename);
+ /**
+ * Run an executable command and put the stdout in output.
+ * A temporary file is created in the binaryDir for storing the
+ * output because windows does not have popen.
+ */
+ static bool RunCommand(const char* command,
+ std::string& output);
+
+ ///! Generate a temporary file name
+ static std::string TemporaryFileName();
+
private:
static bool s_ErrorOccured;
};
diff --git a/Source/cmUnixMakefileGenerator.cxx b/Source/cmUnixMakefileGenerator.cxx
index 5937d44..4e1506a 100644
--- a/Source/cmUnixMakefileGenerator.cxx
+++ b/Source/cmUnixMakefileGenerator.cxx
@@ -460,7 +460,7 @@ void cmUnixMakefileGenerator::OutputCustomRules(std::ostream& fout)
sourceGroup.AddCustomCommand(cc);
}
}
-
+
// Loop through every source group.
for(std::vector<cmSourceGroup>::const_iterator sg =
sourceGroups.begin(); sg != sourceGroups.end(); ++sg)