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