summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2002-09-20 13:14:47 -0400
committerAndy Cedilnik <andy.cedilnik@kitware.com>2002-09-20 13:14:47 -0400
commit92714311c992a924a249bf9f27820f0512af7013 (patch)
treea228304f99ee151845d7d3db4fe9cf2857535a65
parente5a8887426da6314855beca296c532119e8d3935 (diff)
downloadcmake-92714311c992a924a249bf9f27820f0512af7013.tar.gz
Add WRITE_FILE command, which writes string to a file
-rw-r--r--Source/cmCommands.cxx2
-rw-r--r--Source/cmWriteFileCommand.cxx54
-rw-r--r--Source/cmWriteFileCommand.h71
3 files changed, 127 insertions, 0 deletions
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index 204de61e2f..fb3c6e2c54 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -88,6 +88,7 @@
#include "cmQTWrapCPPCommand.cxx"
#include "cmQTWrapUICommand.cxx"
#include "cmWrapExcludeFilesCommand.cxx"
+#include "cmWriteFileCommand.cxx"
// on regular builds add in the load command command
// we do not add it in on the bootstrap because it
@@ -171,4 +172,5 @@ void GetPredefinedCommands(std::list<cmCommand*>& commands)
commands.push_back(new cmQTWrapCPPCommand);
commands.push_back(new cmQTWrapUICommand);
commands.push_back(new cmWrapExcludeFilesCommand);
+ commands.push_back(new cmWriteFileCommand);
}
diff --git a/Source/cmWriteFileCommand.cxx b/Source/cmWriteFileCommand.cxx
new file mode 100644
index 0000000000..04fc5799e9
--- /dev/null
+++ b/Source/cmWriteFileCommand.cxx
@@ -0,0 +1,54 @@
+/*=========================================================================
+
+ Program: Insight Segmentation & Registration Toolkit
+ Module: $RCSfile$
+ Language: C++
+ Date: $Date$
+ Version: $Revision$
+
+ Copyright (c) 2002 Insight Consortium. All rights reserved.
+ See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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 "cmWriteFileCommand.h"
+#include "cmCacheManager.h"
+
+// cmLibraryCommand
+bool cmWriteFileCommand::InitialPass(std::vector<std::string> const& argsIn)
+{
+ if(argsIn.size() < 2 )
+ {
+ this->SetError("called with incorrect number of arguments");
+ return false;
+ }
+ std::vector<std::string> args;
+ cmSystemTools::ExpandListArguments(argsIn, args);
+ std::string message;
+ std::vector<std::string>::const_iterator i = args.begin();
+
+ bool send_error = false;
+ std::string fileName = *i;
+ i++;
+
+ for(;i != args.end(); ++i)
+ {
+ message += *i;
+ }
+
+ std::ofstream file(fileName.c_str(), std::ios::app);
+ if ( !file )
+ {
+ cmSystemTools::Error("Internal CMake error when trying to open file: ",
+ fileName.c_str());
+ return false;
+ }
+ file << message << endl;
+ file.close();
+
+ return true;
+}
+
diff --git a/Source/cmWriteFileCommand.h b/Source/cmWriteFileCommand.h
new file mode 100644
index 0000000000..c11c023a63
--- /dev/null
+++ b/Source/cmWriteFileCommand.h
@@ -0,0 +1,71 @@
+/*=========================================================================
+
+ Program: Insight Segmentation & Registration Toolkit
+ Module: $RCSfile$
+ Language: C++
+ Date: $Date$
+ Version: $Revision$
+
+ Copyright (c) 2002 Insight Consortium. All rights reserved.
+ See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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 cmWriteFileCommand_h
+#define cmWriteFileCommand_h
+
+#include "cmStandardIncludes.h"
+#include "cmCommand.h"
+
+/** \class cmWriteFileCommand
+ * \brief Writes a message to a file
+ *
+ */
+class cmWriteFileCommand : public cmCommand
+{
+public:
+ /**
+ * This is a virtual constructor for the command.
+ */
+ virtual cmCommand* Clone()
+ {
+ return new cmWriteFileCommand;
+ }
+
+ /**
+ * 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 "WRITE_FILE";}
+
+ /**
+ * Succinct documentation.
+ */
+ virtual const char* GetTerseDocumentation()
+ {
+ return "Write a message to a file.";
+ }
+
+ /**
+ * More documentation.
+ */
+ virtual const char* GetFullDocumentation()
+ {
+ return
+ "WRITE_FILE(filename \"message to write\"...)\n"
+ "The first argument is the file name, the rest of the arguments are messages to write.";
+ }
+
+ cmTypeMacro(cmWriteFileCommand, cmCommand);
+};
+
+
+#endif