diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2002-03-15 20:42:59 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2002-03-15 20:42:59 (GMT) |
commit | 5bbae885693f74b50b1f4265d8ab32fe65288194 (patch) | |
tree | 55fc5a134bde8f54292155952273ac549c49ec12 /Source/ccommand.cxx | |
parent | c8924864fdcf66fcc62d4c6a95606ad200b7ba1a (diff) | |
download | CMake-5bbae885693f74b50b1f4265d8ab32fe65288194.zip CMake-5bbae885693f74b50b1f4265d8ab32fe65288194.tar.gz CMake-5bbae885693f74b50b1f4265d8ab32fe65288194.tar.bz2 |
Add ccommand for executing commands on the system, so by using ADD_CUSTOM_COMMAND, you can make rules to do some system commands during build. Currently supported commands are copy and remove. Others will follow.
Diffstat (limited to 'Source/ccommand.cxx')
-rw-r--r-- | Source/ccommand.cxx | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Source/ccommand.cxx b/Source/ccommand.cxx new file mode 100644 index 0000000..fc67aad --- /dev/null +++ b/Source/ccommand.cxx @@ -0,0 +1,61 @@ +/*========================================================================= + + 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 "cmMakefile.h" +#include "cmSystemTools.h" + +void CMakeCommandUsage(const char* program) +{ + std::strstream errorStream; + + errorStream << "cmake version " << cmMakefile::GetMajorVersion() + << "." << cmMakefile::GetMinorVersion() << "\n"; + errorStream << "Usage: " << program << " [command] [arguments ...]\n" + << " Available commands: \n" + << " copy file1 file2 - copy first file to the second one\n" + << " remove file1 file2 ... - remove the file(s)\n"; + errorStream << std::ends; + cmSystemTools::Error(errorStream.str()); +} + +int main(int ac, char** av) +{ + std::vector<std::string> args; + for(int i =0; i < ac; ++i) + { + args.push_back(av[i]); + } + + if ( args.size() > 1 ) + { + if ( args[1] == "copy" && args.size() == 4 ) + { + cmSystemTools::cmCopyFile(args[2].c_str(), args[3].c_str()); + return 0; + } + if ( args[1] == "remove" && args.size() > 2 ) + { + for ( int cc = 2; cc < args.size(); cc ++ ) + { + cmSystemTools::RemoveFile(args[cc].c_str()); + } + return 0; + } + } + ::CMakeCommandUsage(args[0].c_str()); + return 1; +} |