summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutoGeneratorMocUic.cxx
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2018-01-31 12:54:37 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2018-02-02 08:10:40 (GMT)
commita8ee7406a74cbc4d5e341ad33210b8eeb99af48f (patch)
tree3d13bde5ee4e44cc66eca61faff9007e108f53ad /Source/cmQtAutoGeneratorMocUic.cxx
parent5a16e762e21e22e7a212acc7e2bc7bd027d66166 (diff)
downloadCMake-a8ee7406a74cbc4d5e341ad33210b8eeb99af48f.zip
CMake-a8ee7406a74cbc4d5e341ad33210b8eeb99af48f.tar.gz
CMake-a8ee7406a74cbc4d5e341ad33210b8eeb99af48f.tar.bz2
Autogen: Improved multi-config include scheme
For multi configuration generators AUTOMOC generates the moc files that are included in `mocs_compilation.cpp` in `AUTOGEN_BUILD_DIR/include_$<CONFIG>/`. By doing so each configuration reads different moc files when compiling `mocs_compilation.cpp`. Since we do not (need to) rewrite `mocs_compilation.cpp` on a configuration change anymore, the files also does not need to be recompiled anymore. Not having to rewrite and recompile `mocs_compilation.cpp` on a configuration change anymore was the main objective of this patch. In a similar fashion AUTORCC generates a `qrc_BASE_CMAKE.cpp` file below `AUTOGEN_BUILD_DIR/include_$<CONFIG>/` and `qrc_BASE.cpp` becomes a mere wrapper that includes this actuall rcc output file (when using multi configuration generators). The template files `Modules/AutoRccInfo.cmake.in` and `Modules/AutogenInfo.cmake.in` were removed in favor of writing the info `.cmake` files manually. Closes #17230
Diffstat (limited to 'Source/cmQtAutoGeneratorMocUic.cxx')
-rw-r--r--Source/cmQtAutoGeneratorMocUic.cxx104
1 files changed, 54 insertions, 50 deletions
diff --git a/Source/cmQtAutoGeneratorMocUic.cxx b/Source/cmQtAutoGeneratorMocUic.cxx
index 037279a..6be65ee 100644
--- a/Source/cmQtAutoGeneratorMocUic.cxx
+++ b/Source/cmQtAutoGeneratorMocUic.cxx
@@ -672,19 +672,24 @@ void cmQtAutoGeneratorMocUic::JobMocT::Process(WorkerT& wrk)
{
// Compute build file name
if (!IncludeString.empty()) {
- BuildFile = wrk.Base().AutogenIncludeDirAbs;
+ BuildFile = wrk.Base().AutogenIncludeDir;
+ BuildFile += '/';
BuildFile += IncludeString;
} else {
- std::string buildRel = wrk.Base().FilePathChecksum.getPart(SourceFile);
- buildRel += '/';
- buildRel += "moc_";
- buildRel += cmSystemTools::GetFilenameWithoutLastExtension(SourceFile);
- if (wrk.Base().MultiConfig != MultiConfigT::SINGLE) {
- buildRel += wrk.Base().ConfigSuffix;
+ std::string rel = wrk.Base().FilePathChecksum.getPart(SourceFile);
+ rel += "/moc_";
+ rel += cmSystemTools::GetFilenameWithoutLastExtension(SourceFile);
+ rel += ".cpp";
+ // Register relative file path
+ wrk.Gen().ParallelMocAutoRegister(rel);
+ // Absolute build path
+ if (wrk.Base().MultiConfig) {
+ BuildFile = wrk.Base().AutogenIncludeDir;
+ BuildFile += '/';
+ BuildFile += rel;
+ } else {
+ BuildFile = wrk.Base().AbsoluteBuildPath(rel);
}
- buildRel += ".cpp";
- wrk.Gen().ParallelMocAutoRegister(buildRel);
- BuildFile = wrk.Base().AbsoluteBuildPath(buildRel);
}
if (UpdateRequired(wrk)) {
@@ -871,7 +876,8 @@ void cmQtAutoGeneratorMocUic::JobMocT::GenerateMoc(WorkerT& wrk)
void cmQtAutoGeneratorMocUic::JobUicT::Process(WorkerT& wrk)
{
// Compute build file name
- BuildFile = wrk.Base().AutogenIncludeDirAbs;
+ BuildFile = wrk.Base().AutogenIncludeDir;
+ BuildFile += '/';
BuildFile += IncludeString;
if (UpdateRequired(wrk)) {
@@ -1208,20 +1214,7 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile)
}
// -- Meta
- Base_.MultiConfig = MultiConfigType(InfoGet("AM_MULTI_CONFIG"));
-
- Base_.ConfigSuffix = InfoGetConfig("AM_CONFIG_SUFFIX");
- if (Base_.ConfigSuffix.empty()) {
- Base_.ConfigSuffix = "_";
- Base_.ConfigSuffix += InfoConfig();
- }
-
- SettingsFile_ = InfoGetConfig("AM_SETTINGS_FILE");
- if (SettingsFile_.empty()) {
- Log().ErrorFile(GeneratorT::GEN, InfoFile(), "Settings file name missing");
- return false;
- }
-
+ Base_.MultiConfig = InfoGetBool("AM_MULTI_CONFIG");
{
unsigned long num = Base_.NumThreads;
if (cmSystemTools::StringToULong(InfoGet("AM_PARALLEL"), &num)) {
@@ -1244,6 +1237,23 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile)
"Autogen build directory missing");
return false;
}
+ // include directory
+ {
+ std::string dirRel = InfoGetConfig("AM_INCLUDE_DIR");
+ if (dirRel.empty()) {
+ Log().ErrorFile(GeneratorT::GEN, InfoFile(),
+ "Autogen include directory missing");
+ return false;
+ }
+ Base_.AutogenIncludeDir = Base_.AbsoluteBuildPath(dirRel);
+ }
+
+ // - Files
+ SettingsFile_ = InfoGetConfig("AM_SETTINGS_FILE");
+ if (SettingsFile_.empty()) {
+ Log().ErrorFile(GeneratorT::GEN, InfoFile(), "Settings file name missing");
+ return false;
+ }
// - Qt environment
{
@@ -1438,30 +1448,17 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile)
Base().CurrentSourceDir, Base().CurrentBinaryDir, Base().ProjectSourceDir,
Base().ProjectBinaryDir);
- // include directory
- Base_.AutogenIncludeDirRel = "include";
- if (Base().MultiConfig != MultiConfigT::SINGLE) {
- Base_.AutogenIncludeDirRel += Base().ConfigSuffix;
- }
- Base_.AutogenIncludeDirRel += "/";
- Base_.AutogenIncludeDirAbs =
- Base_.AbsoluteBuildPath(Base().AutogenIncludeDirRel);
-
// Moc variables
if (Moc().Enabled) {
// Mocs compilation file
- Moc_.CompFileRel = "mocs_compilation";
- if (Base_.MultiConfig == MultiConfigT::MULTI) {
- Moc_.CompFileRel += Base().ConfigSuffix;
- }
- Moc_.CompFileRel += ".cpp";
- Moc_.CompFileAbs = Base_.AbsoluteBuildPath(Moc().CompFileRel);
+ Moc_.CompFileAbs = Base().AbsoluteBuildPath("mocs_compilation.cpp");
// Moc predefs file
if (!Moc_.PredefsCmd.empty()) {
Moc_.PredefsFileRel = "moc_predefs";
- if (Base_.MultiConfig != MultiConfigT::SINGLE) {
- Moc_.PredefsFileRel += Base().ConfigSuffix;
+ if (Base_.MultiConfig) {
+ Moc_.PredefsFileRel += '_';
+ Moc_.PredefsFileRel += InfoConfig();
}
Moc_.PredefsFileRel += ".h";
Moc_.PredefsFileAbs = Base_.AbsoluteBuildPath(Moc().PredefsFileRel);
@@ -1731,7 +1728,7 @@ void cmQtAutoGeneratorMocUic::SettingsFileWrite()
void cmQtAutoGeneratorMocUic::CreateDirectories()
{
// Create AUTOGEN include directory
- if (!FileSys().MakeDirectory(GeneratorT::GEN, Base().AutogenIncludeDirAbs)) {
+ if (!FileSys().MakeDirectory(GeneratorT::GEN, Base().AutogenIncludeDir)) {
RegisterJobError();
}
}
@@ -1980,9 +1977,10 @@ void cmQtAutoGeneratorMocUic::ParallelMocAutoUpdated()
void cmQtAutoGeneratorMocUic::MocGenerateCompilation()
{
std::lock_guard<std::mutex> mocLock(JobsMutex_);
- if (!JobThreadsAbort_ && Moc().Enabled) {
- // Compose mocs compilation file content
+ if (!JobError_ && Moc().Enabled) {
+ // Write mocs compilation build file
{
+ // Compose mocs compilation file content
std::string content =
"// This file is autogenerated. Changes will be overwritten.\n";
if (MocAutoFiles_.empty()) {
@@ -1992,19 +1990,22 @@ void cmQtAutoGeneratorMocUic::MocGenerateCompilation()
content += "enum some_compilers { need_more_than_nothing };\n";
} else {
// Valid content
+ char const sbeg = Base().MultiConfig ? '<' : '"';
+ char const send = Base().MultiConfig ? '>' : '"';
for (std::string const& mocfile : MocAutoFiles_) {
- content += "#include \"";
+ content += "#include ";
+ content += sbeg;
content += mocfile;
- content += "\"\n";
+ content += send;
+ content += '\n';
}
}
- std::string const& compRel = Moc().CompFileRel;
std::string const& compAbs = Moc().CompFileAbs;
if (FileSys().FileDiffers(compAbs, content)) {
// Actually write mocs compilation file
if (Log().Verbose()) {
- Log().Info(GeneratorT::MOC, "Generating MOC compilation " + compRel);
+ Log().Info(GeneratorT::MOC, "Generating MOC compilation " + compAbs);
}
if (!FileSys().FileWrite(GeneratorT::MOC, compAbs, content)) {
Log().ErrorFile(GeneratorT::MOC, compAbs,
@@ -2015,10 +2016,13 @@ void cmQtAutoGeneratorMocUic::MocGenerateCompilation()
} else if (MocAutoFileUpdated_) {
// Only touch mocs compilation file
if (Log().Verbose()) {
- Log().Info(GeneratorT::MOC, "Touching mocs compilation " + compRel);
+ Log().Info(GeneratorT::MOC, "Touching mocs compilation " + compAbs);
}
FileSys().Touch(compAbs);
}
}
+ // Write mocs compilation wrapper file
+ if (Base().MultiConfig) {
+ }
}
}