cmake/Source/cmInstallGenerator.h

103 lines
3.5 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2021-09-14 00:13:48 +02:00
#pragma once
2018-01-26 17:06:56 +01:00
#include "cmConfigure.h" // IWYU pragma: keep
2016-10-30 18:24:19 +01:00
2021-09-14 00:13:48 +02:00
#include <functional>
2016-10-30 18:24:19 +01:00
#include <iosfwd>
#include <string>
#include <vector>
2020-02-01 23:06:01 +01:00
#include "cmInstallType.h"
2021-09-14 00:13:48 +02:00
#include "cmListFileCache.h"
2020-02-01 23:06:01 +01:00
#include "cmScriptGenerator.h"
class cmLocalGenerator;
2015-04-27 22:25:09 +02:00
class cmMakefile;
/** \class cmInstallGenerator
* \brief Support class for generating install scripts.
*
*/
2016-07-09 11:21:54 +02:00
class cmInstallGenerator : public cmScriptGenerator
{
public:
2015-04-27 22:25:09 +02:00
enum MessageLevel
{
MessageDefault,
MessageAlways,
MessageLazy,
MessageNever
};
2020-08-30 11:54:41 +02:00
cmInstallGenerator(std::string destination,
std::vector<std::string> const& configurations,
2020-08-30 11:54:41 +02:00
std::string component, MessageLevel message,
2021-09-14 00:13:48 +02:00
bool exclude_from_all, bool all_components,
cmListFileBacktrace backtrace);
2018-01-26 17:06:56 +01:00
~cmInstallGenerator() override;
2019-11-11 23:01:05 +01:00
cmInstallGenerator(cmInstallGenerator const&) = delete;
cmInstallGenerator& operator=(cmInstallGenerator const&) = delete;
virtual bool HaveInstall();
virtual void CheckCMP0082(bool& haveSubdirectoryInstall,
bool& haveInstallAfterSubdirectory);
2016-10-30 18:24:19 +01:00
void AddInstallRule(
std::ostream& os, std::string const& dest, cmInstallType type,
std::vector<std::string> const& files, bool optional = false,
2018-01-26 17:06:56 +01:00
const char* permissions_file = nullptr,
const char* permissions_dir = nullptr, const char* rename = nullptr,
2021-09-14 00:13:48 +02:00
const char* literal_args = nullptr, Indent indent = Indent(),
const char* files_var = nullptr);
/** Get the install destination as it should appear in the
installation script. */
2021-09-14 00:13:48 +02:00
static std::string ConvertToAbsoluteDestination(std::string const& dest);
/** Test if this generator installs something for a given configuration. */
2015-04-27 22:25:09 +02:00
bool InstallsForConfig(const std::string& config);
/** Select message level from CMAKE_INSTALL_MESSAGE or 'never'. */
static MessageLevel SelectMessageLevel(cmMakefile* mf, bool never = false);
2019-11-11 23:01:05 +01:00
virtual bool Compute(cmLocalGenerator*) { return true; }
2015-11-17 17:22:37 +01:00
2021-09-14 00:13:48 +02:00
std::string const& GetComponent() const { return this->Component; }
bool GetExcludeFromAll() const { return this->ExcludeFromAll; }
bool GetAllComponentsFlag() const { return this->AllComponents; }
cmListFileBacktrace const& GetBacktrace() const { return this->Backtrace; }
static std::string GetDestDirPath(std::string const& file);
protected:
2018-01-26 17:06:56 +01:00
void GenerateScript(std::ostream& os) override;
2020-08-30 11:54:41 +02:00
std::string CreateComponentTest(const std::string& component,
2022-08-04 22:12:04 +02:00
bool exclude_from_all,
bool all_components = false);
2021-09-14 00:13:48 +02:00
using TweakMethod =
std::function<void(std::ostream& os, Indent indent,
const std::string& config, const std::string& file)>;
static void AddTweak(std::ostream& os, Indent indent,
const std::string& config, std::string const& file,
const TweakMethod& tweak);
static void AddTweak(std::ostream& os, Indent indent,
const std::string& config, std::string const& dir,
std::vector<std::string> const& files,
const TweakMethod& tweak);
// Information shared by most generator types.
2020-08-30 11:54:41 +02:00
std::string const Destination;
std::string const Component;
MessageLevel const Message;
bool const ExcludeFromAll;
2021-09-14 00:13:48 +02:00
bool const AllComponents;
cmListFileBacktrace const Backtrace;
};