mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-25 01:28:50 -05:00
Autogen: Variable renames and cleanups
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
class cmQtAutoGen
|
||||
{
|
||||
public:
|
||||
/// @brief Integer version
|
||||
/** Integer version. */
|
||||
struct IntegerVersion
|
||||
{
|
||||
unsigned int Major = 0;
|
||||
@@ -43,6 +43,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/** Compiler features. */
|
||||
class CompilerFeatures
|
||||
{
|
||||
public:
|
||||
@@ -52,7 +53,7 @@ public:
|
||||
};
|
||||
using CompilerFeaturesHandle = std::shared_ptr<CompilerFeatures>;
|
||||
|
||||
/// @brief AutoGen generator type
|
||||
/** AutoGen generator type. */
|
||||
enum class GenT
|
||||
{
|
||||
GEN, // AUTOGEN
|
||||
|
||||
@@ -123,7 +123,7 @@ bool StaticLibraryCycle(cmGeneratorTarget const* targetOrigin,
|
||||
return cycle;
|
||||
}
|
||||
|
||||
/** Sanitizes file search paths */
|
||||
/** Sanitizes file search paths. */
|
||||
class SearchPathSanitizer
|
||||
{
|
||||
public:
|
||||
@@ -353,9 +353,6 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
|
||||
|
||||
// Include directory
|
||||
this->Dir.Include = cmStrCat(this->Dir.Build, "/include");
|
||||
if (this->MultiConfig) {
|
||||
this->Dir.Include += "_$<CONFIG>";
|
||||
}
|
||||
// Per config include directories
|
||||
if (this->MultiConfig) {
|
||||
for (std::string const& cfg : this->ConfigsList) {
|
||||
@@ -363,6 +360,10 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
|
||||
dir = cmStrCat(this->Dir.Build, "/include_", cfg);
|
||||
}
|
||||
}
|
||||
this->Dir.IncludeGenExp = this->Dir.Include;
|
||||
if (this->MultiConfig) {
|
||||
this->Dir.IncludeGenExp += "_$<CONFIG>";
|
||||
}
|
||||
}
|
||||
|
||||
// Moc, Uic and _autogen target settings
|
||||
@@ -454,7 +455,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
|
||||
|
||||
// Add autogen include directory to the origin target INCLUDE_DIRECTORIES
|
||||
if (this->MocOrUicEnabled() || (this->Rcc.Enabled && this->MultiConfig)) {
|
||||
this->GenTarget->AddIncludeDirectory(this->Dir.Include, true);
|
||||
this->GenTarget->AddIncludeDirectory(this->Dir.IncludeGenExp, true);
|
||||
}
|
||||
|
||||
// Scan files
|
||||
@@ -889,13 +890,15 @@ bool cmQtAutoGenInitializer::InitScanFiles()
|
||||
{
|
||||
cmFilePathChecksum const fpathCheckSum(this->Makefile);
|
||||
for (Qrc& qrc : this->Rcc.Qrcs) {
|
||||
qrc.PathChecksum = fpathCheckSum.getPart(qrc.QrcFile);
|
||||
// RCC output file name
|
||||
qrc.RccFile = cmStrCat(this->Dir.Build, '/', qrc.PathChecksum, "/qrc_",
|
||||
qrc.QrcName, ".cpp");
|
||||
// Path checksum
|
||||
qrc.QrcPathChecksum = fpathCheckSum.getPart(qrc.QrcFile);
|
||||
// Output file name
|
||||
qrc.OutputFile = cmStrCat(this->Dir.Build, '/', qrc.QrcPathChecksum,
|
||||
"/qrc_", qrc.QrcName, ".cpp");
|
||||
{
|
||||
cm::string_view const baseSuffix =
|
||||
qrc.Unique ? cm::string_view() : cm::string_view(qrc.PathChecksum);
|
||||
cm::string_view const baseSuffix = qrc.Unique
|
||||
? cm::string_view()
|
||||
: cm::string_view(qrc.QrcPathChecksum);
|
||||
std::string const base =
|
||||
cmStrCat(this->Dir.Info, "/RCC", qrc.QrcName, baseSuffix);
|
||||
qrc.LockFile = cmStrCat(base, ".lock");
|
||||
@@ -910,7 +913,7 @@ bool cmQtAutoGenInitializer::InitScanFiles()
|
||||
}
|
||||
}
|
||||
}
|
||||
// RCC options
|
||||
// rcc options
|
||||
for (Qrc& qrc : this->Rcc.Qrcs) {
|
||||
// Target options
|
||||
std::vector<std::string> opts = optionsTarget;
|
||||
@@ -920,7 +923,7 @@ bool cmQtAutoGenInitializer::InitScanFiles()
|
||||
// Replace '-' with '_'. The former is not valid for symbol names.
|
||||
std::replace(name.begin(), name.end(), '-', '_');
|
||||
if (!qrc.Unique) {
|
||||
name += cmStrCat('_', qrc.PathChecksum);
|
||||
name += cmStrCat('_', qrc.QrcPathChecksum);
|
||||
}
|
||||
std::vector<std::string> nameOpts;
|
||||
nameOpts.emplace_back("-name");
|
||||
@@ -931,7 +934,7 @@ bool cmQtAutoGenInitializer::InitScanFiles()
|
||||
RccMergeOptions(opts, qrc.Options, modernQt);
|
||||
qrc.Options = std::move(opts);
|
||||
}
|
||||
// RCC resources
|
||||
// rcc resources
|
||||
for (Qrc& qrc : this->Rcc.Qrcs) {
|
||||
if (!qrc.Generated) {
|
||||
std::string error;
|
||||
@@ -1099,10 +1102,10 @@ bool cmQtAutoGenInitializer::InitRccTargets()
|
||||
// Register info file as generated by CMake
|
||||
this->Makefile->AddCMakeOutputFile(qrc.InfoFile);
|
||||
// Register file at target
|
||||
this->AddGeneratedSource(qrc.RccFile, this->Rcc);
|
||||
this->AddGeneratedSource(qrc.OutputFile, this->Rcc);
|
||||
|
||||
std::vector<std::string> ccOutput;
|
||||
ccOutput.push_back(qrc.RccFile);
|
||||
ccOutput.push_back(qrc.OutputFile);
|
||||
|
||||
std::vector<std::string> ccDepends;
|
||||
// Add the .qrc and info file to the custom command dependencies
|
||||
@@ -1132,7 +1135,7 @@ bool cmQtAutoGenInitializer::InitRccTargets()
|
||||
{
|
||||
ccName = cmStrCat(this->GenTarget->GetName(), "_arcc_", qrc.QrcName);
|
||||
if (!qrc.Unique) {
|
||||
ccName += cmStrCat('_', qrc.PathChecksum);
|
||||
ccName += cmStrCat('_', qrc.QrcPathChecksum);
|
||||
}
|
||||
|
||||
cmTarget* autoRccTarget = this->Makefile->AddUtilityCommand(
|
||||
@@ -1424,9 +1427,9 @@ bool cmQtAutoGenInitializer::SetupWriteRccInfo()
|
||||
ofs.Write("# Rcc job\n");
|
||||
ofs.Write("ARCC_LOCK_FILE", qrc.LockFile);
|
||||
ofs.Write("ARCC_SOURCE", qrc.QrcFile);
|
||||
ofs.Write("ARCC_OUTPUT_CHECKSUM", qrc.PathChecksum);
|
||||
ofs.Write("ARCC_OUTPUT_CHECKSUM", qrc.QrcPathChecksum);
|
||||
ofs.Write("ARCC_OUTPUT_NAME",
|
||||
cmSystemTools::GetFilenameName(qrc.RccFile));
|
||||
cmSystemTools::GetFilenameName(qrc.OutputFile));
|
||||
ofs.WriteStrings("ARCC_OPTIONS", qrc.Options);
|
||||
ofs.WriteStrings("ARCC_INPUTS", qrc.Resources);
|
||||
} else {
|
||||
|
||||
@@ -26,29 +26,31 @@ class cmQtAutoGenGlobalInitializer;
|
||||
class cmSourceFile;
|
||||
class cmTarget;
|
||||
|
||||
/// @brief Initializes the QtAutoGen generators
|
||||
/** \class cmQtAutoGenerator
|
||||
* \brief Initializes the QtAutoGen generators
|
||||
*/
|
||||
class cmQtAutoGenInitializer : public cmQtAutoGen
|
||||
{
|
||||
public:
|
||||
/// @brief Rcc job information
|
||||
/** rcc job. */
|
||||
class Qrc
|
||||
{
|
||||
public:
|
||||
std::string LockFile;
|
||||
std::string QrcFile;
|
||||
std::string QrcName;
|
||||
std::string PathChecksum;
|
||||
std::string QrcPathChecksum;
|
||||
std::string InfoFile;
|
||||
std::string SettingsFile;
|
||||
std::map<std::string, std::string> ConfigSettingsFile;
|
||||
std::string RccFile;
|
||||
std::string OutputFile;
|
||||
bool Generated = false;
|
||||
bool Unique = false;
|
||||
std::vector<std::string> Options;
|
||||
std::vector<std::string> Resources;
|
||||
};
|
||||
|
||||
/// @brief Moc/Uic file
|
||||
/** moc and/or uic file. */
|
||||
struct MUFile
|
||||
{
|
||||
std::string FullPath;
|
||||
@@ -61,7 +63,7 @@ public:
|
||||
};
|
||||
using MUFileHandle = std::unique_ptr<MUFile>;
|
||||
|
||||
/// @brief Abstract moc/uic/rcc generator variables base class
|
||||
/** Abstract moc/uic/rcc generator variables base class */
|
||||
struct GenVarsT
|
||||
{
|
||||
bool Enabled = false;
|
||||
@@ -74,20 +76,19 @@ public:
|
||||
std::string Executable;
|
||||
CompilerFeaturesHandle ExecutableFeatures;
|
||||
|
||||
/// @brief Constructor
|
||||
GenVarsT(GenT gen)
|
||||
: Gen(gen)
|
||||
, GenNameUpper(cmQtAutoGen::GeneratorNameUpper(gen)){};
|
||||
};
|
||||
|
||||
/// @brief Writes a CMake info file
|
||||
/** Writes a CMake info file. */
|
||||
class InfoWriter
|
||||
{
|
||||
public:
|
||||
/// @brief Open the given file
|
||||
/** Open the given file. */
|
||||
InfoWriter(std::string const& filename);
|
||||
|
||||
/// @return True if the file is open
|
||||
/** @return True if the file is open. */
|
||||
explicit operator bool() const { return static_cast<bool>(Ofs_); }
|
||||
|
||||
void Write(cm::string_view text) { Ofs_ << text; }
|
||||
@@ -114,7 +115,7 @@ public:
|
||||
};
|
||||
|
||||
public:
|
||||
/// @return The detected Qt version and the required Qt major version
|
||||
/** @return The detected Qt version and the required Qt major version. */
|
||||
static std::pair<IntegerVersion, unsigned int> GetQtVersion(
|
||||
cmGeneratorTarget const* genTarget);
|
||||
|
||||
@@ -128,7 +129,7 @@ public:
|
||||
bool SetupCustomTargets();
|
||||
|
||||
private:
|
||||
/// @brief If moc or uic is enabled, the autogen target will be generated
|
||||
/** If moc or uic is enabled, the autogen target will be generated. */
|
||||
bool MocOrUicEnabled() const
|
||||
{
|
||||
return (this->Moc.Enabled || this->Uic.Enabled);
|
||||
@@ -162,7 +163,7 @@ private:
|
||||
cmLocalGenerator* LocalGen = nullptr;
|
||||
cmMakefile* Makefile = nullptr;
|
||||
|
||||
// Configuration
|
||||
// -- Configuration
|
||||
IntegerVersion QtVersion;
|
||||
bool MultiConfig = false;
|
||||
std::string ConfigDefault;
|
||||
@@ -172,7 +173,7 @@ private:
|
||||
bool CMP0071Accept = false;
|
||||
bool CMP0071Warn = false;
|
||||
|
||||
/// @brief Common directories
|
||||
/** Common directories. */
|
||||
struct
|
||||
{
|
||||
std::string Info;
|
||||
@@ -180,9 +181,10 @@ private:
|
||||
std::string Work;
|
||||
std::string Include;
|
||||
std::map<std::string, std::string> ConfigInclude;
|
||||
std::string IncludeGenExp;
|
||||
} Dir;
|
||||
|
||||
/// @brief Autogen target variables
|
||||
/** Autogen target variables. */
|
||||
struct
|
||||
{
|
||||
std::string Name;
|
||||
@@ -204,45 +206,42 @@ private:
|
||||
std::vector<MUFile*> FilesGenerated;
|
||||
} AutogenTarget;
|
||||
|
||||
/// @brief Moc only variables
|
||||
/** moc variables. */
|
||||
struct MocT : public GenVarsT
|
||||
{
|
||||
MocT()
|
||||
: GenVarsT(GenT::MOC){};
|
||||
|
||||
std::string PredefsCmd;
|
||||
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;
|
||||
|
||||
/// @brief Constructor
|
||||
MocT()
|
||||
: GenVarsT(GenT::MOC){};
|
||||
} Moc;
|
||||
|
||||
/// @brief Uic only variables
|
||||
/** uic variables. */
|
||||
struct UicT : public GenVarsT
|
||||
{
|
||||
UicT()
|
||||
: GenVarsT(GenT::UIC){};
|
||||
|
||||
std::set<std::string> SkipUi;
|
||||
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;
|
||||
|
||||
/// @brief Constructor
|
||||
UicT()
|
||||
: GenVarsT(GenT::UIC){};
|
||||
} Uic;
|
||||
|
||||
/// @brief Rcc only variables
|
||||
/** rcc variables. */
|
||||
struct RccT : public GenVarsT
|
||||
{
|
||||
bool GlobalTarget = false;
|
||||
std::vector<Qrc> Qrcs;
|
||||
|
||||
/// @brief Constructor
|
||||
RccT()
|
||||
: GenVarsT(GenT::RCC){};
|
||||
|
||||
bool GlobalTarget = false;
|
||||
std::vector<Qrc> Qrcs;
|
||||
} Rcc;
|
||||
};
|
||||
|
||||
|
||||
@@ -78,9 +78,8 @@ public:
|
||||
{
|
||||
public:
|
||||
// -- Types
|
||||
/**
|
||||
* Entry of the file parsing cache
|
||||
*/
|
||||
|
||||
/** Entry of the file parsing cache. */
|
||||
struct FileT
|
||||
{
|
||||
void Clear();
|
||||
|
||||
@@ -14,7 +14,9 @@
|
||||
|
||||
class cmMakefile;
|
||||
|
||||
// @brief AUTORCC generator
|
||||
/** \class cmQtAutoRcc
|
||||
* \brief AUTORCC generator
|
||||
*/
|
||||
class cmQtAutoRcc : public cmQtAutoGenerator
|
||||
{
|
||||
public:
|
||||
|
||||
+4
-4
@@ -1058,18 +1058,18 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args)
|
||||
#ifndef CMAKE_BOOTSTRAP
|
||||
if ((args[1] == "cmake_autogen") && (args.size() >= 4)) {
|
||||
cmQtAutoMocUic autoGen;
|
||||
std::string const& infoDir = args[2];
|
||||
std::string const& infoFile = args[2];
|
||||
std::string const& config = args[3];
|
||||
return autoGen.Run(infoDir, config) ? 0 : 1;
|
||||
return autoGen.Run(infoFile, config) ? 0 : 1;
|
||||
}
|
||||
if ((args[1] == "cmake_autorcc") && (args.size() >= 3)) {
|
||||
cmQtAutoRcc autoGen;
|
||||
cmQtAutoRcc autoRcc;
|
||||
std::string const& infoFile = args[2];
|
||||
std::string config;
|
||||
if (args.size() > 3) {
|
||||
config = args[3];
|
||||
}
|
||||
return autoGen.Run(infoFile, config) ? 0 : 1;
|
||||
return autoRcc.Run(infoFile, config) ? 0 : 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user