1
/*=========================================================================
3
Program: CMake - Cross-Platform Makefile Generator
4
Module: $RCSfile: cmInstallGenerator.cxx,v $
6
Date: $Date: 2009-01-13 18:03:52 $
7
Version: $Revision: 1.15.2.1 $
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
=========================================================================*/
1
/*============================================================================
2
CMake - Cross Platform Makefile Generator
3
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5
Distributed under the OSI-approved BSD License (the "License");
6
see accompanying file Copyright.txt for details.
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"
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:""),
24
Component(component? component:"")
41
34
//----------------------------------------------------------------------------
44
::Generate(std::ostream& os, const char* config,
45
std::vector<std::string> const& configurationTypes)
47
this->ConfigurationName = config;
48
this->ConfigurationTypes = &configurationTypes;
49
this->GenerateScript(os);
50
this->ConfigurationName = 0;
51
this->ConfigurationTypes = 0;
54
//----------------------------------------------------------------------------
55
35
void cmInstallGenerator
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
69
48
// Use the FILE command to install the file.
130
105
//----------------------------------------------------------------------------
131
static void cmInstallGeneratorEncodeConfig(const char* config,
134
for(const char* c = config; *c; ++c)
136
if(*c >= 'a' && *c <= 'z')
139
result += *c + ('A' - 'a');
143
else if(*c >= 'A' && *c <= 'Z')
147
result += *c + ('a' - 'A');
157
//----------------------------------------------------------------------------
159
cmInstallGenerator::CreateConfigTest(const char* config)
161
std::string result = "\"${CMAKE_INSTALL_CONFIG_NAME}\" MATCHES \"^(";
162
if(config && *config)
164
cmInstallGeneratorEncodeConfig(config, result);
170
//----------------------------------------------------------------------------
172
cmInstallGenerator::CreateConfigTest(std::vector<std::string> const& configs)
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)
181
cmInstallGeneratorEncodeConfig(ci->c_str(), result);
187
//----------------------------------------------------------------------------
189
107
cmInstallGenerator::CreateComponentTest(const char* component)
216
134
//----------------------------------------------------------------------------
218
cmInstallGenerator::GenerateScriptConfigs(std::ostream& os,
219
Indent const& indent)
221
if(this->Configurations.empty())
223
// This rule is for all configurations.
224
this->GenerateScriptActions(os, indent);
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";
236
//----------------------------------------------------------------------------
237
void cmInstallGenerator::GenerateScriptActions(std::ostream&, Indent const&)
239
// No actions for this generator.
242
//----------------------------------------------------------------------------
243
135
bool cmInstallGenerator::InstallsForConfig(const char* config)
245
// If this is not a configuration-specific rule then we install.
246
if(this->Configurations.empty())
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)
258
if(cmSystemTools::UpperCase(*i) == config_upper)
137
return this->GeneratesForConfig(config);
266
140
//----------------------------------------------------------------------------