blob: 0fcfa546fec1dff0f031f64ba92325c70482880a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstallSubdirectoryGenerator.h"
#include <memory>
#include <sstream>
#include <utility>
#include <vector>
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmPolicies.h"
#include "cmScriptGenerator.h"
#include "cmSystemTools.h"
cmInstallSubdirectoryGenerator::cmInstallSubdirectoryGenerator(
cmMakefile* makefile, std::string binaryDirectory, bool excludeFromAll,
cmListFileBacktrace backtrace)
: cmInstallGenerator("", std::vector<std::string>(), "", MessageDefault,
excludeFromAll, false, std::move(backtrace))
, Makefile(makefile)
, BinaryDirectory(std::move(binaryDirectory))
{
}
cmInstallSubdirectoryGenerator::~cmInstallSubdirectoryGenerator() = default;
bool cmInstallSubdirectoryGenerator::HaveInstall()
{
for (const auto& generator : this->Makefile->GetInstallGenerators()) {
if (generator->HaveInstall()) {
return true;
}
}
return false;
}
void cmInstallSubdirectoryGenerator::CheckCMP0082(
bool& haveSubdirectoryInstall, bool& /*unused*/)
{
if (this->HaveInstall()) {
haveSubdirectoryInstall = true;
}
}
bool cmInstallSubdirectoryGenerator::Compute(cmLocalGenerator* lg)
{
this->LocalGenerator = lg;
return true;
}
void cmInstallSubdirectoryGenerator::GenerateScript(std::ostream& os)
{
if (!this->ExcludeFromAll) {
cmPolicies::PolicyStatus status =
this->LocalGenerator->GetPolicyStatus(cmPolicies::CMP0082);
switch (status) {
case cmPolicies::WARN:
case cmPolicies::OLD:
// OLD behavior is handled in cmLocalGenerator::GenerateInstallRules()
break;
case cmPolicies::NEW:
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS: {
Indent indent;
std::string odir = this->BinaryDirectory;
cmSystemTools::ConvertToUnixSlashes(odir);
os << indent << "if(NOT CMAKE_INSTALL_LOCAL_ONLY)\n"
<< indent.Next()
<< "# Include the install script for the subdirectory.\n"
<< indent.Next() << "include(\"" << odir
<< "/cmake_install.cmake\")\n"
<< indent << "endif()\n\n";
} break;
}
}
}
|