~ubuntu-branches/ubuntu/lucid/cmake/lucid

« back to all changes in this revision

Viewing changes to Source/cmInstallGenerator.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Artur Rona
  • Date: 2009-12-16 11:11:54 UTC
  • mfrom: (3.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20091216111154-6accvv6yq86h2hkc
Tags: 2.8.0-5ubuntu1
* Merge from debian testing (LP: #497349). Remaining changes:
  - Keep the Replaces: on cmake-data to cover the Kubuntu version from
    Jaunty in case someone decides to do an (unsupported) Jaunty->Lucid
    upgrade.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*=========================================================================
2
 
 
3
 
  Program:   CMake - Cross-Platform Makefile Generator
4
 
  Module:    $RCSfile: cmInstallGenerator.cxx,v $
5
 
  Language:  C++
6
 
  Date:      $Date: 2009-01-13 18:03:52 $
7
 
  Version:   $Revision: 1.15.2.1 $
8
 
 
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.
11
 
 
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.
15
 
 
16
 
=========================================================================*/
 
1
/*============================================================================
 
2
  CMake - Cross Platform Makefile Generator
 
3
  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
 
4
 
 
5
  Distributed under the OSI-approved BSD License (the "License");
 
6
  see accompanying file Copyright.txt for details.
 
7
 
 
8
  This software is distributed WITHOUT ANY WARRANTY; without even the
 
9
  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
10
  See the License for more information.
 
11
============================================================================*/
17
12
#include "cmInstallGenerator.h"
18
13
 
19
14
#include "cmSystemTools.h"
24
19
::cmInstallGenerator(const char* destination,
25
20
                     std::vector<std::string> const& configurations,
26
21
                     const char* component):
 
22
  cmScriptGenerator("CMAKE_INSTALL_CONFIG_NAME", configurations),
27
23
  Destination(destination? destination:""),
28
 
  Configurations(configurations),
29
 
  Component(component? component:""),
30
 
  ConfigurationName(0),
31
 
  ConfigurationTypes(0)
 
24
  Component(component? component:"")
32
25
{
33
26
}
34
27
 
39
32
}
40
33
 
41
34
//----------------------------------------------------------------------------
42
 
void
43
 
cmInstallGenerator
44
 
::Generate(std::ostream& os, const char* config,
45
 
           std::vector<std::string> const& configurationTypes)
46
 
{
47
 
  this->ConfigurationName = config;
48
 
  this->ConfigurationTypes = &configurationTypes;
49
 
  this->GenerateScript(os);
50
 
  this->ConfigurationName = 0;
51
 
  this->ConfigurationTypes = 0;
52
 
}
53
 
 
54
 
//----------------------------------------------------------------------------
55
35
void cmInstallGenerator
56
36
::AddInstallRule(
57
37
                 std::ostream& os,
58
38
                 int type,
59
39
                 std::vector<std::string> const& files,
60
40
                 bool optional /* = false */,
61
 
                 const char* properties /* = 0 */,
62
41
                 const char* permissions_file /* = 0 */,
63
42
                 const char* permissions_dir /* = 0 */,
64
43
                 const char* rename /* = 0 */,
65
44
                 const char* literal_args /* = 0 */,
66
 
                 cmInstallGeneratorIndent const& indent
 
45
                 Indent const& indent
67
46
                 )
68
47
{
69
48
  // Use the FILE command to install the file.
86
65
    {
87
66
    os << " OPTIONAL";
88
67
    }
89
 
  if(properties && *properties)
90
 
    {
91
 
    os << " PROPERTIES" << properties;
92
 
    }
93
68
  if(permissions_file && *permissions_file)
94
69
    {
95
70
    os << " PERMISSIONS" << permissions_file;
128
103
}
129
104
 
130
105
//----------------------------------------------------------------------------
131
 
static void cmInstallGeneratorEncodeConfig(const char* config,
132
 
                                           std::string& result)
133
 
{
134
 
  for(const char* c = config; *c; ++c)
135
 
    {
136
 
    if(*c >= 'a' && *c <= 'z')
137
 
      {
138
 
      result += "[";
139
 
      result += *c + ('A' - 'a');
140
 
      result += *c;
141
 
      result += "]";
142
 
      }
143
 
    else if(*c >= 'A' && *c <= 'Z')
144
 
      {
145
 
      result += "[";
146
 
      result += *c;
147
 
      result += *c + ('a' - 'A');
148
 
      result += "]";
149
 
      }
150
 
    else
151
 
      {
152
 
      result += *c;
153
 
      }
154
 
    }
155
 
}
156
 
 
157
 
//----------------------------------------------------------------------------
158
 
std::string
159
 
cmInstallGenerator::CreateConfigTest(const char* config)
160
 
{
161
 
  std::string result = "\"${CMAKE_INSTALL_CONFIG_NAME}\" MATCHES \"^(";
162
 
  if(config && *config)
163
 
    {
164
 
    cmInstallGeneratorEncodeConfig(config, result);
165
 
    }
166
 
  result += ")$\"";
167
 
  return result;
168
 
}
169
 
 
170
 
//----------------------------------------------------------------------------
171
 
std::string
172
 
cmInstallGenerator::CreateConfigTest(std::vector<std::string> const& configs)
173
 
{
174
 
  std::string result = "\"${CMAKE_INSTALL_CONFIG_NAME}\" MATCHES \"^(";
175
 
  const char* sep = "";
176
 
  for(std::vector<std::string>::const_iterator ci = configs.begin();
177
 
      ci != configs.end(); ++ci)
178
 
    {
179
 
    result += sep;
180
 
    sep = "|";
181
 
    cmInstallGeneratorEncodeConfig(ci->c_str(), result);
182
 
    }
183
 
  result += ")$\"";
184
 
  return result;
185
 
}
186
 
 
187
 
//----------------------------------------------------------------------------
188
106
std::string
189
107
cmInstallGenerator::CreateComponentTest(const char* component)
190
108
{
214
132
}
215
133
 
216
134
//----------------------------------------------------------------------------
217
 
void
218
 
cmInstallGenerator::GenerateScriptConfigs(std::ostream& os,
219
 
                                          Indent const& indent)
220
 
{
221
 
  if(this->Configurations.empty())
222
 
    {
223
 
    // This rule is for all configurations.
224
 
    this->GenerateScriptActions(os, indent);
225
 
    }
226
 
  else
227
 
    {
228
 
    // Generate a per-configuration block.
229
 
    std::string config_test = this->CreateConfigTest(this->Configurations);
230
 
    os << indent << "IF(" << config_test << ")\n";
231
 
    this->GenerateScriptActions(os, indent.Next());
232
 
    os << indent << "ENDIF(" << config_test << ")\n";
233
 
    }
234
 
}
235
 
 
236
 
//----------------------------------------------------------------------------
237
 
void cmInstallGenerator::GenerateScriptActions(std::ostream&, Indent const&)
238
 
{
239
 
  // No actions for this generator.
240
 
}
241
 
 
242
 
//----------------------------------------------------------------------------
243
135
bool cmInstallGenerator::InstallsForConfig(const char* config)
244
136
{
245
 
  // If this is not a configuration-specific rule then we install.
246
 
  if(this->Configurations.empty())
247
 
    {
248
 
    return true;
249
 
    }
250
 
 
251
 
  // This is a configuration-specific rule.  Check if the config
252
 
  // matches this rule.
253
 
  std::string config_upper = cmSystemTools::UpperCase(config?config:"");
254
 
  for(std::vector<std::string>::const_iterator i =
255
 
        this->Configurations.begin();
256
 
      i != this->Configurations.end(); ++i)
257
 
    {
258
 
    if(cmSystemTools::UpperCase(*i) == config_upper)
259
 
      {
260
 
      return true;
261
 
      }
262
 
    }
263
 
  return false;
 
137
  return this->GeneratesForConfig(config);
264
138
}
265
139
 
266
140
//----------------------------------------------------------------------------