FIX: stupid pb fixed (close to being medieval'ed by The Ken)
[cmake.git] / Source / cmExecProgramCommand.cxx
blobda3a04e93f6737739dd65f67973868497ed1fe64
1 /*=========================================================================
3 Program: Insight Segmentation & Registration Toolkit
4 Module: $RCSfile: cmExecProgramCommand.cxx,v $
5 Language: C++
6 Date: $Date: 2002-04-08 17:36:18 $
7 Version: $Revision: 1.11 $
9 Copyright (c) 2002 Insight Consortium. All rights reserved.
10 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmExecProgramCommand.h"
18 #include "cmSystemTools.h"
20 // cmExecProgramCommand
21 bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args)
23 if(args.size() < 1 )
25 this->SetError("called with incorrect number of arguments");
26 return false;
28 std::string arguments;
29 bool doingargs = false;
30 int count = 0;
31 for(size_t i=0; i < args.size(); ++i)
33 if(doingargs)
35 arguments += args[i];
36 arguments += " ";
37 count++;
39 else if(args[i] == "ARGS")
41 count++;
42 doingargs = true;
46 std::string command;
47 if(arguments.size())
49 command = cmSystemTools::ConvertToOutputPath(args[0].c_str());
50 command += " ";
51 command += arguments;
53 else
55 command = args[0];
57 std::string output;
58 if(args.size() - count == 2)
60 cmSystemTools::MakeDirectory(args[1].c_str());
61 cmSystemTools::RunCommand(command.c_str(), output,
62 cmSystemTools::ConvertToOutputPath(args[1].c_str()).c_str());
64 else
66 cmSystemTools::RunCommand(command.c_str(), output);
68 return true;