2017-02-28 11:08:26 +00:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2017-08-26 11:59:57 +00:00
|
|
|
#ifndef cmQtAutoGen_h
|
|
|
|
#define cmQtAutoGen_h
|
2017-02-28 11:08:26 +00:00
|
|
|
|
2017-08-25 18:39:02 +00:00
|
|
|
#include "cmConfigure.h" // IWYU pragma: keep
|
2017-04-11 19:42:35 +00:00
|
|
|
|
2019-08-26 12:47:45 +00:00
|
|
|
#include "cm_string_view.hxx"
|
|
|
|
|
2019-07-10 15:38:48 +00:00
|
|
|
#include <memory>
|
2017-02-28 11:08:26 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2017-08-26 11:59:57 +00:00
|
|
|
/** \class cmQtAutoGen
|
2018-01-03 15:59:40 +00:00
|
|
|
* \brief Common base class for QtAutoGen classes
|
2017-08-26 11:59:57 +00:00
|
|
|
*/
|
|
|
|
class cmQtAutoGen
|
2017-02-28 11:08:26 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-08-13 10:06:19 +00:00
|
|
|
/// @brief Integer version
|
|
|
|
struct IntegerVersion
|
|
|
|
{
|
|
|
|
unsigned int Major = 0;
|
|
|
|
unsigned int Minor = 0;
|
|
|
|
|
|
|
|
IntegerVersion() = default;
|
|
|
|
IntegerVersion(unsigned int major, unsigned int minor)
|
|
|
|
: Major(major)
|
|
|
|
, Minor(minor)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator>(IntegerVersion const version)
|
|
|
|
{
|
|
|
|
return (this->Major > version.Major) ||
|
|
|
|
((this->Major == version.Major) && (this->Minor > version.Minor));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator>=(IntegerVersion const version)
|
|
|
|
{
|
|
|
|
return (this->Major > version.Major) ||
|
|
|
|
((this->Major == version.Major) && (this->Minor >= version.Minor));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-05-22 10:09:31 +00:00
|
|
|
class CompilerFeatures
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool Evaluated = false;
|
|
|
|
std::string HelpOutput;
|
|
|
|
std::vector<std::string> ListOptions;
|
|
|
|
};
|
2019-08-23 21:25:56 +00:00
|
|
|
using CompilerFeaturesHandle = std::shared_ptr<CompilerFeatures>;
|
2019-05-22 10:09:31 +00:00
|
|
|
|
2019-02-21 09:17:52 +00:00
|
|
|
/// @brief AutoGen generator type
|
|
|
|
enum class GenT
|
|
|
|
{
|
|
|
|
GEN, // AUTOGEN
|
|
|
|
MOC, // AUTOMOC
|
|
|
|
UIC, // AUTOUIC
|
|
|
|
RCC // AUTORCC
|
|
|
|
};
|
|
|
|
|
2019-02-14 13:44:18 +00:00
|
|
|
/// @brief Nested lists separator
|
|
|
|
static std::string const ListSep;
|
2019-02-21 09:17:52 +00:00
|
|
|
/// @brief Maximum number of parallel threads/processes in a generator
|
|
|
|
static unsigned int const ParallelMax;
|
2019-02-14 13:44:18 +00:00
|
|
|
|
2017-02-28 11:08:26 +00:00
|
|
|
public:
|
2017-08-26 11:59:57 +00:00
|
|
|
/// @brief Returns the generator name
|
2019-08-26 13:31:55 +00:00
|
|
|
static cm::string_view GeneratorName(GenT genType);
|
2017-08-26 11:59:57 +00:00
|
|
|
/// @brief Returns the generator name in upper case
|
2019-08-26 13:31:55 +00:00
|
|
|
static cm::string_view GeneratorNameUpper(GenT genType);
|
2017-08-26 11:59:57 +00:00
|
|
|
|
2019-01-14 16:33:03 +00:00
|
|
|
/// @brief Returns a string with the requested tool names
|
|
|
|
static std::string Tools(bool moc, bool uic, bool rcc);
|
|
|
|
|
2018-04-22 21:42:51 +00:00
|
|
|
/// @brief Returns the string escaped and enclosed in quotes
|
2019-08-26 12:47:45 +00:00
|
|
|
static std::string Quoted(cm::string_view text);
|
2017-09-12 08:08:10 +00:00
|
|
|
|
2018-01-03 15:59:40 +00:00
|
|
|
static std::string QuotedCommand(std::vector<std::string> const& command);
|
|
|
|
|
2019-09-12 10:14:12 +00:00
|
|
|
/// @brief Returns the parent directory of the file (thread safe)
|
|
|
|
static std::string ParentDir(cm::string_view filename);
|
|
|
|
|
2018-01-03 15:59:40 +00:00
|
|
|
/// @brief Returns the parent directory of the file with a "/" suffix
|
2019-08-26 12:47:45 +00:00
|
|
|
static std::string SubDirPrefix(cm::string_view filename);
|
2018-01-03 15:59:40 +00:00
|
|
|
|
2017-09-12 08:08:10 +00:00
|
|
|
/// @brief Appends the suffix to the filename before the last dot
|
2019-08-26 12:47:45 +00:00
|
|
|
static std::string AppendFilenameSuffix(cm::string_view filename,
|
|
|
|
cm::string_view suffix);
|
2017-03-02 13:06:02 +00:00
|
|
|
|
2017-08-30 21:13:10 +00:00
|
|
|
/// @brief Merges newOpts into baseOpts
|
|
|
|
static void UicMergeOptions(std::vector<std::string>& baseOpts,
|
2017-09-12 08:08:10 +00:00
|
|
|
std::vector<std::string> const& newOpts,
|
2017-08-30 21:13:10 +00:00
|
|
|
bool isQt5);
|
|
|
|
|
|
|
|
/// @brief Merges newOpts into baseOpts
|
|
|
|
static void RccMergeOptions(std::vector<std::string>& baseOpts,
|
2017-09-12 08:08:10 +00:00
|
|
|
std::vector<std::string> const& newOpts,
|
2017-08-30 21:13:10 +00:00
|
|
|
bool isQt5);
|
|
|
|
|
2019-04-05 19:10:53 +00: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
|
|
|
|
std::string const& RccExcutable() const { return RccExcutable_; }
|
|
|
|
void SetRccExecutable(std::string const& rccExecutable)
|
|
|
|
{
|
|
|
|
RccExcutable_ = rccExecutable;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! The rcc executable list options
|
|
|
|
std::vector<std::string> const& ListOptions() const
|
|
|
|
{
|
|
|
|
return ListOptions_;
|
|
|
|
}
|
|
|
|
void SetListOptions(std::vector<std::string> const& listOptions)
|
|
|
|
{
|
|
|
|
ListOptions_ = listOptions;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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_;
|
|
|
|
};
|
2017-02-28 11:08:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|