CMake/Source/cmQtAutoGenInitializer.h

195 lines
5.2 KiB
C
Raw Normal View History

Simplify CMake per-source license notices Per-source copyright/license notice headers that spell out copyright holder names and years are hard to maintain and often out-of-date or plain wrong. Precise contributor information is already maintained automatically by the version control tool. Ultimately it is the receiver of a file who is responsible for determining its licensing status, and per-source notices are merely a convenience. Therefore it is simpler and more accurate for each source to have a generic notice of the license name and references to more detailed information on copyright holders and full license terms. Our `Copyright.txt` file now contains a list of Contributors whose names appeared source-level copyright notices. It also references version control history for more precise information. Therefore we no longer need to spell out the list of Contributors in each source file notice. Replace CMake per-source copyright/license notice headers with a short description of the license and links to `Copyright.txt` and online information available from "https://cmake.org/licensing". The online URL also handles cases of modules being copied out of our source into other projects, so we can drop our notices about replacing links with full license text. Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority of the replacements mechanically. Manually fix up shebang lines and trailing newlines in a few files. Manually update the notices in a few files that the script does not handle.
2016-09-27 15:01:08 -04:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#ifndef cmQtAutoGenInitializer_h
#define cmQtAutoGenInitializer_h
#include "cmConfigure.h" // IWYU pragma: keep
#include "cmGeneratedFileStream.h"
#include "cmQtAutoGen.h"
#include <map>
#include <ostream>
#include <set>
#include <string>
#include <vector>
class cmGeneratorTarget;
2018-07-22 16:09:18 +02:00
class cmTarget;
class cmQtAutoGenGlobalInitializer;
/// @brief Initializes the QtAutoGen generators
class cmQtAutoGenInitializer : public cmQtAutoGen
{
public:
/// @brief Rcc job information
class Qrc
{
public:
Qrc() {}
public:
std::string LockFile;
std::string QrcFile;
std::string QrcName;
std::string PathChecksum;
std::string InfoFile;
std::string SettingsFile;
2018-07-22 16:09:18 +02:00
std::map<std::string, std::string> ConfigSettingsFile;
std::string RccFile;
bool Generated = false;
bool Unique = false;
std::vector<std::string> Options;
std::vector<std::string> Resources;
};
/// @brief Writes a CMake info file
class InfoWriter
{
public:
/// @brief Open the given file
InfoWriter(std::string const& filename);
/// @return True if the file is open
2018-11-19 23:35:09 +01:00
explicit operator bool() const { return static_cast<bool>(Ofs_); }
void Write(const char* text) { Ofs_ << text; }
void Write(const char* key, std::string const& value);
void WriteUInt(const char* key, unsigned int value);
template <class C>
void WriteStrings(const char* key, C const& container);
void WriteConfig(const char* key,
std::map<std::string, std::string> const& map);
template <class C>
void WriteConfigStrings(const char* key,
std::map<std::string, C> const& map);
void WriteNestedLists(const char* key,
std::vector<std::vector<std::string>> const& lists);
private:
template <class IT>
static std::string ListJoin(IT it_begin, IT it_end);
static std::string ConfigKey(const char* key, std::string const& config);
private:
cmGeneratedFileStream Ofs_;
};
public:
static IntegerVersion GetQtVersion(cmGeneratorTarget const* target);
cmQtAutoGenInitializer(cmQtAutoGenGlobalInitializer* globalInitializer,
cmGeneratorTarget* target,
IntegerVersion const& qtVersion, bool mocEnabled,
bool uicEnabled, bool rccEnabled,
bool globalAutogenTarget, bool globalAutoRccTarget);
bool InitCustomTargets();
bool SetupCustomTargets();
private:
2018-07-22 16:09:18 +02:00
bool InitMoc();
bool InitUic();
bool InitRcc();
bool InitScanFiles();
bool InitAutogenTarget();
bool InitRccTargets();
bool SetupWriteAutogenInfo();
bool SetupWriteRccInfo();
void AddGeneratedSource(std::string const& filename, GeneratorT genType);
bool GetMocExecutable();
bool GetUicExecutable();
bool GetRccExecutable();
bool RccListInputs(std::string const& fileName,
std::vector<std::string>& files,
std::string& errorMessage);
private:
cmQtAutoGenGlobalInitializer* GlobalInitializer;
cmGeneratorTarget* Target;
// Configuration
IntegerVersion QtVersion;
bool MultiConfig = false;
std::string ConfigDefault;
std::vector<std::string> ConfigsList;
std::string Verbosity;
std::string TargetsFolder;
/// @brief Common directories
struct
{
std::string Info;
std::string Build;
std::string Work;
std::string Include;
std::map<std::string, std::string> ConfigInclude;
} Dir;
/// @brief Autogen target variables
2018-07-22 16:09:18 +02:00
struct
{
std::string Name;
bool GlobalTarget = false;
// Settings
std::string Parallel;
// Configuration files
std::string InfoFile;
std::string SettingsFile;
std::map<std::string, std::string> ConfigSettingsFile;
// Dependencies
bool DependOrigin = false;
std::set<std::string> DependFiles;
std::set<cmTarget*> DependTargets;
// Sources to process
2018-07-22 16:09:18 +02:00
std::vector<std::string> Headers;
std::vector<std::string> Sources;
std::vector<std::string> HeadersGenerated;
std::vector<std::string> SourcesGenerated;
} AutogenTarget;
/// @brief Moc only variables
struct
{
bool Enabled = false;
std::string Executable;
std::string PredefsCmd;
std::set<std::string> Skip;
std::vector<std::string> Includes;
std::map<std::string, std::vector<std::string>> ConfigIncludes;
std::set<std::string> Defines;
std::map<std::string, std::set<std::string>> ConfigDefines;
std::string MocsCompilation;
} Moc;
///@brief Uic only variables
struct
{
bool Enabled = false;
std::string Executable;
std::set<std::string> Skip;
std::vector<std::string> SearchPaths;
std::vector<std::string> Options;
std::map<std::string, std::vector<std::string>> ConfigOptions;
std::vector<std::string> FileFiles;
std::vector<std::vector<std::string>> FileOptions;
} Uic;
/// @brief Rcc only variables
struct
{
bool Enabled = false;
bool GlobalTarget = false;
std::string Executable;
std::vector<std::string> ListOptions;
std::vector<Qrc> Qrcs;
} Rcc;
};
#endif