cmake/Source/cmQtAutoGen.h

159 lines
4.5 KiB
C
Raw Normal View History

2018-01-26 17:06:56 +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
2020-02-01 23:06:01 +01:00
#include <memory>
2018-01-26 17:06:56 +01:00
#include <string>
2024-04-14 22:45:38 +02:00
#include <unordered_map>
2018-01-26 17:06:56 +01:00
#include <vector>
2020-02-01 23:06:01 +01:00
#include <cm/string_view>
2018-01-26 17:06:56 +01:00
/** \class cmQtAutoGen
2018-04-23 21:13:27 +02:00
* \brief Common base class for QtAutoGen classes
2018-01-26 17:06:56 +01:00
*/
class cmQtAutoGen
{
public:
2024-04-14 22:45:38 +02:00
/** String value with per configuration variants. */
class ConfigString
{
public:
std::string Default;
std::unordered_map<std::string, std::string> Config;
};
/** String values with per configuration variants. */
template <typename C>
class ConfigStrings
{
public:
C Default;
std::unordered_map<std::string, C> Config;
};
2020-02-01 23:06:01 +01:00
/** Integer version. */
2018-10-28 12:09:07 +01:00
struct IntegerVersion
{
unsigned int Major = 0;
unsigned int Minor = 0;
IntegerVersion() = default;
IntegerVersion(unsigned int major, unsigned int minor)
: Major(major)
, Minor(minor)
{
}
2021-09-14 00:13:48 +02:00
bool operator>(IntegerVersion const version) const
2018-10-28 12:09:07 +01:00
{
return (this->Major > version.Major) ||
((this->Major == version.Major) && (this->Minor > version.Minor));
}
2021-09-14 00:13:48 +02:00
bool operator>=(IntegerVersion const version) const
2018-10-28 12:09:07 +01:00
{
return (this->Major > version.Major) ||
((this->Major == version.Major) && (this->Minor >= version.Minor));
}
};
2020-02-01 23:06:01 +01:00
/** Compiler features. */
2019-11-11 23:01:05 +01:00
class CompilerFeatures
{
public:
bool Evaluated = false;
std::string HelpOutput;
std::vector<std::string> ListOptions;
};
2020-02-01 23:06:01 +01:00
using CompilerFeaturesHandle = std::shared_ptr<CompilerFeatures>;
2019-11-11 23:01:05 +01:00
2020-02-01 23:06:01 +01:00
/** AutoGen generator type. */
2019-11-11 23:01:05 +01:00
enum class GenT
{
GEN, // AUTOGEN
MOC, // AUTOMOC
UIC, // AUTOUIC
RCC // AUTORCC
};
/// @brief Maximum number of parallel threads/processes in a generator
static unsigned int const ParallelMax;
2018-01-26 17:06:56 +01:00
/// @brief Returns the generator name
2020-02-01 23:06:01 +01:00
static cm::string_view GeneratorName(GenT genType);
2018-01-26 17:06:56 +01:00
/// @brief Returns the generator name in upper case
2020-02-01 23:06:01 +01:00
static cm::string_view GeneratorNameUpper(GenT genType);
2019-11-11 23:01:05 +01:00
/// @brief Returns a string with the requested tool names
static std::string Tools(bool moc, bool uic, bool rcc);
2018-01-26 17:06:56 +01:00
2018-08-09 18:06:22 +02:00
/// @brief Returns the string escaped and enclosed in quotes
2020-02-01 23:06:01 +01:00
static std::string Quoted(cm::string_view text);
2018-01-26 17:06:56 +01:00
2018-04-23 21:13:27 +02:00
static std::string QuotedCommand(std::vector<std::string> const& command);
2020-02-01 23:06:01 +01:00
/// @brief Returns the file name without path and extension (thread safe)
static std::string FileNameWithoutLastExtension(cm::string_view filename);
/// @brief Returns the parent directory of the file (thread safe)
static std::string ParentDir(cm::string_view filename);
2018-04-23 21:13:27 +02:00
/// @brief Returns the parent directory of the file with a "/" suffix
2020-02-01 23:06:01 +01:00
static std::string SubDirPrefix(cm::string_view filename);
2018-04-23 21:13:27 +02:00
2018-01-26 17:06:56 +01:00
/// @brief Appends the suffix to the filename before the last dot
2020-02-01 23:06:01 +01:00
static std::string AppendFilenameSuffix(cm::string_view filename,
cm::string_view suffix);
2018-01-26 17:06:56 +01:00
/// @brief Merges newOpts into baseOpts
static void UicMergeOptions(std::vector<std::string>& baseOpts,
std::vector<std::string> const& newOpts,
2021-11-20 13:41:27 +01:00
bool isQt5OrLater);
2018-01-26 17:06:56 +01:00
/// @brief Merges newOpts into baseOpts
static void RccMergeOptions(std::vector<std::string>& baseOpts,
std::vector<std::string> const& newOpts,
2021-11-20 13:41:27 +01:00
bool isQt5OrLater);
2018-01-26 17:06:56 +01:00
2019-11-11 23:01:05 +01:00
/** @class RccLister
* @brief Lists files in qrc resource files
*/
class RccLister
{
public:
RccLister();
RccLister(std::string rccExecutable, std::vector<std::string> listOptions);
//! The rcc executable
2021-09-14 00:13:48 +02:00
std::string const& RccExcutable() const { return this->RccExcutable_; }
2019-11-11 23:01:05 +01:00
void SetRccExecutable(std::string const& rccExecutable)
{
2021-09-14 00:13:48 +02:00
this->RccExcutable_ = rccExecutable;
2019-11-11 23:01:05 +01:00
}
//! The rcc executable list options
std::vector<std::string> const& ListOptions() const
{
2021-09-14 00:13:48 +02:00
return this->ListOptions_;
2019-11-11 23:01:05 +01:00
}
void SetListOptions(std::vector<std::string> const& listOptions)
{
2021-09-14 00:13:48 +02:00
this->ListOptions_ = listOptions;
2019-11-11 23:01:05 +01:00
}
/**
* @brief Lists a files in the qrcFile
* @arg files The file names are appended to this list
* @arg error contains the error message when the function fails
*/
bool list(std::string const& qrcFile, std::vector<std::string>& files,
std::string& error, bool verbose = false) const;
private:
std::string RccExcutable_;
std::vector<std::string> ListOptions_;
};
2018-01-26 17:06:56 +01:00
};