CMake/Source/cmQtAutoGen.h
Sebastian Holtermann a008578dee Autogen: Process files concurrently in AUTOMOC and AUTOUIC
This introduces concurrent thread processing in the `_autogen`
target wich processes AUTOMOC and AUTOUIC.
Source file parsing is distributed among the threads by
using a job queue from which the threads pull new parse jobs.
Each thread might start an independent ``moc`` or ``uic`` process.
Altogether this roughly speeds up the AUTOMOC and AUTOUIC build
process by the number of physical CPUs on the host system.

The exact number of threads to start in  the `_autogen` target
is controlled by the new AUTOGEN_PARALLEL target property which
is initialized by the new CMAKE_AUTOGEN_PARALLEL variable.
If AUTOGEN_PARALLEL is empty or unset (which is the default)
the thread count is set to the number of physical CPUs on
the host system.

The AUTOMOC/AUTOUIC generator and the AUTORCC generator are
refactored to use a libuv loop internally.

Closes #17422.
2018-01-17 17:23:49 +01:00

90 lines
3.1 KiB
C++

/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#ifndef cmQtAutoGen_h
#define cmQtAutoGen_h
#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
/** \class cmQtAutoGen
* \brief Common base class for QtAutoGen classes
*/
class cmQtAutoGen
{
public:
/// @brief Nested lists separator
static std::string const ListSep;
/// @brief Maximum number of parallel threads/processes in a generator
static unsigned int const ParallelMax;
/// @brief AutoGen generator type
enum class GeneratorT
{
GEN, // General
MOC,
UIC,
RCC
};
/// @brief Multiconfiguration type
enum class MultiConfigT
{
SINGLE, // Single configuration
WRAPPER, // Multi configuration using wrapper files
MULTI // Multi configuration using per config sources
};
public:
/// @brief Returns the generator name
static std::string const& GeneratorName(GeneratorT genType);
/// @brief Returns the generator name in upper case
static std::string GeneratorNameUpper(GeneratorT genType);
/// @brief Returns the multi configuration name string
static std::string const& MultiConfigName(MultiConfigT config);
/// @brief Returns the multi configuration type
static MultiConfigT MultiConfigType(std::string const& name);
/// @brief Returns a the string escaped and enclosed in quotes
static std::string Quoted(std::string const& text);
static std::string QuotedCommand(std::vector<std::string> const& command);
/// @brief Returns the parent directory of the file with a "/" suffix
static std::string SubDirPrefix(std::string const& filename);
/// @brief Appends the suffix to the filename before the last dot
static std::string AppendFilenameSuffix(std::string const& filename,
std::string const& suffix);
/// @brief Merges newOpts into baseOpts
static void UicMergeOptions(std::vector<std::string>& baseOpts,
std::vector<std::string> const& newOpts,
bool isQt5);
/// @brief Merges newOpts into baseOpts
static void RccMergeOptions(std::vector<std::string>& baseOpts,
std::vector<std::string> const& newOpts,
bool isQt5);
/// @brief Parses the content of a qrc file
///
/// Use when rcc does not support the "--list" option
static void RccListParseContent(std::string const& content,
std::vector<std::string>& files);
/// @brief Parses the output of the "rcc --list ..." command
static bool RccListParseOutput(std::string const& rccStdOut,
std::string const& rccStdErr,
std::vector<std::string>& files,
std::string& error);
/// @brief Converts relative qrc entry paths to full paths
static void RccListConvertFullPath(std::string const& qrcFileDir,
std::vector<std::string>& files);
};
#endif