Add label summary times to ctest default output. Also, remove parallel time output...
[cmake.git] / Source / cmInstallProgramsCommand.cxx
blobeff2934b1b1e7a82abb945b70a3df3d771f78ed8
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmInstallProgramsCommand.cxx,v $
5 Language: C++
6 Date: $Date: 2009-02-04 15:34:08 $
7 Version: $Revision: 1.24 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html 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 "cmInstallProgramsCommand.h"
18 #include "cmInstallFilesGenerator.h"
19 // cmExecutableCommand
20 bool cmInstallProgramsCommand
21 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
23 if(args.size() < 2)
25 this->SetError("called with incorrect number of arguments");
26 return false;
29 // Enable the install target.
30 this->Makefile->GetLocalGenerator()
31 ->GetGlobalGenerator()->EnableInstallTarget();
33 this->Destination = args[0];
35 std::vector<std::string>::const_iterator s = args.begin();
36 for (++s;s != args.end(); ++s)
38 this->FinalArgs.push_back(*s);
41 this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
42 ->AddInstallComponent("Unspecified");
44 return true;
47 void cmInstallProgramsCommand::FinalPass()
49 bool files_mode = false;
50 if(!this->FinalArgs.empty() && this->FinalArgs[0] == "FILES")
52 files_mode = true;
55 // two different options
56 if (this->FinalArgs.size() > 1 || files_mode)
58 // for each argument, get the programs
59 std::vector<std::string>::iterator s = this->FinalArgs.begin();
60 if(files_mode)
62 // Skip the FILES argument in files mode.
63 ++s;
65 for(;s != this->FinalArgs.end(); ++s)
67 // add to the result
68 this->Files.push_back(this->FindInstallSource(s->c_str()));
71 else // reg exp list
73 std::vector<std::string> programs;
74 cmSystemTools::Glob(this->Makefile->GetCurrentDirectory(),
75 this->FinalArgs[0].c_str(), programs);
77 std::vector<std::string>::iterator s = programs.begin();
78 // for each argument, get the programs
79 for (;s != programs.end(); ++s)
81 this->Files.push_back(this->FindInstallSource(s->c_str()));
85 // Construct the destination. This command always installs under
86 // the prefix. We skip the leading slash given by the user.
87 std::string destination = this->Destination.substr(1);
88 cmSystemTools::ConvertToUnixSlashes(destination);
89 if(destination.empty())
91 destination = ".";
94 // Use a file install generator.
95 const char* no_permissions = "";
96 const char* no_rename = "";
97 const char* no_component = "Unspecified";
98 std::vector<std::string> no_configurations;
99 this->Makefile->AddInstallGenerator(
100 new cmInstallFilesGenerator(this->Files,
101 destination.c_str(), true,
102 no_permissions, no_configurations,
103 no_component, no_rename));
107 * Find a file in the build or source tree for installation given a
108 * relative path from the CMakeLists.txt file. This will favor files
109 * present in the build tree. If a full path is given, it is just
110 * returned.
112 std::string cmInstallProgramsCommand
113 ::FindInstallSource(const char* name) const
115 if(cmSystemTools::FileIsFullPath(name))
117 // This is a full path.
118 return name;
121 // This is a relative path.
122 std::string tb = this->Makefile->GetCurrentOutputDirectory();
123 tb += "/";
124 tb += name;
125 std::string ts = this->Makefile->GetCurrentDirectory();
126 ts += "/";
127 ts += name;
129 if(cmSystemTools::FileExists(tb.c_str()))
131 // The file exists in the binary tree. Use it.
132 return tb;
134 else if(cmSystemTools::FileExists(ts.c_str()))
136 // The file exists in the source tree. Use it.
137 return ts;
139 else
141 // The file doesn't exist. Assume it will be present in the
142 // binary tree when the install occurs.
143 return tb;