diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2018-06-08 19:14:10 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2018-07-02 13:51:02 (GMT) |
commit | 80914d88da3e5c997158fd3cc703a39b6673f780 (patch) | |
tree | 5b472c13d547f5b2d8e3c7c4d92f96b912c899ab /Source/CPack/cmCPackExtGenerator.h | |
parent | 3ced881db63a97eb402bd68be5e45298371f4519 (diff) | |
download | CMake-80914d88da3e5c997158fd3cc703a39b6673f780.zip CMake-80914d88da3e5c997158fd3cc703a39b6673f780.tar.gz CMake-80914d88da3e5c997158fd3cc703a39b6673f780.tar.bz2 |
CPack: Add "CPack External" generator
This generator doesn't actually package the files. Instead, it
provides a metadata JSON file that can be used by external packaging
software to do its own packaging. This JSON file provides information
about the components, component groups, installation types, and CMake
projects.
Diffstat (limited to 'Source/CPack/cmCPackExtGenerator.h')
-rw-r--r-- | Source/CPack/cmCPackExtGenerator.h | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/Source/CPack/cmCPackExtGenerator.h b/Source/CPack/cmCPackExtGenerator.h new file mode 100644 index 0000000..fa12d7f --- /dev/null +++ b/Source/CPack/cmCPackExtGenerator.h @@ -0,0 +1,86 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cmCPackExtGenerator_h +#define cmCPackExtGenerator_h + +#include "cmCPackGenerator.h" +#include "cm_sys_stat.h" + +#include <memory> +#include <string> + +class cmGlobalGenerator; +namespace Json { +class Value; +} + +/** \class cmCPackExtGenerator + * \brief A generator for CPack External packaging tools + */ +class cmCPackExtGenerator : public cmCPackGenerator +{ +public: + cmCPackTypeMacro(cmCPackExtGenerator, cmCPackGenerator); + + const char* GetOutputExtension() override { return ".json"; } + +protected: + int InitializeInternal() override; + + int PackageFiles() override; + + bool SupportsComponentInstallation() const override; + + int InstallProjectViaInstallCommands( + bool setDestDir, const std::string& tempInstallDirectory) override; + int InstallProjectViaInstallScript( + bool setDestDir, const std::string& tempInstallDirectory) override; + int InstallProjectViaInstalledDirectories( + bool setDestDir, const std::string& tempInstallDirectory, + const mode_t* default_dir_mode) override; + + int RunPreinstallTarget(const std::string& installProjectName, + const std::string& installDirectory, + cmGlobalGenerator* globalGenerator, + const std::string& buildConfig) override; + int InstallCMakeProject(bool setDestDir, const std::string& installDirectory, + const std::string& baseTempInstallDirectory, + const mode_t* default_dir_mode, + const std::string& component, bool componentInstall, + const std::string& installSubDirectory, + const std::string& buildConfig, + std::string& absoluteDestFiles) override; + +private: + class cmCPackExtVersionGenerator + { + public: + cmCPackExtVersionGenerator(cmCPackExtGenerator* parent); + + virtual ~cmCPackExtVersionGenerator() = default; + + virtual int WriteToJSON(Json::Value& root); + + protected: + virtual int GetVersionMajor() = 0; + virtual int GetVersionMinor() = 0; + + int WriteVersion(Json::Value& root); + + cmCPackExtGenerator* Parent; + }; + + class cmCPackExtVersion1Generator : public cmCPackExtVersionGenerator + { + public: + using cmCPackExtVersionGenerator::cmCPackExtVersionGenerator; + + protected: + int GetVersionMajor() override { return 1; } + int GetVersionMinor() override { return 0; } + }; + + std::unique_ptr<cmCPackExtVersionGenerator> Generator; +}; + +#endif |