FIX: stupid pb fixed (close to being medieval'ed by The Ken)
[cmake.git] / Source / cmInstallFilesCommand.cxx
blobe876c2d6de7d4374d973727e98d44e2154fd9619
1 /*=========================================================================
3 Program: Insight Segmentation & Registration Toolkit
4 Module: $RCSfile: cmInstallFilesCommand.cxx,v $
5 Language: C++
6 Date: $Date: 2002-07-17 19:57:51 $
7 Version: $Revision: 1.15 $
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 "cmInstallFilesCommand.h"
18 #include "cmCacheManager.h"
20 // cmExecutableCommand
21 bool cmInstallFilesCommand::InitialPass(std::vector<std::string> const& argsIn)
23 if(argsIn.size() < 2)
25 this->SetError("called with incorrect number of arguments");
26 return false;
28 std::vector<std::string> args;
29 m_Makefile->ExpandSourceListArguments(argsIn, args, 2);
31 // Create an INSTALL_FILES target specifically for this path.
32 m_TargetName = "INSTALL_FILES_"+args[0];
33 cmTarget target;
34 target.SetInAll(false);
35 target.SetType(cmTarget::INSTALL_FILES);
36 target.SetInstallPath(args[0].c_str());
37 m_Makefile->GetTargets().insert(cmTargets::value_type(m_TargetName, target));
39 std::vector<std::string>::const_iterator s = args.begin();
40 for (++s;s != args.end(); ++s)
42 m_FinalArgs.push_back(*s);
45 return true;
48 void cmInstallFilesCommand::FinalPass()
50 std::string testf;
51 std::string ext = m_FinalArgs[0];
52 std::vector<std::string>& targetSourceLists =
53 m_Makefile->GetTargets()[m_TargetName].GetSourceLists();
55 // two different options
56 if (m_FinalArgs.size() > 1)
58 // now put the files into the list
59 std::vector<std::string>::iterator s = m_FinalArgs.begin();
60 ++s;
61 // for each argument, get the files
62 for (;s != m_FinalArgs.end(); ++s)
64 // replace any variables
65 std::string temps = *s;
66 if (cmSystemTools::GetFilenamePath(temps).size() > 0)
68 testf = cmSystemTools::GetFilenamePath(temps) + "/" +
69 cmSystemTools::GetFilenameWithoutLastExtension(temps) + ext;
71 else
73 testf = cmSystemTools::GetFilenameWithoutLastExtension(temps) + ext;
75 // add to the result
76 targetSourceLists.push_back(testf);
79 else // reg exp list
81 std::vector<std::string> files;
82 std::string regex = m_FinalArgs[0].c_str();
83 cmSystemTools::Glob(m_Makefile->GetCurrentDirectory(),
84 regex.c_str(), files);
86 std::vector<std::string>::iterator s = files.begin();
87 // for each argument, get the files
88 for (;s != files.end(); ++s)
90 targetSourceLists.push_back(*s);