blob: 1c0512ce5fde6df05924c00322085b539ac0ee5a (
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
|
/* 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 "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmPolicies.h"
#include "cmScriptGenerator.h"
#include "cmSystemTools.h"
#include <sstream>
#include <vector>
cmInstallSubdirectoryGenerator::cmInstallSubdirectoryGenerator(
cmMakefile* makefile, const char* binaryDirectory, bool excludeFromAll)
: cmInstallGenerator(nullptr, std::vector<std::string>(), nullptr,
MessageDefault, excludeFromAll)
, Makefile(makefile)
, BinaryDirectory(binaryDirectory)
{
}
cmInstallSubdirectoryGenerator::~cmInstallSubdirectoryGenerator() = default;
bool cmInstallSubdirectoryGenerator::HaveInstall()
{
for (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;
}
}
}
|