1 /*=========================================================================
3 Program: Insight Segmentation & Registration Toolkit
4 Module: $RCSfile: cmAddCustomCommandCommand.cxx,v $
6 Date: $Date: 2002-05-22 17:20:54 $
7 Version: $Revision: 1.13 $
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 "cmAddCustomCommandCommand.h"
20 // cmAddCustomCommandCommand
21 bool cmAddCustomCommandCommand::InitialPass(std::vector
<std::string
> const& argsIn
)
23 /* Let's complain at the end of this function about the lack of a particular
24 arg. For the moment, let's say that COMMAND, TARGET are always
27 if (argsIn
.size() < 4)
29 this->SetError("called with wrong number of arguments.");
32 std::vector
<std::string
> args
;
33 cmSystemTools::ExpandListArguments(argsIn
, args
);
35 std::string source
, command
, target
;
36 std::vector
<std::string
> command_args
, depends
, outputs
;
37 std::string outDir
= m_Makefile
->GetCurrentOutputDirectory();
49 tdoing doing
= doing_nothing
;
51 for (unsigned int j
= 0; j
< args
.size(); ++j
)
53 std::string
const& copy
= args
[j
];
59 else if(copy
== "COMMAND")
61 doing
= doing_command
;
63 else if(copy
== "TARGET")
67 else if(copy
== "ARGS")
71 else if (copy
== "DEPENDS")
73 doing
= doing_depends
;
75 else if (copy
== "OUTPUTS")
77 doing
= doing_outputs
;
93 command_args
.push_back(copy
);
96 depends
.push_back(copy
);
99 outputs
.push_back(copy
);
102 this->SetError("Wrong syntax. Unknow type of argument.");
108 /* At this point we could complain about the lack of arguments.
109 For the moment, let's say that COMMAND, TARGET are always
115 this->SetError("Wrong syntax. Empty COMMAND.");
120 this->SetError("Wrong syntax. Empty TARGET.");
124 // If source is empty, use target as source, so that this command
125 // can be used to just attach a commmand to a target
132 m_Makefile
->AddCustomCommand(source
.c_str(),