[Cmake-commits] CMake branch, next, updated. v3.3.2-3306-gdddedd4
Stephen Kelly
steveire at gmail.com
Sat Sep 26 13:38:18 EDT 2015
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via dddedd4a3b7c78c73e595be06f505dbda4b08980 (commit)
via 20077c1be0f45b3b540457358c47dcb6ea00664a (commit)
via 1e83a963d8983f09f5fe6fbf7d268f920b4ed7d0 (commit)
via 12f0e13c5f546a721d893adedba327c18c5c9e5e (commit)
via 65ff75d3f5bf117508ba046779cdad323e077220 (commit)
via 64b78c147fdfa6a9125371c01acfdfce3666c890 (commit)
via c3c20d3ce3acbf6afd6a54dd846fd78b82623312 (commit)
via 8b6ec29d4096b4ea59ef502360845e25a9bcb47e (commit)
via 9470b056fc0be0910f90230e0635d4a2e2baa81a (commit)
via b7491b1cda7096aa914c79a1b2fc7768e90aa951 (commit)
via e791c85419e81b937f0c1215073b2d09ee6c1555 (commit)
via 6210ec644ae3a9e602a24e87d86da7d0b2942d21 (commit)
via a3ceb998d7768592b670abd2a8d0dd2777c84789 (commit)
via dced2fe10f55222ece04c12693d68e13e30771d0 (commit)
via f9a77e76e4e1c19c094ff770487e677a92a1198b (commit)
via c3633e7a416373e6c8e8f87b4920a8a41c5afd82 (commit)
from c645a4f94e9e56130e85cec63b53f656876b173b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dddedd4a3b7c78c73e595be06f505dbda4b08980
commit dddedd4a3b7c78c73e595be06f505dbda4b08980
Merge: c645a4f 20077c1
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Sep 26 13:38:15 2015 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Sat Sep 26 13:38:15 2015 -0400
Merge topic 'simplify-qt-autogen' into next
20077c1b QtAutogen: Split initializer class into separate file.
1e83a963 QtAutogen: Split initializer methods into separate class.
12f0e13c QtAutogen: Simplify generator initialization API.
65ff75d3 QtAutogen: Remove unnecessary dereference.
64b78c14 QtAutogen: Move Source initialization to prior loop.
c3c20d3c QtAutogen: Add _automoc.cpp sources before initializing.
8b6ec29d QtAutogen: Move initialization condition to caller.
9470b056 QtAutogen: Move condition to prior loop.
b7491b1c QtAutogen: Move condition to prior loop.
e791c854 QtAutogen: Make some methods static.
6210ec64 QtAutogen: Make internal method private.
a3ceb998 QtAutogen: Don't use members to initialize automoc targets.
dced2fe1 QtAutogen: Rename variable.
f9a77e76 QtAutogen: Don't use a member to store skipped uic files.
c3633e7a QtAutogen: Add missing includes and forward declarations.
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=20077c1be0f45b3b540457358c47dcb6ea00664a
commit 20077c1be0f45b3b540457358c47dcb6ea00664a
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Sep 26 19:05:00 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Sep 26 19:35:30 2015 +0200
QtAutogen: Split initializer class into separate file.
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index e2a7ff2..ae5b03f 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -327,6 +327,8 @@ set(SRCS
cmPropertyDefinitionMap.h
cmPropertyMap.cxx
cmPropertyMap.h
+ cmQtAutoGeneratorInitializer.cxx
+ cmQtAutoGeneratorInitializer.h
cmQtAutoGenerators.cxx
cmQtAutoGenerators.h
cmRST.cxx
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index a86c91c..540bd01 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -22,7 +22,7 @@
#include "cmake.h"
#include "cmState.h"
#include "cmMakefile.h"
-#include "cmQtAutoGenerators.h"
+#include "cmQtAutoGeneratorInitializer.h"
#include "cmSourceFile.h"
#include "cmVersion.h"
#include "cmTargetExport.h"
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
new file mode 100644
index 0000000..21a1a2c
--- /dev/null
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -0,0 +1,1070 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2004-2011 Kitware, Inc.
+ Copyright 2011 Alexander Neundorf (neundorf at kde.org)
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+
+#include "cmQtAutoGeneratorInitializer.h"
+
+#include "cmLocalGenerator.h"
+#include "cmMakefile.h"
+#include "cmSourceFile.h"
+
+#include <sys/stat.h>
+
+#include <cmsys/FStream.hxx>
+
+std::string cmQtAutoGeneratorInitializer::GetAutogenTargetName(
+ cmTarget const* target)
+{
+ std::string autogenTargetName = target->GetName();
+ autogenTargetName += "_automoc";
+ return autogenTargetName;
+}
+
+std::string cmQtAutoGeneratorInitializer::GetAutogenTargetDir(
+ cmTarget const* target)
+{
+ cmMakefile* makefile = target->GetMakefile();
+ std::string targetDir = makefile->GetCurrentBinaryDirectory();
+ targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory();
+ targetDir += "/";
+ targetDir += cmQtAutoGeneratorInitializer::GetAutogenTargetName(target);
+ targetDir += ".dir/";
+ return targetDir;
+}
+
+static void copyTargetProperty(cmTarget* destinationTarget,
+ cmTarget* sourceTarget,
+ const std::string& propertyName)
+{
+ const char* propertyValue = sourceTarget->GetProperty(propertyName);
+ if (propertyValue)
+ {
+ destinationTarget->SetProperty(propertyName, propertyValue);
+ }
+}
+
+static std::string cmQtAutoGeneratorsStripCR(std::string const& line)
+{
+ // Strip CR characters rcc may have printed (possibly more than one!).
+ std::string::size_type cr = line.find('\r');
+ if (cr != line.npos)
+ {
+ return line.substr(0, cr);
+ }
+ return line;
+}
+
+static std::string ReadAll(const std::string& filename)
+{
+ cmsys::ifstream file(filename.c_str());
+ std::stringstream stream;
+ stream << file.rdbuf();
+ file.close();
+ return stream.str();
+}
+
+std::string cmQtAutoGeneratorInitializer::ListQt5RccInputs(cmSourceFile* sf,
+ cmTarget const* target,
+ std::vector<std::string>& depends)
+{
+ std::string rccCommand
+ = cmQtAutoGeneratorInitializer::GetRccExecutable(target);
+ std::vector<std::string> qrcEntries;
+
+ std::vector<std::string> command;
+ command.push_back(rccCommand);
+ command.push_back("-list");
+
+ std::string absFile = cmsys::SystemTools::GetRealPath(
+ sf->GetFullPath());
+
+ command.push_back(absFile);
+
+ std::string rccStdOut;
+ std::string rccStdErr;
+ int retVal = 0;
+ bool result = cmSystemTools::RunSingleCommand(
+ command, &rccStdOut, &rccStdErr,
+ &retVal, 0, cmSystemTools::OUTPUT_NONE);
+ if (!result || retVal)
+ {
+ std::cerr << "AUTOGEN: error: Rcc list process for " << sf->GetFullPath()
+ << " failed:\n" << rccStdOut << "\n" << rccStdErr << std::endl;
+ return std::string();
+ }
+
+ {
+ std::istringstream ostr(rccStdOut);
+ std::string oline;
+ while(std::getline(ostr, oline))
+ {
+ oline = cmQtAutoGeneratorsStripCR(oline);
+ if(!oline.empty())
+ {
+ qrcEntries.push_back(oline);
+ }
+ }
+ }
+
+ {
+ std::istringstream estr(rccStdErr);
+ std::string eline;
+ while(std::getline(estr, eline))
+ {
+ eline = cmQtAutoGeneratorsStripCR(eline);
+ if (cmHasLiteralPrefix(eline, "RCC: Error in"))
+ {
+ static std::string searchString = "Cannot find file '";
+
+ std::string::size_type pos = eline.find(searchString);
+ if (pos == std::string::npos)
+ {
+ std::cerr << "AUTOGEN: error: Rcc lists unparsable output "
+ << eline << std::endl;
+ return std::string();
+ }
+ pos += searchString.length();
+ std::string::size_type sz = eline.size() - pos - 1;
+ qrcEntries.push_back(eline.substr(pos, sz));
+ }
+ }
+ }
+
+ depends.insert(depends.end(), qrcEntries.begin(), qrcEntries.end());
+ return cmJoin(qrcEntries, "@list_sep@");
+}
+
+std::string cmQtAutoGeneratorInitializer::ListQt4RccInputs(cmSourceFile* sf,
+ std::vector<std::string>& depends)
+{
+ const std::string qrcContents = ReadAll(sf->GetFullPath());
+
+ cmsys::RegularExpression fileMatchRegex("(<file[^<]+)");
+
+ std::string entriesList;
+ const char* sep = "";
+
+ size_t offset = 0;
+ while (fileMatchRegex.find(qrcContents.c_str() + offset))
+ {
+ std::string qrcEntry = fileMatchRegex.match(1);
+
+ offset += qrcEntry.size();
+
+ cmsys::RegularExpression fileReplaceRegex("(^<file[^>]*>)");
+ fileReplaceRegex.find(qrcEntry);
+ std::string tag = fileReplaceRegex.match(1);
+
+ qrcEntry = qrcEntry.substr(tag.size());
+
+ if (!cmSystemTools::FileIsFullPath(qrcEntry.c_str()))
+ {
+ qrcEntry = sf->GetLocation().GetDirectory() + "/" + qrcEntry;
+ }
+
+ entriesList += sep;
+ entriesList += qrcEntry;
+ sep = "@list_sep@";
+ depends.push_back(qrcEntry);
+ }
+ return entriesList;
+}
+
+
+void cmQtAutoGeneratorInitializer::InitializeAutogenSources(cmTarget* target)
+{
+ cmMakefile* makefile = target->GetMakefile();
+
+ if (target->GetPropertyAsBool("AUTOMOC"))
+ {
+ std::string automocTargetName =
+ cmQtAutoGeneratorInitializer::GetAutogenTargetName(target);
+ std::string mocCppFile = makefile->GetCurrentBinaryDirectory();
+ mocCppFile += "/";
+ mocCppFile += automocTargetName;
+ mocCppFile += ".cpp";
+ makefile->GetOrCreateSource(mocCppFile, true);
+ makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
+ mocCppFile.c_str(), false);
+
+ target->AddSource(mocCppFile);
+ }
+}
+
+void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
+ cmLocalGenerator* lg,
+ cmTarget* target)
+{
+ cmMakefile* makefile = target->GetMakefile();
+
+ std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR");
+ if (qtMajorVersion == "")
+ {
+ qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR");
+ }
+
+ // create a custom target for running generators at buildtime:
+ std::string autogenTargetName =
+ cmQtAutoGeneratorInitializer::GetAutogenTargetName(target);
+
+ std::string targetDir =
+ cmQtAutoGeneratorInitializer::GetAutogenTargetDir(target);
+
+ cmCustomCommandLine currentLine;
+ currentLine.push_back(cmSystemTools::GetCMakeCommand());
+ currentLine.push_back("-E");
+ currentLine.push_back("cmake_autogen");
+ currentLine.push_back(targetDir);
+ currentLine.push_back("$<CONFIGURATION>");
+
+ cmCustomCommandLines commandLines;
+ commandLines.push_back(currentLine);
+
+ std::string workingDirectory = cmSystemTools::CollapseFullPath(
+ "", makefile->GetCurrentBinaryDirectory());
+
+ std::vector<std::string> depends;
+ if (const char *autogenDepends =
+ target->GetProperty("AUTOGEN_TARGET_DEPENDS"))
+ {
+ cmSystemTools::ExpandListArgument(autogenDepends, depends);
+ }
+ std::vector<std::string> toolNames;
+ if (target->GetPropertyAsBool("AUTOMOC"))
+ {
+ toolNames.push_back("moc");
+ }
+ if (target->GetPropertyAsBool("AUTOUIC"))
+ {
+ toolNames.push_back("uic");
+ }
+ if (target->GetPropertyAsBool("AUTORCC"))
+ {
+ toolNames.push_back("rcc");
+ }
+
+ std::string tools = toolNames[0];
+ toolNames.erase(toolNames.begin());
+ while (toolNames.size() > 1)
+ {
+ tools += ", " + toolNames[0];
+ toolNames.erase(toolNames.begin());
+ }
+ if (toolNames.size() == 1)
+ {
+ tools += " and " + toolNames[0];
+ }
+ std::string autogenComment = "Automatic " + tools + " for target ";
+ autogenComment += target->GetName();
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ bool usePRE_BUILD = false;
+ cmGlobalGenerator* gg = lg->GetGlobalGenerator();
+ if(gg->GetName().find("Visual Studio") != std::string::npos)
+ {
+ cmGlobalVisualStudioGenerator* vsgg =
+ static_cast<cmGlobalVisualStudioGenerator*>(gg);
+ // Under VS >= 7 use a PRE_BUILD event instead of a separate target to
+ // reduce the number of targets loaded into the IDE.
+ // This also works around a VS 11 bug that may skip updating the target:
+ // https://connect.microsoft.com/VisualStudio/feedback/details/769495
+ usePRE_BUILD = vsgg->GetVersion() >= cmGlobalVisualStudioGenerator::VS7;
+ if(usePRE_BUILD)
+ {
+ for (std::vector<std::string>::iterator it = depends.begin();
+ it != depends.end(); ++it)
+ {
+ if(!makefile->FindTargetToUse(it->c_str()))
+ {
+ usePRE_BUILD = false;
+ break;
+ }
+ }
+ }
+ }
+#endif
+
+ std::vector<std::string> rcc_output;
+ bool const isNinja =
+ lg->GetGlobalGenerator()->GetName() == "Ninja";
+ if(isNinja
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ || usePRE_BUILD
+#endif
+ )
+ {
+ std::vector<cmSourceFile*> srcFiles;
+ cmGeneratorTarget* gtgt =
+ lg->GetGlobalGenerator()->GetGeneratorTarget(target);
+ gtgt->GetConfigCommonSourceFiles(srcFiles);
+ for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
+ fileIt != srcFiles.end();
+ ++fileIt)
+ {
+ cmSourceFile* sf = *fileIt;
+ std::string absFile = cmsys::SystemTools::GetRealPath(
+ sf->GetFullPath());
+
+ std::string ext = sf->GetExtension();
+
+ if (target->GetPropertyAsBool("AUTORCC"))
+ {
+ if (ext == "qrc"
+ && !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")))
+ {
+ std::string basename = cmsys::SystemTools::
+ GetFilenameWithoutLastExtension(absFile);
+
+ std::string rcc_output_dir = target->GetSupportDirectory();
+ cmSystemTools::MakeDirectory(rcc_output_dir.c_str());
+ std::string rcc_output_file = rcc_output_dir;
+ rcc_output_file += "/qrc_" + basename + ".cpp";
+ rcc_output.push_back(rcc_output_file);
+
+ if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED")))
+ {
+ if (qtMajorVersion == "5")
+ {
+ cmQtAutoGeneratorInitializer::ListQt5RccInputs(sf, target,
+ depends);
+ }
+ else
+ {
+ cmQtAutoGeneratorInitializer::ListQt4RccInputs(sf, depends);
+ }
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ // Cannot use PRE_BUILD because the resource files themselves
+ // may not be sources within the target so VS may not know the
+ // target needs to re-build at all.
+ usePRE_BUILD = false;
+#endif
+ }
+ }
+ }
+ }
+ }
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ if(usePRE_BUILD)
+ {
+ // Add the pre-build command directly to bypass the OBJECT_LIBRARY
+ // rejection in cmMakefile::AddCustomCommandToTarget because we know
+ // PRE_BUILD will work for an OBJECT_LIBRARY in this specific case.
+ std::vector<std::string> no_output;
+ std::vector<std::string> no_byproducts;
+ cmCustomCommand cc(makefile, no_output, no_byproducts, depends,
+ commandLines, autogenComment.c_str(),
+ workingDirectory.c_str());
+ cc.SetEscapeOldStyle(false);
+ cc.SetEscapeAllowMakeVars(true);
+ target->AddPreBuildCommand(cc);
+ }
+ else
+#endif
+ {
+ cmTarget* autogenTarget = makefile->AddUtilityCommand(
+ autogenTargetName, true,
+ workingDirectory.c_str(),
+ /*byproducts=*/rcc_output, depends,
+ commandLines, false, autogenComment.c_str());
+
+ cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg);
+ makefile->AddGeneratorTarget(autogenTarget, gt);
+
+ // Set target folder
+ const char* autogenFolder = makefile->GetState()
+ ->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER");
+ if (!autogenFolder)
+ {
+ autogenFolder = makefile->GetState()
+ ->GetGlobalProperty("AUTOGEN_TARGETS_FOLDER");
+ }
+ if (autogenFolder && *autogenFolder)
+ {
+ autogenTarget->SetProperty("FOLDER", autogenFolder);
+ }
+ else
+ {
+ // inherit FOLDER property from target (#13688)
+ copyTargetProperty(autogenTarget, target, "FOLDER");
+ }
+
+ target->AddUtility(autogenTargetName);
+ }
+}
+
+static void GetCompileDefinitionsAndDirectories(cmTarget const* target,
+ const std::string& config,
+ std::string &incs,
+ std::string &defs)
+{
+ cmMakefile* makefile = target->GetMakefile();
+ cmGlobalGenerator* globalGen = makefile->GetGlobalGenerator();
+ std::vector<std::string> includeDirs;
+ cmGeneratorTarget *gtgt = globalGen->GetGeneratorTarget(target);
+ cmLocalGenerator *localGen = gtgt->GetLocalGenerator();
+ // Get the include dirs for this target, without stripping the implicit
+ // include dirs off, see http://public.kitware.com/Bug/view.php?id=13667
+ localGen->GetIncludeDirectories(includeDirs, gtgt, "CXX", config, false);
+
+ incs = cmJoin(includeDirs, ";");
+
+ std::set<std::string> defines;
+ localGen->AddCompileDefinitions(defines, target, config, "CXX");
+
+ defs += cmJoin(defines, ";");
+}
+
+void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(
+ cmTarget const* target)
+{
+ cmMakefile* makefile = target->GetMakefile();
+
+ // forget the variables added here afterwards again:
+ cmMakefile::ScopePushPop varScope(makefile);
+ static_cast<void>(varScope);
+
+ // create a custom target for running generators at buildtime:
+ std::string autogenTargetName =
+ cmQtAutoGeneratorInitializer::GetAutogenTargetName(target);
+
+ makefile->AddDefinition("_moc_target_name",
+ cmOutputConverter::EscapeForCMake(autogenTargetName).c_str());
+ makefile->AddDefinition("_origin_target_name",
+ cmOutputConverter::EscapeForCMake(target->GetName()).c_str());
+
+ std::string targetDir =
+ cmQtAutoGeneratorInitializer::GetAutogenTargetDir(target);
+
+ const char *qtVersion = makefile->GetDefinition("Qt5Core_VERSION_MAJOR");
+ if (!qtVersion)
+ {
+ qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR");
+ }
+ cmGeneratorTarget *gtgt = target->GetMakefile()
+ ->GetGlobalGenerator()
+ ->GetGeneratorTarget(target);
+ if (const char *targetQtVersion =
+ gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", ""))
+ {
+ qtVersion = targetQtVersion;
+ }
+ if (qtVersion)
+ {
+ makefile->AddDefinition("_target_qt_version", qtVersion);
+ }
+
+ std::vector<std::string> skipUic;
+ std::vector<std::string> skipMoc;
+ std::vector<std::string> mocSources;
+ std::vector<std::string> mocHeaders;
+ std::map<std::string, std::string> configIncludes;
+ std::map<std::string, std::string> configDefines;
+ std::map<std::string, std::string> configUicOptions;
+
+ if (target->GetPropertyAsBool("AUTOMOC")
+ || target->GetPropertyAsBool("AUTOUIC")
+ || target->GetPropertyAsBool("AUTORCC"))
+ {
+ cmQtAutoGeneratorInitializer::SetupSourceFiles(target, skipMoc,
+ mocSources, mocHeaders, skipUic);
+ }
+ makefile->AddDefinition("_cpp_files",
+ cmOutputConverter::EscapeForCMake(cmJoin(mocSources, ";")).c_str());
+ if (target->GetPropertyAsBool("AUTOMOC"))
+ {
+ cmQtAutoGeneratorInitializer::SetupAutoMocTarget(target, autogenTargetName,
+ skipMoc, mocHeaders,
+ configIncludes, configDefines);
+ }
+ if (target->GetPropertyAsBool("AUTOUIC"))
+ {
+ cmQtAutoGeneratorInitializer::SetupAutoUicTarget(target, skipUic,
+ configUicOptions);
+ }
+ if (target->GetPropertyAsBool("AUTORCC"))
+ {
+ cmQtAutoGeneratorInitializer::SetupAutoRccTarget(target);
+ }
+
+ const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT");
+ std::string inputFile = cmakeRoot;
+ inputFile += "/Modules/AutogenInfo.cmake.in";
+ std::string outputFile = targetDir;
+ outputFile += "/AutogenInfo.cmake";
+ makefile->AddDefinition("_qt_rcc_inputs",
+ makefile->GetDefinition("_qt_rcc_inputs_" + target->GetName()));
+ makefile->ConfigureFile(inputFile.c_str(), outputFile.c_str(),
+ false, true, false);
+
+ // Ensure we have write permission in case .in was read-only.
+ mode_t perm = 0;
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ mode_t mode_write = S_IWRITE;
+#else
+ mode_t mode_write = S_IWUSR;
+#endif
+ cmSystemTools::GetPermissions(outputFile, perm);
+ if (!(perm & mode_write))
+ {
+ cmSystemTools::SetPermissions(outputFile, perm | mode_write);
+ }
+ if (!configDefines.empty()
+ || !configIncludes.empty()
+ || !configUicOptions.empty())
+ {
+ cmsys::ofstream infoFile(outputFile.c_str(), std::ios::app);
+ if ( !infoFile )
+ {
+ std::string error = "Internal CMake error when trying to open file: ";
+ error += outputFile.c_str();
+ error += " for writing.";
+ cmSystemTools::Error(error.c_str());
+ return;
+ }
+ if (!configDefines.empty())
+ {
+ for (std::map<std::string, std::string>::iterator
+ it = configDefines.begin(), end = configDefines.end();
+ it != end; ++it)
+ {
+ infoFile << "set(AM_MOC_COMPILE_DEFINITIONS_" << it->first <<
+ " " << it->second << ")\n";
+ }
+ }
+ if (!configIncludes.empty())
+ {
+ for (std::map<std::string, std::string>::iterator
+ it = configIncludes.begin(), end = configIncludes.end();
+ it != end; ++it)
+ {
+ infoFile << "set(AM_MOC_INCLUDES_" << it->first <<
+ " " << it->second << ")\n";
+ }
+ }
+ if (!configUicOptions.empty())
+ {
+ for (std::map<std::string, std::string>::iterator
+ it = configUicOptions.begin(), end = configUicOptions.end();
+ it != end; ++it)
+ {
+ infoFile << "set(AM_UIC_TARGET_OPTIONS_" << it->first <<
+ " " << it->second << ")\n";
+ }
+ }
+ }
+}
+
+void cmQtAutoGeneratorInitializer::SetupSourceFiles(cmTarget const* target,
+ std::vector<std::string>& skipMoc,
+ std::vector<std::string>& mocSources,
+ std::vector<std::string>& mocHeaders,
+ std::vector<std::string>& skipUic)
+{
+ cmMakefile* makefile = target->GetMakefile();
+
+ std::vector<cmSourceFile*> srcFiles;
+ cmGeneratorTarget *gtgt = target->GetMakefile()
+ ->GetGlobalGenerator()
+ ->GetGeneratorTarget(target);
+ gtgt->GetConfigCommonSourceFiles(srcFiles);
+
+ std::vector<std::string> newRccFiles;
+
+ for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
+ fileIt != srcFiles.end();
+ ++fileIt)
+ {
+ cmSourceFile* sf = *fileIt;
+ std::string absFile = cmsys::SystemTools::GetRealPath(
+ sf->GetFullPath());
+ bool skipFileForMoc =
+ cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC"));
+ bool generated = cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"));
+
+ if(cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOUIC")))
+ {
+ skipUic.push_back(absFile);
+ }
+
+ std::string ext = sf->GetExtension();
+
+ if (target->GetPropertyAsBool("AUTORCC"))
+ {
+ if (ext == "qrc"
+ && !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")))
+ {
+ std::string basename = cmsys::SystemTools::
+ GetFilenameWithoutLastExtension(absFile);
+
+ std::string rcc_output_dir = target->GetSupportDirectory();
+ cmSystemTools::MakeDirectory(rcc_output_dir.c_str());
+ std::string rcc_output_file = rcc_output_dir;
+ rcc_output_file += "/qrc_" + basename + ".cpp";
+ makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
+ rcc_output_file.c_str(), false);
+ makefile->GetOrCreateSource(rcc_output_file, true);
+ newRccFiles.push_back(rcc_output_file);
+ }
+ }
+
+ if (!generated)
+ {
+ if (skipFileForMoc)
+ {
+ skipMoc.push_back(absFile);
+ }
+ else
+ {
+ cmSystemTools::FileFormat fileType = cmSystemTools::GetFileFormat(
+ ext.c_str());
+ if (fileType == cmSystemTools::CXX_FILE_FORMAT)
+ {
+ mocSources.push_back(absFile);
+ }
+ else if (fileType == cmSystemTools::HEADER_FILE_FORMAT)
+ {
+ mocHeaders.push_back(absFile);
+ }
+ }
+ }
+ }
+
+ for(std::vector<std::string>::const_iterator fileIt = newRccFiles.begin();
+ fileIt != newRccFiles.end();
+ ++fileIt)
+ {
+ const_cast<cmTarget*>(target)->AddSource(*fileIt);
+ }
+}
+
+void cmQtAutoGeneratorInitializer::SetupAutoMocTarget(cmTarget const* target,
+ const std::string &autogenTargetName,
+ std::vector<std::string> const& skipMoc,
+ std::vector<std::string> const& mocHeaders,
+ std::map<std::string, std::string> &configIncludes,
+ std::map<std::string, std::string> &configDefines)
+{
+ cmMakefile* makefile = target->GetMakefile();
+
+ const char* tmp = target->GetProperty("AUTOMOC_MOC_OPTIONS");
+ std::string _moc_options = (tmp!=0 ? tmp : "");
+ makefile->AddDefinition("_moc_options",
+ cmOutputConverter::EscapeForCMake(_moc_options).c_str());
+ makefile->AddDefinition("_skip_moc",
+ cmOutputConverter::EscapeForCMake(cmJoin(skipMoc, ";")).c_str());
+ makefile->AddDefinition("_moc_headers",
+ cmOutputConverter::EscapeForCMake(cmJoin(mocHeaders, ";")).c_str());
+ bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE");
+ makefile->AddDefinition("_moc_relaxed_mode", relaxedMode ? "TRUE" : "FALSE");
+
+ std::string _moc_incs;
+ std::string _moc_compile_defs;
+ std::vector<std::string> configs;
+ const std::string& config = makefile->GetConfigurations(configs);
+ GetCompileDefinitionsAndDirectories(target, config,
+ _moc_incs, _moc_compile_defs);
+
+ makefile->AddDefinition("_moc_incs",
+ cmOutputConverter::EscapeForCMake(_moc_incs).c_str());
+ makefile->AddDefinition("_moc_compile_defs",
+ cmOutputConverter::EscapeForCMake(_moc_compile_defs).c_str());
+
+ for (std::vector<std::string>::const_iterator li = configs.begin();
+ li != configs.end(); ++li)
+ {
+ std::string config_moc_incs;
+ std::string config_moc_compile_defs;
+ GetCompileDefinitionsAndDirectories(target, *li,
+ config_moc_incs,
+ config_moc_compile_defs);
+ if (config_moc_incs != _moc_incs)
+ {
+ configIncludes[*li] =
+ cmOutputConverter::EscapeForCMake(config_moc_incs);
+ if(_moc_incs.empty())
+ {
+ _moc_incs = config_moc_incs;
+ }
+ }
+ if (config_moc_compile_defs != _moc_compile_defs)
+ {
+ configDefines[*li] =
+ cmOutputConverter::EscapeForCMake(config_moc_compile_defs);
+ if(_moc_compile_defs.empty())
+ {
+ _moc_compile_defs = config_moc_compile_defs;
+ }
+ }
+ }
+
+ const char *qtVersion = makefile->GetDefinition("_target_qt_version");
+ if (strcmp(qtVersion, "5") == 0)
+ {
+ cmTarget *qt5Moc = makefile->FindTargetToUse("Qt5::moc");
+ if (!qt5Moc)
+ {
+ cmSystemTools::Error("Qt5::moc target not found ",
+ autogenTargetName.c_str());
+ return;
+ }
+ makefile->AddDefinition("_qt_moc_executable",
+ qt5Moc->ImportedGetLocation(""));
+ }
+ else if (strcmp(qtVersion, "4") == 0)
+ {
+ cmTarget *qt4Moc = makefile->FindTargetToUse("Qt4::moc");
+ if (!qt4Moc)
+ {
+ cmSystemTools::Error("Qt4::moc target not found ",
+ autogenTargetName.c_str());
+ return;
+ }
+ makefile->AddDefinition("_qt_moc_executable",
+ qt4Moc->ImportedGetLocation(""));
+ }
+ else
+ {
+ cmSystemTools::Error("The CMAKE_AUTOMOC feature supports only Qt 4 and "
+ "Qt 5 ", autogenTargetName.c_str());
+ }
+}
+
+static void GetUicOpts(cmTarget const* target, const std::string& config,
+ std::string &optString)
+{
+ cmGeneratorTarget *gtgt = target->GetMakefile()
+ ->GetGlobalGenerator()
+ ->GetGeneratorTarget(target);
+ std::vector<std::string> opts;
+ gtgt->GetAutoUicOptions(opts, config);
+ optString = cmJoin(opts, ";");
+}
+
+void cmQtAutoGeneratorInitializer::SetupAutoUicTarget(cmTarget const* target,
+ std::vector<std::string> const& skipUic,
+ std::map<std::string, std::string> &configUicOptions)
+{
+ cmMakefile *makefile = target->GetMakefile();
+
+ std::set<std::string> skipped;
+ skipped.insert(skipUic.begin(), skipUic.end());
+
+ makefile->AddDefinition("_skip_uic",
+ cmOutputConverter::EscapeForCMake(cmJoin(skipUic, ";")).c_str());
+
+ std::vector<cmSourceFile*> uiFilesWithOptions
+ = makefile->GetQtUiFilesWithOptions();
+
+ const char *qtVersion = makefile->GetDefinition("_target_qt_version");
+
+ std::string _uic_opts;
+ std::vector<std::string> configs;
+ const std::string& config = makefile->GetConfigurations(configs);
+ GetUicOpts(target, config, _uic_opts);
+
+ if (!_uic_opts.empty())
+ {
+ _uic_opts = cmOutputConverter::EscapeForCMake(_uic_opts);
+ makefile->AddDefinition("_uic_target_options", _uic_opts.c_str());
+ }
+ for (std::vector<std::string>::const_iterator li = configs.begin();
+ li != configs.end(); ++li)
+ {
+ std::string config_uic_opts;
+ GetUicOpts(target, *li, config_uic_opts);
+ if (config_uic_opts != _uic_opts)
+ {
+ configUicOptions[*li] =
+ cmOutputConverter::EscapeForCMake(config_uic_opts);
+ if(_uic_opts.empty())
+ {
+ _uic_opts = config_uic_opts;
+ }
+ }
+ }
+
+ std::string uiFileFiles;
+ std::string uiFileOptions;
+ const char* sep = "";
+
+ for(std::vector<cmSourceFile*>::const_iterator fileIt =
+ uiFilesWithOptions.begin();
+ fileIt != uiFilesWithOptions.end();
+ ++fileIt)
+ {
+ cmSourceFile* sf = *fileIt;
+ std::string absFile = cmsys::SystemTools::GetRealPath(
+ sf->GetFullPath());
+
+ if (!skipped.insert(absFile).second)
+ {
+ continue;
+ }
+ uiFileFiles += sep;
+ uiFileFiles += absFile;
+ uiFileOptions += sep;
+ std::string opts = sf->GetProperty("AUTOUIC_OPTIONS");
+ cmSystemTools::ReplaceString(opts, ";", "@list_sep@");
+ uiFileOptions += opts;
+ sep = ";";
+ }
+
+ makefile->AddDefinition("_qt_uic_options_files",
+ cmOutputConverter::EscapeForCMake(uiFileFiles).c_str());
+ makefile->AddDefinition("_qt_uic_options_options",
+ cmOutputConverter::EscapeForCMake(uiFileOptions).c_str());
+
+ std::string targetName = target->GetName();
+ if (strcmp(qtVersion, "5") == 0)
+ {
+ cmTarget *qt5Uic = makefile->FindTargetToUse("Qt5::uic");
+ if (!qt5Uic)
+ {
+ // Project does not use Qt5Widgets, but has AUTOUIC ON anyway
+ }
+ else
+ {
+ makefile->AddDefinition("_qt_uic_executable",
+ qt5Uic->ImportedGetLocation(""));
+ }
+ }
+ else if (strcmp(qtVersion, "4") == 0)
+ {
+ cmTarget *qt4Uic = makefile->FindTargetToUse("Qt4::uic");
+ if (!qt4Uic)
+ {
+ cmSystemTools::Error("Qt4::uic target not found ",
+ targetName.c_str());
+ return;
+ }
+ makefile->AddDefinition("_qt_uic_executable",
+ qt4Uic->ImportedGetLocation(""));
+ }
+ else
+ {
+ cmSystemTools::Error("The CMAKE_AUTOUIC feature supports only Qt 4 and "
+ "Qt 5 ", targetName.c_str());
+ }
+}
+
+void cmQtAutoGeneratorInitializer::MergeRccOptions(
+ std::vector<std::string> &opts,
+ const std::vector<std::string> &fileOpts,
+ bool isQt5)
+{
+ static const char* valueOptions[] = {
+ "name",
+ "root",
+ "compress",
+ "threshold"
+ };
+ std::vector<std::string> extraOpts;
+ for(std::vector<std::string>::const_iterator it = fileOpts.begin();
+ it != fileOpts.end(); ++it)
+ {
+ std::vector<std::string>::iterator existingIt
+ = std::find(opts.begin(), opts.end(), *it);
+ if (existingIt != opts.end())
+ {
+ const char *o = it->c_str();
+ if (*o == '-')
+ {
+ ++o;
+ }
+ if (isQt5 && *o == '-')
+ {
+ ++o;
+ }
+ if (std::find_if(cmArrayBegin(valueOptions), cmArrayEnd(valueOptions),
+ cmStrCmp(*it)) != cmArrayEnd(valueOptions))
+ {
+ assert(existingIt + 1 != opts.end());
+ *(existingIt + 1) = *(it + 1);
+ ++it;
+ }
+ }
+ else
+ {
+ extraOpts.push_back(*it);
+ }
+ }
+ opts.insert(opts.end(), extraOpts.begin(), extraOpts.end());
+}
+
+void cmQtAutoGeneratorInitializer::SetupAutoRccTarget(cmTarget const* target)
+{
+ std::string _rcc_files;
+ const char* sepRccFiles = "";
+ cmMakefile *makefile = target->GetMakefile();
+
+ std::vector<cmSourceFile*> srcFiles;
+ cmGeneratorTarget *gtgt = target->GetMakefile()
+ ->GetGlobalGenerator()
+ ->GetGeneratorTarget(target);
+ gtgt->GetConfigCommonSourceFiles(srcFiles);
+
+ std::string qrcInputs;
+ const char* qrcInputsSep = "";
+
+ std::string rccFileFiles;
+ std::string rccFileOptions;
+ const char *optionSep = "";
+
+ const char *qtVersion = makefile->GetDefinition("_target_qt_version");
+
+ std::vector<std::string> rccOptions;
+ if (const char* opts = target->GetProperty("AUTORCC_OPTIONS"))
+ {
+ cmSystemTools::ExpandListArgument(opts, rccOptions);
+ }
+ std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR");
+ if (qtMajorVersion == "")
+ {
+ qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR");
+ }
+
+ for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
+ fileIt != srcFiles.end();
+ ++fileIt)
+ {
+ cmSourceFile* sf = *fileIt;
+ std::string ext = sf->GetExtension();
+ if (ext == "qrc")
+ {
+ std::string absFile = cmsys::SystemTools::GetRealPath(
+ sf->GetFullPath());
+ bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC"));
+
+ if (!skip)
+ {
+ _rcc_files += sepRccFiles;
+ _rcc_files += absFile;
+ sepRccFiles = ";";
+
+ if (const char *prop = sf->GetProperty("AUTORCC_OPTIONS"))
+ {
+ std::vector<std::string> optsVec;
+ cmSystemTools::ExpandListArgument(prop, optsVec);
+ cmQtAutoGeneratorInitializer::MergeRccOptions(rccOptions, optsVec,
+ strcmp(qtVersion, "5") == 0);
+ }
+
+ if (!rccOptions.empty())
+ {
+ rccFileFiles += optionSep;
+ rccFileFiles += absFile;
+ rccFileOptions += optionSep;
+ }
+ const char *listSep = "";
+ for(std::vector<std::string>::const_iterator it = rccOptions.begin();
+ it != rccOptions.end();
+ ++it)
+ {
+ rccFileOptions += listSep;
+ rccFileOptions += *it;
+ listSep = "@list_sep@";
+ }
+ optionSep = ";";
+
+ std::vector<std::string> depends;
+
+ std::string entriesList;
+ if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED")))
+ {
+ if (qtMajorVersion == "5")
+ {
+ entriesList = cmQtAutoGeneratorInitializer::ListQt5RccInputs(sf,
+ target,
+ depends);
+ }
+ else
+ {
+ entriesList =
+ cmQtAutoGeneratorInitializer::ListQt4RccInputs(sf, depends);
+ }
+ if (entriesList.empty())
+ {
+ return;
+ }
+ }
+ qrcInputs += qrcInputsSep;
+ qrcInputs += entriesList;
+ qrcInputsSep = ";";
+ }
+ }
+ }
+ makefile->AddDefinition("_qt_rcc_inputs_" + target->GetName(),
+ cmOutputConverter::EscapeForCMake(qrcInputs).c_str());
+
+ makefile->AddDefinition("_rcc_files",
+ cmOutputConverter::EscapeForCMake(_rcc_files).c_str());
+
+ makefile->AddDefinition("_qt_rcc_options_files",
+ cmOutputConverter::EscapeForCMake(rccFileFiles).c_str());
+ makefile->AddDefinition("_qt_rcc_options_options",
+ cmOutputConverter::EscapeForCMake(rccFileOptions).c_str());
+
+ makefile->AddDefinition("_qt_rcc_executable",
+ cmQtAutoGeneratorInitializer::GetRccExecutable(target).c_str());
+}
+
+std::string cmQtAutoGeneratorInitializer::GetRccExecutable(
+ cmTarget const* target)
+{
+ cmGeneratorTarget *gtgt = target->GetMakefile()
+ ->GetGlobalGenerator()
+ ->GetGeneratorTarget(target);
+ cmMakefile *makefile = target->GetMakefile();
+ const char *qtVersion = makefile->GetDefinition("_target_qt_version");
+ if (!qtVersion)
+ {
+ qtVersion = makefile->GetDefinition("Qt5Core_VERSION_MAJOR");
+ if (!qtVersion)
+ {
+ qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR");
+ }
+ if (const char *targetQtVersion =
+ gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", ""))
+ {
+ qtVersion = targetQtVersion;
+ }
+ }
+
+ std::string targetName = target->GetName();
+ if (strcmp(qtVersion, "5") == 0)
+ {
+ cmTarget *qt5Rcc = makefile->FindTargetToUse("Qt5::rcc");
+ if (!qt5Rcc)
+ {
+ cmSystemTools::Error("Qt5::rcc target not found ",
+ targetName.c_str());
+ return std::string();
+ }
+ return qt5Rcc->ImportedGetLocation("");
+ }
+ else if (strcmp(qtVersion, "4") == 0)
+ {
+ cmTarget *qt4Rcc = makefile->FindTargetToUse("Qt4::rcc");
+ if (!qt4Rcc)
+ {
+ cmSystemTools::Error("Qt4::rcc target not found ",
+ targetName.c_str());
+ return std::string();
+ }
+ return qt4Rcc->ImportedGetLocation("");
+ }
+
+ cmSystemTools::Error("The CMAKE_AUTORCC feature supports only Qt 4 and "
+ "Qt 5 ", targetName.c_str());
+ return std::string();
+}
diff --git a/Source/cmQtAutoGeneratorInitializer.h b/Source/cmQtAutoGeneratorInitializer.h
new file mode 100644
index 0000000..78e49e0
--- /dev/null
+++ b/Source/cmQtAutoGeneratorInitializer.h
@@ -0,0 +1,65 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2004-2011 Kitware, Inc.
+ Copyright 2011 Alexander Neundorf (neundorf at kde.org)
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+
+#ifndef cmQtAutoGeneratorInitializer_h
+#define cmQtAutoGeneratorInitializer_h
+
+#include <string>
+#include <vector>
+#include <map>
+
+class cmSourceFile;
+class cmTarget;
+class cmLocalGenerator;
+
+class cmQtAutoGeneratorInitializer
+{
+public:
+ static void InitializeAutogenSources(cmTarget* target);
+ static void InitializeAutogenTarget(cmLocalGenerator* lg, cmTarget* target);
+ static void SetupAutoGenerateTarget(cmTarget const* target);
+
+ static std::string GetAutogenTargetName(cmTarget const* target);
+ static std::string GetAutogenTargetDir(cmTarget const* target);
+
+private:
+ static void SetupSourceFiles(cmTarget const* target,
+ std::vector<std::string>& skipMoc,
+ std::vector<std::string>& mocSources,
+ std::vector<std::string>& mocHeaders,
+ std::vector<std::string>& skipUic);
+
+ static void SetupAutoMocTarget(cmTarget const* target,
+ const std::string &autogenTargetName,
+ const std::vector<std::string>& skipMoc,
+ const std::vector<std::string>& mocHeaders,
+ std::map<std::string, std::string> &configIncludes,
+ std::map<std::string, std::string> &configDefines);
+ static void SetupAutoUicTarget(cmTarget const* target,
+ const std::vector<std::string>& skipUic,
+ std::map<std::string, std::string> &configUicOptions);
+ static void SetupAutoRccTarget(cmTarget const* target);
+
+ static void MergeRccOptions(std::vector<std::string> &opts,
+ const std::vector<std::string> &fileOpts, bool isQt5);
+
+ static std::string GetRccExecutable(cmTarget const* target);
+
+ static std::string ListQt5RccInputs(cmSourceFile* sf, cmTarget const* target,
+ std::vector<std::string>& depends);
+
+ static std::string ListQt4RccInputs(cmSourceFile* sf,
+ std::vector<std::string>& depends);
+};
+
+#endif
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 62b5cb1..42bcaa5 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -35,7 +35,7 @@
#endif
#include "cmQtAutoGenerators.h"
-
+#include "cmQtAutoGeneratorInitializer.h"
static bool requiresMocing(const std::string& text, std::string ¯oName)
{
@@ -105,28 +105,6 @@ static std::string extractSubDir(const std::string& absPath,
return subDir;
}
-
-static void copyTargetProperty(cmTarget* destinationTarget,
- cmTarget* sourceTarget,
- const std::string& propertyName)
-{
- const char* propertyValue = sourceTarget->GetProperty(propertyName);
- if (propertyValue)
- {
- destinationTarget->SetProperty(propertyName, propertyValue);
- }
-}
-
-
-static std::string ReadAll(const std::string& filename)
-{
- cmsys::ifstream file(filename.c_str());
- std::stringstream stream;
- stream << file.rdbuf();
- file.close();
- return stream.str();
-}
-
cmQtAutoGenerators::cmQtAutoGenerators()
:Verbose(cmsys::SystemTools::GetEnv("VERBOSE") != 0)
,ColorOutput(true)
@@ -151,697 +129,6 @@ cmQtAutoGenerators::cmQtAutoGenerators()
}
}
-static std::string getAutogenTargetName(cmTarget const* target)
-{
- std::string autogenTargetName = target->GetName();
- autogenTargetName += "_automoc";
- return autogenTargetName;
-}
-
-static std::string getAutogenTargetDir(cmTarget const* target)
-{
- cmMakefile* makefile = target->GetMakefile();
- std::string targetDir = makefile->GetCurrentBinaryDirectory();
- targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory();
- targetDir += "/";
- targetDir += getAutogenTargetName(target);
- targetDir += ".dir/";
- return targetDir;
-}
-
-static std::string cmQtAutoGeneratorsStripCR(std::string const& line)
-{
- // Strip CR characters rcc may have printed (possibly more than one!).
- std::string::size_type cr = line.find('\r');
- if (cr != line.npos)
- {
- return line.substr(0, cr);
- }
- return line;
-}
-
-std::string cmQtAutoGeneratorInitializer::ListQt5RccInputs(cmSourceFile* sf,
- cmTarget const* target,
- std::vector<std::string>& depends)
-{
- std::string rccCommand
- = cmQtAutoGeneratorInitializer::GetRccExecutable(target);
- std::vector<std::string> qrcEntries;
-
- std::vector<std::string> command;
- command.push_back(rccCommand);
- command.push_back("-list");
-
- std::string absFile = cmsys::SystemTools::GetRealPath(
- sf->GetFullPath());
-
- command.push_back(absFile);
-
- std::string rccStdOut;
- std::string rccStdErr;
- int retVal = 0;
- bool result = cmSystemTools::RunSingleCommand(
- command, &rccStdOut, &rccStdErr,
- &retVal, 0, cmSystemTools::OUTPUT_NONE);
- if (!result || retVal)
- {
- std::cerr << "AUTOGEN: error: Rcc list process for " << sf->GetFullPath()
- << " failed:\n" << rccStdOut << "\n" << rccStdErr << std::endl;
- return std::string();
- }
-
- {
- std::istringstream ostr(rccStdOut);
- std::string oline;
- while(std::getline(ostr, oline))
- {
- oline = cmQtAutoGeneratorsStripCR(oline);
- if(!oline.empty())
- {
- qrcEntries.push_back(oline);
- }
- }
- }
-
- {
- std::istringstream estr(rccStdErr);
- std::string eline;
- while(std::getline(estr, eline))
- {
- eline = cmQtAutoGeneratorsStripCR(eline);
- if (cmHasLiteralPrefix(eline, "RCC: Error in"))
- {
- static std::string searchString = "Cannot find file '";
-
- std::string::size_type pos = eline.find(searchString);
- if (pos == std::string::npos)
- {
- std::cerr << "AUTOGEN: error: Rcc lists unparsable output "
- << eline << std::endl;
- return std::string();
- }
- pos += searchString.length();
- std::string::size_type sz = eline.size() - pos - 1;
- qrcEntries.push_back(eline.substr(pos, sz));
- }
- }
- }
-
- depends.insert(depends.end(), qrcEntries.begin(), qrcEntries.end());
- return cmJoin(qrcEntries, "@list_sep@");
-}
-
-std::string cmQtAutoGeneratorInitializer::ListQt4RccInputs(cmSourceFile* sf,
- std::vector<std::string>& depends)
-{
- const std::string qrcContents = ReadAll(sf->GetFullPath());
-
- cmsys::RegularExpression fileMatchRegex("(<file[^<]+)");
-
- std::string entriesList;
- const char* sep = "";
-
- size_t offset = 0;
- while (fileMatchRegex.find(qrcContents.c_str() + offset))
- {
- std::string qrcEntry = fileMatchRegex.match(1);
-
- offset += qrcEntry.size();
-
- cmsys::RegularExpression fileReplaceRegex("(^<file[^>]*>)");
- fileReplaceRegex.find(qrcEntry);
- std::string tag = fileReplaceRegex.match(1);
-
- qrcEntry = qrcEntry.substr(tag.size());
-
- if (!cmSystemTools::FileIsFullPath(qrcEntry.c_str()))
- {
- qrcEntry = sf->GetLocation().GetDirectory() + "/" + qrcEntry;
- }
-
- entriesList += sep;
- entriesList += qrcEntry;
- sep = "@list_sep@";
- depends.push_back(qrcEntry);
- }
- return entriesList;
-}
-
-
-void cmQtAutoGeneratorInitializer::InitializeAutogenSources(cmTarget* target)
-{
- cmMakefile* makefile = target->GetMakefile();
-
- if (target->GetPropertyAsBool("AUTOMOC"))
- {
- std::string automocTargetName = getAutogenTargetName(target);
- std::string mocCppFile = makefile->GetCurrentBinaryDirectory();
- mocCppFile += "/";
- mocCppFile += automocTargetName;
- mocCppFile += ".cpp";
- makefile->GetOrCreateSource(mocCppFile, true);
- makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
- mocCppFile.c_str(), false);
-
- target->AddSource(mocCppFile);
- }
-}
-
-void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
- cmLocalGenerator* lg,
- cmTarget* target)
-{
- cmMakefile* makefile = target->GetMakefile();
-
- std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR");
- if (qtMajorVersion == "")
- {
- qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR");
- }
-
- // create a custom target for running generators at buildtime:
- std::string autogenTargetName = getAutogenTargetName(target);
-
- std::string targetDir = getAutogenTargetDir(target);
-
- cmCustomCommandLine currentLine;
- currentLine.push_back(cmSystemTools::GetCMakeCommand());
- currentLine.push_back("-E");
- currentLine.push_back("cmake_autogen");
- currentLine.push_back(targetDir);
- currentLine.push_back("$<CONFIGURATION>");
-
- cmCustomCommandLines commandLines;
- commandLines.push_back(currentLine);
-
- std::string workingDirectory = cmSystemTools::CollapseFullPath(
- "", makefile->GetCurrentBinaryDirectory());
-
- std::vector<std::string> depends;
- if (const char *autogenDepends =
- target->GetProperty("AUTOGEN_TARGET_DEPENDS"))
- {
- cmSystemTools::ExpandListArgument(autogenDepends, depends);
- }
- std::vector<std::string> toolNames;
- if (target->GetPropertyAsBool("AUTOMOC"))
- {
- toolNames.push_back("moc");
- }
- if (target->GetPropertyAsBool("AUTOUIC"))
- {
- toolNames.push_back("uic");
- }
- if (target->GetPropertyAsBool("AUTORCC"))
- {
- toolNames.push_back("rcc");
- }
-
- std::string tools = toolNames[0];
- toolNames.erase(toolNames.begin());
- while (toolNames.size() > 1)
- {
- tools += ", " + toolNames[0];
- toolNames.erase(toolNames.begin());
- }
- if (toolNames.size() == 1)
- {
- tools += " and " + toolNames[0];
- }
- std::string autogenComment = "Automatic " + tools + " for target ";
- autogenComment += target->GetName();
-
-#if defined(_WIN32) && !defined(__CYGWIN__)
- bool usePRE_BUILD = false;
- cmGlobalGenerator* gg = lg->GetGlobalGenerator();
- if(gg->GetName().find("Visual Studio") != std::string::npos)
- {
- cmGlobalVisualStudioGenerator* vsgg =
- static_cast<cmGlobalVisualStudioGenerator*>(gg);
- // Under VS >= 7 use a PRE_BUILD event instead of a separate target to
- // reduce the number of targets loaded into the IDE.
- // This also works around a VS 11 bug that may skip updating the target:
- // https://connect.microsoft.com/VisualStudio/feedback/details/769495
- usePRE_BUILD = vsgg->GetVersion() >= cmGlobalVisualStudioGenerator::VS7;
- if(usePRE_BUILD)
- {
- for (std::vector<std::string>::iterator it = depends.begin();
- it != depends.end(); ++it)
- {
- if(!makefile->FindTargetToUse(it->c_str()))
- {
- usePRE_BUILD = false;
- break;
- }
- }
- }
- }
-#endif
-
- std::vector<std::string> rcc_output;
- bool const isNinja =
- lg->GetGlobalGenerator()->GetName() == "Ninja";
- if(isNinja
-#if defined(_WIN32) && !defined(__CYGWIN__)
- || usePRE_BUILD
-#endif
- )
- {
- std::vector<cmSourceFile*> srcFiles;
- cmGeneratorTarget* gtgt =
- lg->GetGlobalGenerator()->GetGeneratorTarget(target);
- gtgt->GetConfigCommonSourceFiles(srcFiles);
- for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
- fileIt != srcFiles.end();
- ++fileIt)
- {
- cmSourceFile* sf = *fileIt;
- std::string absFile = cmsys::SystemTools::GetRealPath(
- sf->GetFullPath());
-
- std::string ext = sf->GetExtension();
-
- if (target->GetPropertyAsBool("AUTORCC"))
- {
- if (ext == "qrc"
- && !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")))
- {
- std::string basename = cmsys::SystemTools::
- GetFilenameWithoutLastExtension(absFile);
-
- std::string rcc_output_dir = target->GetSupportDirectory();
- cmSystemTools::MakeDirectory(rcc_output_dir.c_str());
- std::string rcc_output_file = rcc_output_dir;
- rcc_output_file += "/qrc_" + basename + ".cpp";
- rcc_output.push_back(rcc_output_file);
-
- if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED")))
- {
- if (qtMajorVersion == "5")
- {
- cmQtAutoGeneratorInitializer::ListQt5RccInputs(sf, target,
- depends);
- }
- else
- {
- cmQtAutoGeneratorInitializer::ListQt4RccInputs(sf, depends);
- }
-#if defined(_WIN32) && !defined(__CYGWIN__)
- // Cannot use PRE_BUILD because the resource files themselves
- // may not be sources within the target so VS may not know the
- // target needs to re-build at all.
- usePRE_BUILD = false;
-#endif
- }
- }
- }
- }
- }
-
-#if defined(_WIN32) && !defined(__CYGWIN__)
- if(usePRE_BUILD)
- {
- // Add the pre-build command directly to bypass the OBJECT_LIBRARY
- // rejection in cmMakefile::AddCustomCommandToTarget because we know
- // PRE_BUILD will work for an OBJECT_LIBRARY in this specific case.
- std::vector<std::string> no_output;
- std::vector<std::string> no_byproducts;
- cmCustomCommand cc(makefile, no_output, no_byproducts, depends,
- commandLines, autogenComment.c_str(),
- workingDirectory.c_str());
- cc.SetEscapeOldStyle(false);
- cc.SetEscapeAllowMakeVars(true);
- target->AddPreBuildCommand(cc);
- }
- else
-#endif
- {
- cmTarget* autogenTarget = makefile->AddUtilityCommand(
- autogenTargetName, true,
- workingDirectory.c_str(),
- /*byproducts=*/rcc_output, depends,
- commandLines, false, autogenComment.c_str());
-
- cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg);
- makefile->AddGeneratorTarget(autogenTarget, gt);
-
- // Set target folder
- const char* autogenFolder = makefile->GetState()
- ->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER");
- if (!autogenFolder)
- {
- autogenFolder = makefile->GetState()
- ->GetGlobalProperty("AUTOGEN_TARGETS_FOLDER");
- }
- if (autogenFolder && *autogenFolder)
- {
- autogenTarget->SetProperty("FOLDER", autogenFolder);
- }
- else
- {
- // inherit FOLDER property from target (#13688)
- copyTargetProperty(autogenTarget, target, "FOLDER");
- }
-
- target->AddUtility(autogenTargetName);
- }
-}
-
-static void GetCompileDefinitionsAndDirectories(cmTarget const* target,
- const std::string& config,
- std::string &incs,
- std::string &defs)
-{
- cmMakefile* makefile = target->GetMakefile();
- cmGlobalGenerator* globalGen = makefile->GetGlobalGenerator();
- std::vector<std::string> includeDirs;
- cmGeneratorTarget *gtgt = globalGen->GetGeneratorTarget(target);
- cmLocalGenerator *localGen = gtgt->GetLocalGenerator();
- // Get the include dirs for this target, without stripping the implicit
- // include dirs off, see http://public.kitware.com/Bug/view.php?id=13667
- localGen->GetIncludeDirectories(includeDirs, gtgt, "CXX", config, false);
-
- incs = cmJoin(includeDirs, ";");
-
- std::set<std::string> defines;
- localGen->AddCompileDefinitions(defines, target, config, "CXX");
-
- defs += cmJoin(defines, ";");
-}
-
-void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(
- cmTarget const* target)
-{
- cmMakefile* makefile = target->GetMakefile();
-
- // forget the variables added here afterwards again:
- cmMakefile::ScopePushPop varScope(makefile);
- static_cast<void>(varScope);
-
- // create a custom target for running generators at buildtime:
- std::string autogenTargetName = getAutogenTargetName(target);
-
- makefile->AddDefinition("_moc_target_name",
- cmOutputConverter::EscapeForCMake(autogenTargetName).c_str());
- makefile->AddDefinition("_origin_target_name",
- cmOutputConverter::EscapeForCMake(target->GetName()).c_str());
-
- std::string targetDir = getAutogenTargetDir(target);
-
- const char *qtVersion = makefile->GetDefinition("Qt5Core_VERSION_MAJOR");
- if (!qtVersion)
- {
- qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR");
- }
- cmGeneratorTarget *gtgt = target->GetMakefile()
- ->GetGlobalGenerator()
- ->GetGeneratorTarget(target);
- if (const char *targetQtVersion =
- gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", ""))
- {
- qtVersion = targetQtVersion;
- }
- if (qtVersion)
- {
- makefile->AddDefinition("_target_qt_version", qtVersion);
- }
-
- std::vector<std::string> skipUic;
- std::vector<std::string> skipMoc;
- std::vector<std::string> mocSources;
- std::vector<std::string> mocHeaders;
- std::map<std::string, std::string> configIncludes;
- std::map<std::string, std::string> configDefines;
- std::map<std::string, std::string> configUicOptions;
-
- if (target->GetPropertyAsBool("AUTOMOC")
- || target->GetPropertyAsBool("AUTOUIC")
- || target->GetPropertyAsBool("AUTORCC"))
- {
- cmQtAutoGeneratorInitializer::SetupSourceFiles(target, skipMoc,
- mocSources, mocHeaders, skipUic);
- }
- makefile->AddDefinition("_cpp_files",
- cmOutputConverter::EscapeForCMake(cmJoin(mocSources, ";")).c_str());
- if (target->GetPropertyAsBool("AUTOMOC"))
- {
- cmQtAutoGeneratorInitializer::SetupAutoMocTarget(target, autogenTargetName,
- skipMoc, mocHeaders,
- configIncludes, configDefines);
- }
- if (target->GetPropertyAsBool("AUTOUIC"))
- {
- cmQtAutoGeneratorInitializer::SetupAutoUicTarget(target, skipUic,
- configUicOptions);
- }
- if (target->GetPropertyAsBool("AUTORCC"))
- {
- cmQtAutoGeneratorInitializer::SetupAutoRccTarget(target);
- }
-
- const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT");
- std::string inputFile = cmakeRoot;
- inputFile += "/Modules/AutogenInfo.cmake.in";
- std::string outputFile = targetDir;
- outputFile += "/AutogenInfo.cmake";
- makefile->AddDefinition("_qt_rcc_inputs",
- makefile->GetDefinition("_qt_rcc_inputs_" + target->GetName()));
- makefile->ConfigureFile(inputFile.c_str(), outputFile.c_str(),
- false, true, false);
-
- // Ensure we have write permission in case .in was read-only.
- mode_t perm = 0;
-#if defined(_WIN32) && !defined(__CYGWIN__)
- mode_t mode_write = S_IWRITE;
-#else
- mode_t mode_write = S_IWUSR;
-#endif
- cmSystemTools::GetPermissions(outputFile, perm);
- if (!(perm & mode_write))
- {
- cmSystemTools::SetPermissions(outputFile, perm | mode_write);
- }
- if (!configDefines.empty()
- || !configIncludes.empty()
- || !configUicOptions.empty())
- {
- cmsys::ofstream infoFile(outputFile.c_str(), std::ios::app);
- if ( !infoFile )
- {
- std::string error = "Internal CMake error when trying to open file: ";
- error += outputFile.c_str();
- error += " for writing.";
- cmSystemTools::Error(error.c_str());
- return;
- }
- if (!configDefines.empty())
- {
- for (std::map<std::string, std::string>::iterator
- it = configDefines.begin(), end = configDefines.end();
- it != end; ++it)
- {
- infoFile << "set(AM_MOC_COMPILE_DEFINITIONS_" << it->first <<
- " " << it->second << ")\n";
- }
- }
- if (!configIncludes.empty())
- {
- for (std::map<std::string, std::string>::iterator
- it = configIncludes.begin(), end = configIncludes.end();
- it != end; ++it)
- {
- infoFile << "set(AM_MOC_INCLUDES_" << it->first <<
- " " << it->second << ")\n";
- }
- }
- if (!configUicOptions.empty())
- {
- for (std::map<std::string, std::string>::iterator
- it = configUicOptions.begin(), end = configUicOptions.end();
- it != end; ++it)
- {
- infoFile << "set(AM_UIC_TARGET_OPTIONS_" << it->first <<
- " " << it->second << ")\n";
- }
- }
- }
-}
-
-void cmQtAutoGeneratorInitializer::SetupSourceFiles(cmTarget const* target,
- std::vector<std::string>& skipMoc,
- std::vector<std::string>& mocSources,
- std::vector<std::string>& mocHeaders,
- std::vector<std::string>& skipUic)
-{
- cmMakefile* makefile = target->GetMakefile();
-
- std::vector<cmSourceFile*> srcFiles;
- cmGeneratorTarget *gtgt = target->GetMakefile()
- ->GetGlobalGenerator()
- ->GetGeneratorTarget(target);
- gtgt->GetConfigCommonSourceFiles(srcFiles);
-
- std::vector<std::string> newRccFiles;
-
- for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
- fileIt != srcFiles.end();
- ++fileIt)
- {
- cmSourceFile* sf = *fileIt;
- std::string absFile = cmsys::SystemTools::GetRealPath(
- sf->GetFullPath());
- bool skipFileForMoc =
- cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC"));
- bool generated = cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"));
-
- if(cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOUIC")))
- {
- skipUic.push_back(absFile);
- }
-
- std::string ext = sf->GetExtension();
-
- if (target->GetPropertyAsBool("AUTORCC"))
- {
- if (ext == "qrc"
- && !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")))
- {
- std::string basename = cmsys::SystemTools::
- GetFilenameWithoutLastExtension(absFile);
-
- std::string rcc_output_dir = target->GetSupportDirectory();
- cmSystemTools::MakeDirectory(rcc_output_dir.c_str());
- std::string rcc_output_file = rcc_output_dir;
- rcc_output_file += "/qrc_" + basename + ".cpp";
- makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
- rcc_output_file.c_str(), false);
- makefile->GetOrCreateSource(rcc_output_file, true);
- newRccFiles.push_back(rcc_output_file);
- }
- }
-
- if (!generated)
- {
- if (skipFileForMoc)
- {
- skipMoc.push_back(absFile);
- }
- else
- {
- cmSystemTools::FileFormat fileType = cmSystemTools::GetFileFormat(
- ext.c_str());
- if (fileType == cmSystemTools::CXX_FILE_FORMAT)
- {
- mocSources.push_back(absFile);
- }
- else if (fileType == cmSystemTools::HEADER_FILE_FORMAT)
- {
- mocHeaders.push_back(absFile);
- }
- }
- }
- }
-
- for(std::vector<std::string>::const_iterator fileIt = newRccFiles.begin();
- fileIt != newRccFiles.end();
- ++fileIt)
- {
- const_cast<cmTarget*>(target)->AddSource(*fileIt);
- }
-}
-
-void cmQtAutoGeneratorInitializer::SetupAutoMocTarget(cmTarget const* target,
- const std::string &autogenTargetName,
- std::vector<std::string> const& skipMoc,
- std::vector<std::string> const& mocHeaders,
- std::map<std::string, std::string> &configIncludes,
- std::map<std::string, std::string> &configDefines)
-{
- cmMakefile* makefile = target->GetMakefile();
-
- const char* tmp = target->GetProperty("AUTOMOC_MOC_OPTIONS");
- std::string _moc_options = (tmp!=0 ? tmp : "");
- makefile->AddDefinition("_moc_options",
- cmOutputConverter::EscapeForCMake(_moc_options).c_str());
- makefile->AddDefinition("_skip_moc",
- cmOutputConverter::EscapeForCMake(cmJoin(skipMoc, ";")).c_str());
- makefile->AddDefinition("_moc_headers",
- cmOutputConverter::EscapeForCMake(cmJoin(mocHeaders, ";")).c_str());
- bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE");
- makefile->AddDefinition("_moc_relaxed_mode", relaxedMode ? "TRUE" : "FALSE");
-
- std::string _moc_incs;
- std::string _moc_compile_defs;
- std::vector<std::string> configs;
- const std::string& config = makefile->GetConfigurations(configs);
- GetCompileDefinitionsAndDirectories(target, config,
- _moc_incs, _moc_compile_defs);
-
- makefile->AddDefinition("_moc_incs",
- cmOutputConverter::EscapeForCMake(_moc_incs).c_str());
- makefile->AddDefinition("_moc_compile_defs",
- cmOutputConverter::EscapeForCMake(_moc_compile_defs).c_str());
-
- for (std::vector<std::string>::const_iterator li = configs.begin();
- li != configs.end(); ++li)
- {
- std::string config_moc_incs;
- std::string config_moc_compile_defs;
- GetCompileDefinitionsAndDirectories(target, *li,
- config_moc_incs,
- config_moc_compile_defs);
- if (config_moc_incs != _moc_incs)
- {
- configIncludes[*li] =
- cmOutputConverter::EscapeForCMake(config_moc_incs);
- if(_moc_incs.empty())
- {
- _moc_incs = config_moc_incs;
- }
- }
- if (config_moc_compile_defs != _moc_compile_defs)
- {
- configDefines[*li] =
- cmOutputConverter::EscapeForCMake(config_moc_compile_defs);
- if(_moc_compile_defs.empty())
- {
- _moc_compile_defs = config_moc_compile_defs;
- }
- }
- }
-
- const char *qtVersion = makefile->GetDefinition("_target_qt_version");
- if (strcmp(qtVersion, "5") == 0)
- {
- cmTarget *qt5Moc = makefile->FindTargetToUse("Qt5::moc");
- if (!qt5Moc)
- {
- cmSystemTools::Error("Qt5::moc target not found ",
- autogenTargetName.c_str());
- return;
- }
- makefile->AddDefinition("_qt_moc_executable",
- qt5Moc->ImportedGetLocation(""));
- }
- else if (strcmp(qtVersion, "4") == 0)
- {
- cmTarget *qt4Moc = makefile->FindTargetToUse("Qt4::moc");
- if (!qt4Moc)
- {
- cmSystemTools::Error("Qt4::moc target not found ",
- autogenTargetName.c_str());
- return;
- }
- makefile->AddDefinition("_qt_moc_executable",
- qt4Moc->ImportedGetLocation(""));
- }
- else
- {
- cmSystemTools::Error("The CMAKE_AUTOMOC feature supports only Qt 4 and "
- "Qt 5 ", autogenTargetName.c_str());
- }
-}
-
void cmQtAutoGenerators::MergeUicOptions(std::vector<std::string> &opts,
const std::vector<std::string> &fileOpts,
bool isQt5)
@@ -887,336 +174,6 @@ void cmQtAutoGenerators::MergeUicOptions(std::vector<std::string> &opts,
opts.insert(opts.end(), extraOpts.begin(), extraOpts.end());
}
-static void GetUicOpts(cmTarget const* target, const std::string& config,
- std::string &optString)
-{
- cmGeneratorTarget *gtgt = target->GetMakefile()
- ->GetGlobalGenerator()
- ->GetGeneratorTarget(target);
- std::vector<std::string> opts;
- gtgt->GetAutoUicOptions(opts, config);
- optString = cmJoin(opts, ";");
-}
-
-void cmQtAutoGeneratorInitializer::SetupAutoUicTarget(cmTarget const* target,
- std::vector<std::string> const& skipUic,
- std::map<std::string, std::string> &configUicOptions)
-{
- cmMakefile *makefile = target->GetMakefile();
-
- std::set<std::string> skipped;
- skipped.insert(skipUic.begin(), skipUic.end());
-
- makefile->AddDefinition("_skip_uic",
- cmOutputConverter::EscapeForCMake(cmJoin(skipUic, ";")).c_str());
-
- std::vector<cmSourceFile*> uiFilesWithOptions
- = makefile->GetQtUiFilesWithOptions();
-
- const char *qtVersion = makefile->GetDefinition("_target_qt_version");
-
- std::string _uic_opts;
- std::vector<std::string> configs;
- const std::string& config = makefile->GetConfigurations(configs);
- GetUicOpts(target, config, _uic_opts);
-
- if (!_uic_opts.empty())
- {
- _uic_opts = cmOutputConverter::EscapeForCMake(_uic_opts);
- makefile->AddDefinition("_uic_target_options", _uic_opts.c_str());
- }
- for (std::vector<std::string>::const_iterator li = configs.begin();
- li != configs.end(); ++li)
- {
- std::string config_uic_opts;
- GetUicOpts(target, *li, config_uic_opts);
- if (config_uic_opts != _uic_opts)
- {
- configUicOptions[*li] =
- cmOutputConverter::EscapeForCMake(config_uic_opts);
- if(_uic_opts.empty())
- {
- _uic_opts = config_uic_opts;
- }
- }
- }
-
- std::string uiFileFiles;
- std::string uiFileOptions;
- const char* sep = "";
-
- for(std::vector<cmSourceFile*>::const_iterator fileIt =
- uiFilesWithOptions.begin();
- fileIt != uiFilesWithOptions.end();
- ++fileIt)
- {
- cmSourceFile* sf = *fileIt;
- std::string absFile = cmsys::SystemTools::GetRealPath(
- sf->GetFullPath());
-
- if (!skipped.insert(absFile).second)
- {
- continue;
- }
- uiFileFiles += sep;
- uiFileFiles += absFile;
- uiFileOptions += sep;
- std::string opts = sf->GetProperty("AUTOUIC_OPTIONS");
- cmSystemTools::ReplaceString(opts, ";", "@list_sep@");
- uiFileOptions += opts;
- sep = ";";
- }
-
- makefile->AddDefinition("_qt_uic_options_files",
- cmOutputConverter::EscapeForCMake(uiFileFiles).c_str());
- makefile->AddDefinition("_qt_uic_options_options",
- cmOutputConverter::EscapeForCMake(uiFileOptions).c_str());
-
- std::string targetName = target->GetName();
- if (strcmp(qtVersion, "5") == 0)
- {
- cmTarget *qt5Uic = makefile->FindTargetToUse("Qt5::uic");
- if (!qt5Uic)
- {
- // Project does not use Qt5Widgets, but has AUTOUIC ON anyway
- }
- else
- {
- makefile->AddDefinition("_qt_uic_executable",
- qt5Uic->ImportedGetLocation(""));
- }
- }
- else if (strcmp(qtVersion, "4") == 0)
- {
- cmTarget *qt4Uic = makefile->FindTargetToUse("Qt4::uic");
- if (!qt4Uic)
- {
- cmSystemTools::Error("Qt4::uic target not found ",
- targetName.c_str());
- return;
- }
- makefile->AddDefinition("_qt_uic_executable",
- qt4Uic->ImportedGetLocation(""));
- }
- else
- {
- cmSystemTools::Error("The CMAKE_AUTOUIC feature supports only Qt 4 and "
- "Qt 5 ", targetName.c_str());
- }
-}
-
-void cmQtAutoGeneratorInitializer::MergeRccOptions(
- std::vector<std::string> &opts,
- const std::vector<std::string> &fileOpts,
- bool isQt5)
-{
- static const char* valueOptions[] = {
- "name",
- "root",
- "compress",
- "threshold"
- };
- std::vector<std::string> extraOpts;
- for(std::vector<std::string>::const_iterator it = fileOpts.begin();
- it != fileOpts.end(); ++it)
- {
- std::vector<std::string>::iterator existingIt
- = std::find(opts.begin(), opts.end(), *it);
- if (existingIt != opts.end())
- {
- const char *o = it->c_str();
- if (*o == '-')
- {
- ++o;
- }
- if (isQt5 && *o == '-')
- {
- ++o;
- }
- if (std::find_if(cmArrayBegin(valueOptions), cmArrayEnd(valueOptions),
- cmStrCmp(*it)) != cmArrayEnd(valueOptions))
- {
- assert(existingIt + 1 != opts.end());
- *(existingIt + 1) = *(it + 1);
- ++it;
- }
- }
- else
- {
- extraOpts.push_back(*it);
- }
- }
- opts.insert(opts.end(), extraOpts.begin(), extraOpts.end());
-}
-
-void cmQtAutoGeneratorInitializer::SetupAutoRccTarget(cmTarget const* target)
-{
- std::string _rcc_files;
- const char* sepRccFiles = "";
- cmMakefile *makefile = target->GetMakefile();
-
- std::vector<cmSourceFile*> srcFiles;
- cmGeneratorTarget *gtgt = target->GetMakefile()
- ->GetGlobalGenerator()
- ->GetGeneratorTarget(target);
- gtgt->GetConfigCommonSourceFiles(srcFiles);
-
- std::string qrcInputs;
- const char* qrcInputsSep = "";
-
- std::string rccFileFiles;
- std::string rccFileOptions;
- const char *optionSep = "";
-
- const char *qtVersion = makefile->GetDefinition("_target_qt_version");
-
- std::vector<std::string> rccOptions;
- if (const char* opts = target->GetProperty("AUTORCC_OPTIONS"))
- {
- cmSystemTools::ExpandListArgument(opts, rccOptions);
- }
- std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR");
- if (qtMajorVersion == "")
- {
- qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR");
- }
-
- for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
- fileIt != srcFiles.end();
- ++fileIt)
- {
- cmSourceFile* sf = *fileIt;
- std::string ext = sf->GetExtension();
- if (ext == "qrc")
- {
- std::string absFile = cmsys::SystemTools::GetRealPath(
- sf->GetFullPath());
- bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC"));
-
- if (!skip)
- {
- _rcc_files += sepRccFiles;
- _rcc_files += absFile;
- sepRccFiles = ";";
-
- if (const char *prop = sf->GetProperty("AUTORCC_OPTIONS"))
- {
- std::vector<std::string> optsVec;
- cmSystemTools::ExpandListArgument(prop, optsVec);
- cmQtAutoGeneratorInitializer::MergeRccOptions(rccOptions, optsVec,
- strcmp(qtVersion, "5") == 0);
- }
-
- if (!rccOptions.empty())
- {
- rccFileFiles += optionSep;
- rccFileFiles += absFile;
- rccFileOptions += optionSep;
- }
- const char *listSep = "";
- for(std::vector<std::string>::const_iterator it = rccOptions.begin();
- it != rccOptions.end();
- ++it)
- {
- rccFileOptions += listSep;
- rccFileOptions += *it;
- listSep = "@list_sep@";
- }
- optionSep = ";";
-
- std::vector<std::string> depends;
-
- std::string entriesList;
- if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED")))
- {
- if (qtMajorVersion == "5")
- {
- entriesList = cmQtAutoGeneratorInitializer::ListQt5RccInputs(sf,
- target,
- depends);
- }
- else
- {
- entriesList =
- cmQtAutoGeneratorInitializer::ListQt4RccInputs(sf, depends);
- }
- if (entriesList.empty())
- {
- return;
- }
- }
- qrcInputs += qrcInputsSep;
- qrcInputs += entriesList;
- qrcInputsSep = ";";
- }
- }
- }
- makefile->AddDefinition("_qt_rcc_inputs_" + target->GetName(),
- cmOutputConverter::EscapeForCMake(qrcInputs).c_str());
-
- makefile->AddDefinition("_rcc_files",
- cmOutputConverter::EscapeForCMake(_rcc_files).c_str());
-
- makefile->AddDefinition("_qt_rcc_options_files",
- cmOutputConverter::EscapeForCMake(rccFileFiles).c_str());
- makefile->AddDefinition("_qt_rcc_options_options",
- cmOutputConverter::EscapeForCMake(rccFileOptions).c_str());
-
- makefile->AddDefinition("_qt_rcc_executable",
- cmQtAutoGeneratorInitializer::GetRccExecutable(target).c_str());
-}
-
-std::string cmQtAutoGeneratorInitializer::GetRccExecutable(
- cmTarget const* target)
-{
- cmGeneratorTarget *gtgt = target->GetMakefile()
- ->GetGlobalGenerator()
- ->GetGeneratorTarget(target);
- cmMakefile *makefile = target->GetMakefile();
- const char *qtVersion = makefile->GetDefinition("_target_qt_version");
- if (!qtVersion)
- {
- qtVersion = makefile->GetDefinition("Qt5Core_VERSION_MAJOR");
- if (!qtVersion)
- {
- qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR");
- }
- if (const char *targetQtVersion =
- gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", ""))
- {
- qtVersion = targetQtVersion;
- }
- }
-
- std::string targetName = target->GetName();
- if (strcmp(qtVersion, "5") == 0)
- {
- cmTarget *qt5Rcc = makefile->FindTargetToUse("Qt5::rcc");
- if (!qt5Rcc)
- {
- cmSystemTools::Error("Qt5::rcc target not found ",
- targetName.c_str());
- return std::string();
- }
- return qt5Rcc->ImportedGetLocation("");
- }
- else if (strcmp(qtVersion, "4") == 0)
- {
- cmTarget *qt4Rcc = makefile->FindTargetToUse("Qt4::rcc");
- if (!qt4Rcc)
- {
- cmSystemTools::Error("Qt4::rcc target not found ",
- targetName.c_str());
- return std::string();
- }
- return qt4Rcc->ImportedGetLocation("");
- }
-
- cmSystemTools::Error("The CMAKE_AUTORCC feature supports only Qt 4 and "
- "Qt 5 ", targetName.c_str());
- return std::string();
-}
-
bool cmQtAutoGenerators::Run(const std::string& targetDirectory,
const std::string& config)
{
@@ -1542,6 +499,14 @@ void cmQtAutoGenerators::Init()
}
+static std::string ReadAll(const std::string& filename)
+{
+ cmsys::ifstream file(filename.c_str());
+ std::stringstream stream;
+ stream << file.rdbuf();
+ file.close();
+ return stream.str();
+}
bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
{
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index 63b1c4a..346c468 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -25,43 +25,6 @@ class cmLocalGenerator;
class cmTarget;
class cmSourceFile;
-class cmQtAutoGeneratorInitializer
-{
-public:
- static void InitializeAutogenSources(cmTarget* target);
- static void InitializeAutogenTarget(cmLocalGenerator* lg, cmTarget* target);
- static void SetupAutoGenerateTarget(cmTarget const* target);
-
-private:
- static void SetupSourceFiles(cmTarget const* target,
- std::vector<std::string>& skipMoc,
- std::vector<std::string>& mocSources,
- std::vector<std::string>& mocHeaders,
- std::vector<std::string>& skipUic);
-
- static void SetupAutoMocTarget(cmTarget const* target,
- const std::string &autogenTargetName,
- const std::vector<std::string>& skipMoc,
- const std::vector<std::string>& mocHeaders,
- std::map<std::string, std::string> &configIncludes,
- std::map<std::string, std::string> &configDefines);
- static void SetupAutoUicTarget(cmTarget const* target,
- const std::vector<std::string>& skipUic,
- std::map<std::string, std::string> &configUicOptions);
- static void SetupAutoRccTarget(cmTarget const* target);
-
- static void MergeRccOptions(std::vector<std::string> &opts,
- const std::vector<std::string> &fileOpts, bool isQt5);
-
- static std::string GetRccExecutable(cmTarget const* target);
-
- static std::string ListQt5RccInputs(cmSourceFile* sf, cmTarget const* target,
- std::vector<std::string>& depends);
-
- static std::string ListQt4RccInputs(cmSourceFile* sf,
- std::vector<std::string>& depends);
-};
-
class cmQtAutoGenerators
{
public:
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1e83a963d8983f09f5fe6fbf7d268f920b4ed7d0
commit 1e83a963d8983f09f5fe6fbf7d268f920b4ed7d0
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Sep 26 18:54:56 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Sep 26 19:32:54 2015 +0200
QtAutogen: Split initializer methods into separate class.
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 5848a88..a86c91c 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1269,7 +1269,7 @@ bool cmGlobalGenerator::Compute()
for (std::vector<cmTarget const*>::iterator it = autogenTargets.begin();
it != autogenTargets.end(); ++it)
{
- cmQtAutoGenerators::SetupAutoGenerateTarget(*it);
+ cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(*it);
}
#endif
@@ -1451,7 +1451,7 @@ cmGlobalGenerator::CreateQtAutoGeneratorsTargets()
continue;
}
- cmQtAutoGenerators::InitializeAutogenSources(&ti->second);
+ cmQtAutoGeneratorInitializer::InitializeAutogenSources(&ti->second);
targetNames.push_back(ti->second.GetName());
}
for(std::vector<std::string>::iterator ti = targetNames.begin();
@@ -1459,7 +1459,7 @@ cmGlobalGenerator::CreateQtAutoGeneratorsTargets()
{
cmTarget* target = this->LocalGenerators[i]
->GetMakefile()->FindTarget(*ti, true);
- cmQtAutoGenerators::InitializeAutogenTarget(
+ cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
this->LocalGenerators[i], target);
autogenTargets.push_back(target);
}
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 9bec68a..62b5cb1 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -180,11 +180,12 @@ static std::string cmQtAutoGeneratorsStripCR(std::string const& line)
return line;
}
-std::string cmQtAutoGenerators::ListQt5RccInputs(cmSourceFile* sf,
+std::string cmQtAutoGeneratorInitializer::ListQt5RccInputs(cmSourceFile* sf,
cmTarget const* target,
std::vector<std::string>& depends)
{
- std::string rccCommand = cmQtAutoGenerators::GetRccExecutable(target);
+ std::string rccCommand
+ = cmQtAutoGeneratorInitializer::GetRccExecutable(target);
std::vector<std::string> qrcEntries;
std::vector<std::string> command;
@@ -250,7 +251,7 @@ std::string cmQtAutoGenerators::ListQt5RccInputs(cmSourceFile* sf,
return cmJoin(qrcEntries, "@list_sep@");
}
-std::string cmQtAutoGenerators::ListQt4RccInputs(cmSourceFile* sf,
+std::string cmQtAutoGeneratorInitializer::ListQt4RccInputs(cmSourceFile* sf,
std::vector<std::string>& depends)
{
const std::string qrcContents = ReadAll(sf->GetFullPath());
@@ -287,7 +288,7 @@ std::string cmQtAutoGenerators::ListQt4RccInputs(cmSourceFile* sf,
}
-void cmQtAutoGenerators::InitializeAutogenSources(cmTarget* target)
+void cmQtAutoGeneratorInitializer::InitializeAutogenSources(cmTarget* target)
{
cmMakefile* makefile = target->GetMakefile();
@@ -306,7 +307,8 @@ void cmQtAutoGenerators::InitializeAutogenSources(cmTarget* target)
}
}
-void cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg,
+void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
+ cmLocalGenerator* lg,
cmTarget* target)
{
cmMakefile* makefile = target->GetMakefile();
@@ -437,11 +439,12 @@ void cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg,
{
if (qtMajorVersion == "5")
{
- cmQtAutoGenerators::ListQt5RccInputs(sf, target, depends);
+ cmQtAutoGeneratorInitializer::ListQt5RccInputs(sf, target,
+ depends);
}
else
{
- cmQtAutoGenerators::ListQt4RccInputs(sf, depends);
+ cmQtAutoGeneratorInitializer::ListQt4RccInputs(sf, depends);
}
#if defined(_WIN32) && !defined(__CYGWIN__)
// Cannot use PRE_BUILD because the resource files themselves
@@ -526,7 +529,8 @@ static void GetCompileDefinitionsAndDirectories(cmTarget const* target,
defs += cmJoin(defines, ";");
}
-void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target)
+void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(
+ cmTarget const* target)
{
cmMakefile* makefile = target->GetMakefile();
@@ -574,24 +578,25 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target)
|| target->GetPropertyAsBool("AUTOUIC")
|| target->GetPropertyAsBool("AUTORCC"))
{
- cmQtAutoGenerators::SetupSourceFiles(target, skipMoc,
+ cmQtAutoGeneratorInitializer::SetupSourceFiles(target, skipMoc,
mocSources, mocHeaders, skipUic);
}
makefile->AddDefinition("_cpp_files",
cmOutputConverter::EscapeForCMake(cmJoin(mocSources, ";")).c_str());
if (target->GetPropertyAsBool("AUTOMOC"))
{
- cmQtAutoGenerators::SetupAutoMocTarget(target, autogenTargetName,
+ cmQtAutoGeneratorInitializer::SetupAutoMocTarget(target, autogenTargetName,
skipMoc, mocHeaders,
configIncludes, configDefines);
}
if (target->GetPropertyAsBool("AUTOUIC"))
{
- cmQtAutoGenerators::SetupAutoUicTarget(target, skipUic, configUicOptions);
+ cmQtAutoGeneratorInitializer::SetupAutoUicTarget(target, skipUic,
+ configUicOptions);
}
if (target->GetPropertyAsBool("AUTORCC"))
{
- cmQtAutoGenerators::SetupAutoRccTarget(target);
+ cmQtAutoGeneratorInitializer::SetupAutoRccTarget(target);
}
const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT");
@@ -662,7 +667,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target)
}
}
-void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target,
+void cmQtAutoGeneratorInitializer::SetupSourceFiles(cmTarget const* target,
std::vector<std::string>& skipMoc,
std::vector<std::string>& mocSources,
std::vector<std::string>& mocHeaders,
@@ -745,7 +750,7 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target,
}
}
-void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target,
+void cmQtAutoGeneratorInitializer::SetupAutoMocTarget(cmTarget const* target,
const std::string &autogenTargetName,
std::vector<std::string> const& skipMoc,
std::vector<std::string> const& mocHeaders,
@@ -893,7 +898,7 @@ static void GetUicOpts(cmTarget const* target, const std::string& config,
optString = cmJoin(opts, ";");
}
-void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,
+void cmQtAutoGeneratorInitializer::SetupAutoUicTarget(cmTarget const* target,
std::vector<std::string> const& skipUic,
std::map<std::string, std::string> &configUicOptions)
{
@@ -1000,7 +1005,8 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,
}
}
-void cmQtAutoGenerators::MergeRccOptions(std::vector<std::string> &opts,
+void cmQtAutoGeneratorInitializer::MergeRccOptions(
+ std::vector<std::string> &opts,
const std::vector<std::string> &fileOpts,
bool isQt5)
{
@@ -1043,7 +1049,7 @@ void cmQtAutoGenerators::MergeRccOptions(std::vector<std::string> &opts,
opts.insert(opts.end(), extraOpts.begin(), extraOpts.end());
}
-void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
+void cmQtAutoGeneratorInitializer::SetupAutoRccTarget(cmTarget const* target)
{
std::string _rcc_files;
const char* sepRccFiles = "";
@@ -1097,7 +1103,7 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
{
std::vector<std::string> optsVec;
cmSystemTools::ExpandListArgument(prop, optsVec);
- cmQtAutoGenerators::MergeRccOptions(rccOptions, optsVec,
+ cmQtAutoGeneratorInitializer::MergeRccOptions(rccOptions, optsVec,
strcmp(qtVersion, "5") == 0);
}
@@ -1125,12 +1131,14 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
{
if (qtMajorVersion == "5")
{
- entriesList = cmQtAutoGenerators::ListQt5RccInputs(sf, target,
+ entriesList = cmQtAutoGeneratorInitializer::ListQt5RccInputs(sf,
+ target,
depends);
}
else
{
- entriesList = cmQtAutoGenerators::ListQt4RccInputs(sf, depends);
+ entriesList =
+ cmQtAutoGeneratorInitializer::ListQt4RccInputs(sf, depends);
}
if (entriesList.empty())
{
@@ -1155,10 +1163,11 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
cmOutputConverter::EscapeForCMake(rccFileOptions).c_str());
makefile->AddDefinition("_qt_rcc_executable",
- cmQtAutoGenerators::GetRccExecutable(target).c_str());
+ cmQtAutoGeneratorInitializer::GetRccExecutable(target).c_str());
}
-std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target)
+std::string cmQtAutoGeneratorInitializer::GetRccExecutable(
+ cmTarget const* target)
{
cmGeneratorTarget *gtgt = target->GetMakefile()
->GetGlobalGenerator()
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index 5f8ee62..63b1c4a 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -25,12 +25,9 @@ class cmLocalGenerator;
class cmTarget;
class cmSourceFile;
-class cmQtAutoGenerators
+class cmQtAutoGeneratorInitializer
{
public:
- cmQtAutoGenerators();
- bool Run(const std::string& targetDirectory, const std::string& config);
-
static void InitializeAutogenSources(cmTarget* target);
static void InitializeAutogenTarget(cmLocalGenerator* lg, cmTarget* target);
static void SetupAutoGenerateTarget(cmTarget const* target);
@@ -53,6 +50,26 @@ private:
std::map<std::string, std::string> &configUicOptions);
static void SetupAutoRccTarget(cmTarget const* target);
+ static void MergeRccOptions(std::vector<std::string> &opts,
+ const std::vector<std::string> &fileOpts, bool isQt5);
+
+ static std::string GetRccExecutable(cmTarget const* target);
+
+ static std::string ListQt5RccInputs(cmSourceFile* sf, cmTarget const* target,
+ std::vector<std::string>& depends);
+
+ static std::string ListQt4RccInputs(cmSourceFile* sf,
+ std::vector<std::string>& depends);
+};
+
+class cmQtAutoGenerators
+{
+public:
+ cmQtAutoGenerators();
+ bool Run(const std::string& targetDirectory, const std::string& config);
+
+private:
+
bool ReadAutogenInfoFile(cmMakefile* makefile,
const std::string& targetDirectory,
const std::string& config);
@@ -100,17 +117,6 @@ private:
static void MergeUicOptions(std::vector<std::string> &opts,
const std::vector<std::string> &fileOpts, bool isQt5);
- static void MergeRccOptions(std::vector<std::string> &opts,
- const std::vector<std::string> &fileOpts, bool isQt5);
-
- static std::string GetRccExecutable(cmTarget const* target);
-
- static std::string ListQt5RccInputs(cmSourceFile* sf, cmTarget const* target,
- std::vector<std::string>& depends);
-
- static std::string ListQt4RccInputs(cmSourceFile* sf,
- std::vector<std::string>& depends);
-
bool InputFilesNewerThanQrc(const std::string& qrcFile,
const std::string& rccOutput);
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=12f0e13c5f546a721d893adedba327c18c5c9e5e
commit 12f0e13c5f546a721d893adedba327c18c5c9e5e
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Sep 26 17:50:55 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Sep 26 19:32:54 2015 +0200
QtAutogen: Simplify generator initialization API.
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 50906b8..5848a88 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1251,8 +1251,8 @@ bool cmGlobalGenerator::Compute()
#ifdef CMAKE_BUILD_WITH_CMAKE
// Iterate through all targets and set up automoc for those which have
// the AUTOMOC, AUTOUIC or AUTORCC property set
- AutogensType autogens;
- this->CreateQtAutoGeneratorsTargets(autogens);
+ std::vector<cmTarget const*> autogenTargets =
+ this->CreateQtAutoGeneratorsTargets();
#endif
unsigned int i;
@@ -1266,10 +1266,10 @@ bool cmGlobalGenerator::Compute()
this->InitGeneratorTargets();
#ifdef CMAKE_BUILD_WITH_CMAKE
- for (AutogensType::iterator it = autogens.begin(); it != autogens.end();
- ++it)
+ for (std::vector<cmTarget const*>::iterator it = autogenTargets.begin();
+ it != autogenTargets.end(); ++it)
{
- it->first.SetupAutoGenerateTarget(it->second);
+ cmQtAutoGenerators::SetupAutoGenerateTarget(*it);
}
#endif
@@ -1405,8 +1405,11 @@ bool cmGlobalGenerator::ComputeTargetDepends()
}
//----------------------------------------------------------------------------
-void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens)
+std::vector<const cmTarget*>
+cmGlobalGenerator::CreateQtAutoGeneratorsTargets()
{
+ std::vector<const cmTarget*> autogenTargets;
+
#ifdef CMAKE_BUILD_WITH_CMAKE
for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
{
@@ -1458,13 +1461,11 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens)
->GetMakefile()->FindTarget(*ti, true);
cmQtAutoGenerators::InitializeAutogenTarget(
this->LocalGenerators[i], target);
- cmQtAutoGenerators autogen;
- autogens.push_back(std::make_pair(autogen, target));
+ autogenTargets.push_back(target);
}
}
-#else
- (void)autogens;
#endif
+ return autogenTargets;
}
//----------------------------------------------------------------------------
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 83cbc3f..f3dd713 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -41,7 +41,6 @@ class cmTarget;
class cmInstallTargetGenerator;
class cmInstallFilesGenerator;
class cmExportBuildFileGenerator;
-class cmQtAutoGenerators;
/** \class cmGlobalGenerator
* \brief Responsible for overseeing the generation process for the entire tree
@@ -385,9 +384,7 @@ protected:
virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const;
- typedef std::vector<std::pair<cmQtAutoGenerators,
- cmTarget const*> > AutogensType;
- void CreateQtAutoGeneratorsTargets(AutogensType& autogens);
+ std::vector<cmTarget const*> CreateQtAutoGeneratorsTargets();
std::string SelectMakeProgram(const std::string& makeProgram,
const std::string& makeDefault = "") const;
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=65ff75d3f5bf117508ba046779cdad323e077220
commit 65ff75d3f5bf117508ba046779cdad323e077220
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Sep 26 18:11:10 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Sep 26 19:32:54 2015 +0200
QtAutogen: Remove unnecessary dereference.
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index fa9120e..50906b8 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1454,12 +1454,12 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens)
for(std::vector<std::string>::iterator ti = targetNames.begin();
ti != targetNames.end(); ++ti)
{
- cmTarget& target = *this->LocalGenerators[i]
+ cmTarget* target = this->LocalGenerators[i]
->GetMakefile()->FindTarget(*ti, true);
cmQtAutoGenerators::InitializeAutogenTarget(
- this->LocalGenerators[i], &target);
+ this->LocalGenerators[i], target);
cmQtAutoGenerators autogen;
- autogens.push_back(std::make_pair(autogen, &target));
+ autogens.push_back(std::make_pair(autogen, target));
}
}
#else
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=64b78c147fdfa6a9125371c01acfdfce3666c890
commit 64b78c147fdfa6a9125371c01acfdfce3666c890
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Sep 26 12:31:52 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Sep 26 19:32:53 2015 +0200
QtAutogen: Move Source initialization to prior loop.
Ensure that all targets have their _automoc.cpp before attempting
to initialize the autogen target. The initialization evaluates
generator expressions for target sources, and must include the
_automoc.cpp of object library dependents in order for TARGET_OBJECTS
to include the object file for the corresponding _automoc.cpp file.
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 6627bcc..fa9120e 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1448,6 +1448,7 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens)
continue;
}
+ cmQtAutoGenerators::InitializeAutogenSources(&ti->second);
targetNames.push_back(ti->second.GetName());
}
for(std::vector<std::string>::iterator ti = targetNames.begin();
@@ -1455,8 +1456,6 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens)
{
cmTarget& target = *this->LocalGenerators[i]
->GetMakefile()->FindTarget(*ti, true);
-
- cmQtAutoGenerators::InitializeAutogenSources(&target);
cmQtAutoGenerators::InitializeAutogenTarget(
this->LocalGenerators[i], &target);
cmQtAutoGenerators autogen;
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c3c20d3ce3acbf6afd6a54dd846fd78b82623312
commit c3c20d3ce3acbf6afd6a54dd846fd78b82623312
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Sep 20 17:00:58 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Sep 26 19:32:53 2015 +0200
QtAutogen: Add _automoc.cpp sources before initializing.
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 435b769..6627bcc 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1456,6 +1456,7 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens)
cmTarget& target = *this->LocalGenerators[i]
->GetMakefile()->FindTarget(*ti, true);
+ cmQtAutoGenerators::InitializeAutogenSources(&target);
cmQtAutoGenerators::InitializeAutogenTarget(
this->LocalGenerators[i], &target);
cmQtAutoGenerators autogen;
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 04d7bbc..9bec68a 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -286,8 +286,8 @@ std::string cmQtAutoGenerators::ListQt4RccInputs(cmSourceFile* sf,
return entriesList;
}
-void cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg,
- cmTarget* target)
+
+void cmQtAutoGenerators::InitializeAutogenSources(cmTarget* target)
{
cmMakefile* makefile = target->GetMakefile();
@@ -304,6 +304,19 @@ void cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg,
target->AddSource(mocCppFile);
}
+}
+
+void cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg,
+ cmTarget* target)
+{
+ cmMakefile* makefile = target->GetMakefile();
+
+ std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR");
+ if (qtMajorVersion == "")
+ {
+ qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR");
+ }
+
// create a custom target for running generators at buildtime:
std::string autogenTargetName = getAutogenTargetName(target);
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index ff048c8..5f8ee62 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -31,6 +31,7 @@ public:
cmQtAutoGenerators();
bool Run(const std::string& targetDirectory, const std::string& config);
+ static void InitializeAutogenSources(cmTarget* target);
static void InitializeAutogenTarget(cmLocalGenerator* lg, cmTarget* target);
static void SetupAutoGenerateTarget(cmTarget const* target);
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8b6ec29d4096b4ea59ef502360845e25a9bcb47e
commit 8b6ec29d4096b4ea59ef502360845e25a9bcb47e
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Sep 20 16:55:47 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Sep 26 19:32:53 2015 +0200
QtAutogen: Move initialization condition to caller.
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index f9a65ee..435b769 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1436,6 +1436,18 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens)
{
continue;
}
+ // don't do anything if there is no Qt4 or Qt5Core (which contains moc):
+ cmMakefile* mf = ti->second.GetMakefile();
+ std::string qtMajorVersion = mf->GetSafeDefinition("QT_VERSION_MAJOR");
+ if (qtMajorVersion == "")
+ {
+ qtMajorVersion = mf->GetSafeDefinition("Qt5Core_VERSION_MAJOR");
+ }
+ if (qtMajorVersion != "4" && qtMajorVersion != "5")
+ {
+ continue;
+ }
+
targetNames.push_back(ti->second.GetName());
}
for(std::vector<std::string>::iterator ti = targetNames.begin();
@@ -1444,12 +1456,10 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens)
cmTarget& target = *this->LocalGenerators[i]
->GetMakefile()->FindTarget(*ti, true);
- if(cmQtAutoGenerators::InitializeAutogenTarget(
- this->LocalGenerators[i], &target))
- {
- cmQtAutoGenerators autogen;
- autogens.push_back(std::make_pair(autogen, &target));
- }
+ cmQtAutoGenerators::InitializeAutogenTarget(
+ this->LocalGenerators[i], &target);
+ cmQtAutoGenerators autogen;
+ autogens.push_back(std::make_pair(autogen, &target));
}
}
#else
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 6fee69e..04d7bbc 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -286,20 +286,10 @@ std::string cmQtAutoGenerators::ListQt4RccInputs(cmSourceFile* sf,
return entriesList;
}
-bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg,
+void cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg,
cmTarget* target)
{
cmMakefile* makefile = target->GetMakefile();
- // don't do anything if there is no Qt4 or Qt5Core (which contains moc):
- std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR");
- if (qtMajorVersion == "")
- {
- qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR");
- }
- if (qtMajorVersion != "4" && qtMajorVersion != "5")
- {
- return false;
- }
if (target->GetPropertyAsBool("AUTOMOC"))
{
@@ -499,8 +489,6 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg,
target->AddUtility(autogenTargetName);
}
-
- return true;
}
static void GetCompileDefinitionsAndDirectories(cmTarget const* target,
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index 02b6fdf..ff048c8 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -31,7 +31,7 @@ public:
cmQtAutoGenerators();
bool Run(const std::string& targetDirectory, const std::string& config);
- static bool InitializeAutogenTarget(cmLocalGenerator* lg, cmTarget* target);
+ static void InitializeAutogenTarget(cmLocalGenerator* lg, cmTarget* target);
static void SetupAutoGenerateTarget(cmTarget const* target);
private:
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9470b056fc0be0910f90230e0635d4a2e2baa81a
commit 9470b056fc0be0910f90230e0635d4a2e2baa81a
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Sep 20 16:52:32 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Sep 26 19:32:53 2015 +0200
QtAutogen: Move condition to prior loop.
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 82d8d39..f9a65ee 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1429,6 +1429,13 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens)
{
continue;
}
+ if((!ti->second.GetPropertyAsBool("AUTOMOC")
+ && !ti->second.GetPropertyAsBool("AUTOUIC")
+ && !ti->second.GetPropertyAsBool("AUTORCC"))
+ || ti->second.IsImported())
+ {
+ continue;
+ }
targetNames.push_back(ti->second.GetName());
}
for(std::vector<std::string>::iterator ti = targetNames.begin();
@@ -1436,17 +1443,12 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens)
{
cmTarget& target = *this->LocalGenerators[i]
->GetMakefile()->FindTarget(*ti, true);
- if((target.GetPropertyAsBool("AUTOMOC")
- || target.GetPropertyAsBool("AUTOUIC")
- || target.GetPropertyAsBool("AUTORCC"))
- && !target.IsImported())
+
+ if(cmQtAutoGenerators::InitializeAutogenTarget(
+ this->LocalGenerators[i], &target))
{
- if(cmQtAutoGenerators::InitializeAutogenTarget(
- this->LocalGenerators[i], &target))
- {
- cmQtAutoGenerators autogen;
- autogens.push_back(std::make_pair(autogen, &target));
- }
+ cmQtAutoGenerators autogen;
+ autogens.push_back(std::make_pair(autogen, &target));
}
}
}
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b7491b1cda7096aa914c79a1b2fc7768e90aa951
commit b7491b1cda7096aa914c79a1b2fc7768e90aa951
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Sep 20 16:50:25 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Sep 26 19:32:52 2015 +0200
QtAutogen: Move condition to prior loop.
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 20d86a0..82d8d39 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1421,6 +1421,14 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens)
{
continue;
}
+ if(ti->second.GetType() != cmTarget::EXECUTABLE &&
+ ti->second.GetType() != cmTarget::STATIC_LIBRARY &&
+ ti->second.GetType() != cmTarget::SHARED_LIBRARY &&
+ ti->second.GetType() != cmTarget::MODULE_LIBRARY &&
+ ti->second.GetType() != cmTarget::OBJECT_LIBRARY)
+ {
+ continue;
+ }
targetNames.push_back(ti->second.GetName());
}
for(std::vector<std::string>::iterator ti = targetNames.begin();
@@ -1428,23 +1436,16 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens)
{
cmTarget& target = *this->LocalGenerators[i]
->GetMakefile()->FindTarget(*ti, true);
- if(target.GetType() == cmTarget::EXECUTABLE ||
- target.GetType() == cmTarget::STATIC_LIBRARY ||
- target.GetType() == cmTarget::SHARED_LIBRARY ||
- target.GetType() == cmTarget::MODULE_LIBRARY ||
- target.GetType() == cmTarget::OBJECT_LIBRARY)
+ if((target.GetPropertyAsBool("AUTOMOC")
+ || target.GetPropertyAsBool("AUTOUIC")
+ || target.GetPropertyAsBool("AUTORCC"))
+ && !target.IsImported())
{
- if((target.GetPropertyAsBool("AUTOMOC")
- || target.GetPropertyAsBool("AUTOUIC")
- || target.GetPropertyAsBool("AUTORCC"))
- && !target.IsImported())
+ if(cmQtAutoGenerators::InitializeAutogenTarget(
+ this->LocalGenerators[i], &target))
{
- if(cmQtAutoGenerators::InitializeAutogenTarget(
- this->LocalGenerators[i], &target))
- {
- cmQtAutoGenerators autogen;
- autogens.push_back(std::make_pair(autogen, &target));
- }
+ cmQtAutoGenerators autogen;
+ autogens.push_back(std::make_pair(autogen, &target));
}
}
}
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e791c85419e81b937f0c1215073b2d09ee6c1555
commit e791c85419e81b937f0c1215073b2d09ee6c1555
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sun Sep 20 16:40:49 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Sep 26 19:32:52 2015 +0200
QtAutogen: Make some methods static.
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 3589e82..20d86a0 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1439,10 +1439,10 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens)
|| target.GetPropertyAsBool("AUTORCC"))
&& !target.IsImported())
{
- cmQtAutoGenerators autogen;
- if(autogen.InitializeAutogenTarget(this->LocalGenerators[i],
- &target))
+ if(cmQtAutoGenerators::InitializeAutogenTarget(
+ this->LocalGenerators[i], &target))
{
+ cmQtAutoGenerators autogen;
autogens.push_back(std::make_pair(autogen, &target));
}
}
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 197f92a..6fee69e 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -184,7 +184,7 @@ std::string cmQtAutoGenerators::ListQt5RccInputs(cmSourceFile* sf,
cmTarget const* target,
std::vector<std::string>& depends)
{
- std::string rccCommand = this->GetRccExecutable(target);
+ std::string rccCommand = cmQtAutoGenerators::GetRccExecutable(target);
std::vector<std::string> qrcEntries;
std::vector<std::string> command;
@@ -434,11 +434,11 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg,
{
if (qtMajorVersion == "5")
{
- this->ListQt5RccInputs(sf, target, depends);
+ cmQtAutoGenerators::ListQt5RccInputs(sf, target, depends);
}
else
{
- this->ListQt4RccInputs(sf, depends);
+ cmQtAutoGenerators::ListQt4RccInputs(sf, depends);
}
#if defined(_WIN32) && !defined(__CYGWIN__)
// Cannot use PRE_BUILD because the resource files themselves
@@ -573,23 +573,24 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target)
|| target->GetPropertyAsBool("AUTOUIC")
|| target->GetPropertyAsBool("AUTORCC"))
{
- this->SetupSourceFiles(target, skipMoc, mocSources, mocHeaders, skipUic);
+ cmQtAutoGenerators::SetupSourceFiles(target, skipMoc,
+ mocSources, mocHeaders, skipUic);
}
makefile->AddDefinition("_cpp_files",
cmOutputConverter::EscapeForCMake(cmJoin(mocSources, ";")).c_str());
if (target->GetPropertyAsBool("AUTOMOC"))
{
- this->SetupAutoMocTarget(target, autogenTargetName,
+ cmQtAutoGenerators::SetupAutoMocTarget(target, autogenTargetName,
skipMoc, mocHeaders,
configIncludes, configDefines);
}
if (target->GetPropertyAsBool("AUTOUIC"))
{
- this->SetupAutoUicTarget(target, skipUic, configUicOptions);
+ cmQtAutoGenerators::SetupAutoUicTarget(target, skipUic, configUicOptions);
}
if (target->GetPropertyAsBool("AUTORCC"))
{
- this->SetupAutoRccTarget(target);
+ cmQtAutoGenerators::SetupAutoRccTarget(target);
}
const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT");
@@ -1095,7 +1096,7 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
{
std::vector<std::string> optsVec;
cmSystemTools::ExpandListArgument(prop, optsVec);
- this->MergeRccOptions(rccOptions, optsVec,
+ cmQtAutoGenerators::MergeRccOptions(rccOptions, optsVec,
strcmp(qtVersion, "5") == 0);
}
@@ -1123,11 +1124,12 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
{
if (qtMajorVersion == "5")
{
- entriesList = this->ListQt5RccInputs(sf, target, depends);
+ entriesList = cmQtAutoGenerators::ListQt5RccInputs(sf, target,
+ depends);
}
else
{
- entriesList = this->ListQt4RccInputs(sf, depends);
+ entriesList = cmQtAutoGenerators::ListQt4RccInputs(sf, depends);
}
if (entriesList.empty())
{
@@ -1152,7 +1154,7 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
cmOutputConverter::EscapeForCMake(rccFileOptions).c_str());
makefile->AddDefinition("_qt_rcc_executable",
- this->GetRccExecutable(target).c_str());
+ cmQtAutoGenerators::GetRccExecutable(target).c_str());
}
std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target)
@@ -2248,7 +2250,8 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
{
std::vector<std::string> fileOpts;
cmSystemTools::ExpandListArgument(optionIt->second, fileOpts);
- this->MergeUicOptions(opts, fileOpts, this->QtMajorVersion == "5");
+ cmQtAutoGenerators::MergeUicOptions(opts, fileOpts,
+ this->QtMajorVersion == "5");
}
command.insert(command.end(), opts.begin(), opts.end());
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index 93ff0ba..02b6fdf 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -31,26 +31,26 @@ public:
cmQtAutoGenerators();
bool Run(const std::string& targetDirectory, const std::string& config);
- bool InitializeAutogenTarget(cmLocalGenerator* lg, cmTarget* target);
- void SetupAutoGenerateTarget(cmTarget const* target);
+ static bool InitializeAutogenTarget(cmLocalGenerator* lg, cmTarget* target);
+ static void SetupAutoGenerateTarget(cmTarget const* target);
private:
- void SetupSourceFiles(cmTarget const* target,
+ static void SetupSourceFiles(cmTarget const* target,
std::vector<std::string>& skipMoc,
std::vector<std::string>& mocSources,
std::vector<std::string>& mocHeaders,
std::vector<std::string>& skipUic);
- void SetupAutoMocTarget(cmTarget const* target,
+ static void SetupAutoMocTarget(cmTarget const* target,
const std::string &autogenTargetName,
const std::vector<std::string>& skipMoc,
const std::vector<std::string>& mocHeaders,
std::map<std::string, std::string> &configIncludes,
std::map<std::string, std::string> &configDefines);
- void SetupAutoUicTarget(cmTarget const* target,
+ static void SetupAutoUicTarget(cmTarget const* target,
const std::vector<std::string>& skipUic,
std::map<std::string, std::string> &configUicOptions);
- void SetupAutoRccTarget(cmTarget const* target);
+ static void SetupAutoRccTarget(cmTarget const* target);
bool ReadAutogenInfoFile(cmMakefile* makefile,
const std::string& targetDirectory,
@@ -96,18 +96,18 @@ private:
bool EndsWith(const std::string& str, const std::string& with);
bool StartsWith(const std::string& str, const std::string& with);
- void MergeUicOptions(std::vector<std::string> &opts,
+ static void MergeUicOptions(std::vector<std::string> &opts,
const std::vector<std::string> &fileOpts, bool isQt5);
- void MergeRccOptions(std::vector<std::string> &opts,
+ static void MergeRccOptions(std::vector<std::string> &opts,
const std::vector<std::string> &fileOpts, bool isQt5);
- std::string GetRccExecutable(cmTarget const* target);
+ static std::string GetRccExecutable(cmTarget const* target);
- std::string ListQt5RccInputs(cmSourceFile* sf, cmTarget const* target,
+ static std::string ListQt5RccInputs(cmSourceFile* sf, cmTarget const* target,
std::vector<std::string>& depends);
- std::string ListQt4RccInputs(cmSourceFile* sf,
+ static std::string ListQt4RccInputs(cmSourceFile* sf,
std::vector<std::string>& depends);
bool InputFilesNewerThanQrc(const std::string& qrcFile,
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6210ec644ae3a9e602a24e87d86da7d0b2942d21
commit 6210ec644ae3a9e602a24e87d86da7d0b2942d21
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Sep 26 18:40:10 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Sep 26 19:32:52 2015 +0200
QtAutogen: Make internal method private.
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index 6741139..93ff0ba 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -33,13 +33,14 @@ public:
bool InitializeAutogenTarget(cmLocalGenerator* lg, cmTarget* target);
void SetupAutoGenerateTarget(cmTarget const* target);
+
+private:
void SetupSourceFiles(cmTarget const* target,
std::vector<std::string>& skipMoc,
std::vector<std::string>& mocSources,
std::vector<std::string>& mocHeaders,
std::vector<std::string>& skipUic);
-private:
void SetupAutoMocTarget(cmTarget const* target,
const std::string &autogenTargetName,
const std::vector<std::string>& skipMoc,
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a3ceb998d7768592b670abd2a8d0dd2777c84789
commit a3ceb998d7768592b670abd2a8d0dd2777c84789
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Sep 26 19:25:00 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Sep 26 19:32:50 2015 +0200
QtAutogen: Don't use members to initialize automoc targets.
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index c069a49..197f92a 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -562,6 +562,9 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target)
}
std::vector<std::string> skipUic;
+ std::vector<std::string> skipMoc;
+ std::vector<std::string> mocSources;
+ std::vector<std::string> mocHeaders;
std::map<std::string, std::string> configIncludes;
std::map<std::string, std::string> configDefines;
std::map<std::string, std::string> configUicOptions;
@@ -570,13 +573,14 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target)
|| target->GetPropertyAsBool("AUTOUIC")
|| target->GetPropertyAsBool("AUTORCC"))
{
- this->SetupSourceFiles(target, skipUic);
+ this->SetupSourceFiles(target, skipMoc, mocSources, mocHeaders, skipUic);
}
makefile->AddDefinition("_cpp_files",
- cmOutputConverter::EscapeForCMake(this->Sources).c_str());
+ cmOutputConverter::EscapeForCMake(cmJoin(mocSources, ";")).c_str());
if (target->GetPropertyAsBool("AUTOMOC"))
{
this->SetupAutoMocTarget(target, autogenTargetName,
+ skipMoc, mocHeaders,
configIncludes, configDefines);
}
if (target->GetPropertyAsBool("AUTOUIC"))
@@ -657,21 +661,19 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target)
}
void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target,
- std::vector<std::string>& skipUic)
+ std::vector<std::string>& skipMoc,
+ std::vector<std::string>& mocSources,
+ std::vector<std::string>& mocHeaders,
+ std::vector<std::string>& skipUic)
{
cmMakefile* makefile = target->GetMakefile();
- const char* sepFiles = "";
- const char* sepHeaders = "";
-
std::vector<cmSourceFile*> srcFiles;
cmGeneratorTarget *gtgt = target->GetMakefile()
->GetGlobalGenerator()
->GetGeneratorTarget(target);
gtgt->GetConfigCommonSourceFiles(srcFiles);
- const char *skipMocSep = "";
-
std::vector<std::string> newRccFiles;
for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
@@ -715,9 +717,7 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target,
{
if (skipFileForMoc)
{
- this->SkipMoc += skipMocSep;
- this->SkipMoc += absFile;
- skipMocSep = ";";
+ skipMoc.push_back(absFile);
}
else
{
@@ -725,15 +725,11 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target,
ext.c_str());
if (fileType == cmSystemTools::CXX_FILE_FORMAT)
{
- this->Sources += sepFiles;
- this->Sources += absFile;
- sepFiles = ";";
+ mocSources.push_back(absFile);
}
else if (fileType == cmSystemTools::HEADER_FILE_FORMAT)
{
- this->Headers += sepHeaders;
- this->Headers += absFile;
- sepHeaders = ";";
+ mocHeaders.push_back(absFile);
}
}
}
@@ -749,6 +745,8 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target,
void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target,
const std::string &autogenTargetName,
+ std::vector<std::string> const& skipMoc,
+ std::vector<std::string> const& mocHeaders,
std::map<std::string, std::string> &configIncludes,
std::map<std::string, std::string> &configDefines)
{
@@ -759,9 +757,9 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target,
makefile->AddDefinition("_moc_options",
cmOutputConverter::EscapeForCMake(_moc_options).c_str());
makefile->AddDefinition("_skip_moc",
- cmOutputConverter::EscapeForCMake(this->SkipMoc).c_str());
+ cmOutputConverter::EscapeForCMake(cmJoin(skipMoc, ";")).c_str());
makefile->AddDefinition("_moc_headers",
- cmOutputConverter::EscapeForCMake(this->Headers).c_str());
+ cmOutputConverter::EscapeForCMake(cmJoin(mocHeaders, ";")).c_str());
bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE");
makefile->AddDefinition("_moc_relaxed_mode", relaxedMode ? "TRUE" : "FALSE");
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index c1dac2b..6741139 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -34,11 +34,16 @@ public:
bool InitializeAutogenTarget(cmLocalGenerator* lg, cmTarget* target);
void SetupAutoGenerateTarget(cmTarget const* target);
void SetupSourceFiles(cmTarget const* target,
+ std::vector<std::string>& skipMoc,
+ std::vector<std::string>& mocSources,
+ std::vector<std::string>& mocHeaders,
std::vector<std::string>& skipUic);
private:
void SetupAutoMocTarget(cmTarget const* target,
const std::string &autogenTargetName,
+ const std::vector<std::string>& skipMoc,
+ const std::vector<std::string>& mocHeaders,
std::map<std::string, std::string> &configIncludes,
std::map<std::string, std::string> &configDefines);
void SetupAutoUicTarget(cmTarget const* target,
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dced2fe10f55222ece04c12693d68e13e30771d0
commit dced2fe10f55222ece04c12693d68e13e30771d0
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Sep 26 19:21:49 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Sep 26 19:21:49 2015 +0200
QtAutogen: Rename variable.
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index f48c0bc..c069a49 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -681,7 +681,8 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target,
cmSourceFile* sf = *fileIt;
std::string absFile = cmsys::SystemTools::GetRealPath(
sf->GetFullPath());
- bool skipMoc = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC"));
+ bool skipFileForMoc =
+ cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC"));
bool generated = cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"));
if(cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOUIC")))
@@ -712,7 +713,7 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target,
if (!generated)
{
- if (skipMoc)
+ if (skipFileForMoc)
{
this->SkipMoc += skipMocSep;
this->SkipMoc += absFile;
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f9a77e76e4e1c19c094ff770487e677a92a1198b
commit f9a77e76e4e1c19c094ff770487e677a92a1198b
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Sep 26 18:27:44 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Sep 26 18:48:23 2015 +0200
QtAutogen: Don't use a member to store skipped uic files.
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index becfeba..f48c0bc 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -561,6 +561,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target)
makefile->AddDefinition("_target_qt_version", qtVersion);
}
+ std::vector<std::string> skipUic;
std::map<std::string, std::string> configIncludes;
std::map<std::string, std::string> configDefines;
std::map<std::string, std::string> configUicOptions;
@@ -569,7 +570,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target)
|| target->GetPropertyAsBool("AUTOUIC")
|| target->GetPropertyAsBool("AUTORCC"))
{
- this->SetupSourceFiles(target);
+ this->SetupSourceFiles(target, skipUic);
}
makefile->AddDefinition("_cpp_files",
cmOutputConverter::EscapeForCMake(this->Sources).c_str());
@@ -580,7 +581,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target)
}
if (target->GetPropertyAsBool("AUTOUIC"))
{
- this->SetupAutoUicTarget(target, configUicOptions);
+ this->SetupAutoUicTarget(target, skipUic, configUicOptions);
}
if (target->GetPropertyAsBool("AUTORCC"))
{
@@ -655,7 +656,8 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target)
}
}
-void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target)
+void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target,
+ std::vector<std::string>& skipUic)
{
cmMakefile* makefile = target->GetMakefile();
@@ -669,7 +671,6 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target)
gtgt->GetConfigCommonSourceFiles(srcFiles);
const char *skipMocSep = "";
- const char *skipUicSep = "";
std::vector<std::string> newRccFiles;
@@ -685,9 +686,7 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target)
if(cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOUIC")))
{
- this->SkipUic += skipUicSep;
- this->SkipUic += absFile;
- skipUicSep = ";";
+ skipUic.push_back(absFile);
}
std::string ext = sf->GetExtension();
@@ -894,17 +893,16 @@ static void GetUicOpts(cmTarget const* target, const std::string& config,
}
void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,
+ std::vector<std::string> const& skipUic,
std::map<std::string, std::string> &configUicOptions)
{
cmMakefile *makefile = target->GetMakefile();
std::set<std::string> skipped;
- std::vector<std::string> skipVec;
- cmSystemTools::ExpandListArgument(this->SkipUic, skipVec);
- skipped.insert(skipVec.begin(), skipVec.end());
+ skipped.insert(skipUic.begin(), skipUic.end());
makefile->AddDefinition("_skip_uic",
- cmOutputConverter::EscapeForCMake(this->SkipUic).c_str());
+ cmOutputConverter::EscapeForCMake(cmJoin(skipUic, ";")).c_str());
std::vector<cmSourceFile*> uiFilesWithOptions
= makefile->GetQtUiFilesWithOptions();
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index 25e045f..c1dac2b 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -33,7 +33,8 @@ public:
bool InitializeAutogenTarget(cmLocalGenerator* lg, cmTarget* target);
void SetupAutoGenerateTarget(cmTarget const* target);
- void SetupSourceFiles(cmTarget const* target);
+ void SetupSourceFiles(cmTarget const* target,
+ std::vector<std::string>& skipUic);
private:
void SetupAutoMocTarget(cmTarget const* target,
@@ -41,6 +42,7 @@ private:
std::map<std::string, std::string> &configIncludes,
std::map<std::string, std::string> &configDefines);
void SetupAutoUicTarget(cmTarget const* target,
+ const std::vector<std::string>& skipUic,
std::map<std::string, std::string> &configUicOptions);
void SetupAutoRccTarget(cmTarget const* target);
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c3633e7a416373e6c8e8f87b4920a8a41c5afd82
commit c3633e7a416373e6c8e8f87b4920a8a41c5afd82
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Sep 26 12:51:46 2015 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Sep 26 18:48:23 2015 +0200
QtAutogen: Add missing includes and forward declarations.
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index 4f03348..25e045f 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -15,10 +15,15 @@
#define cmQtAutoGenerators_h
#include <list>
+#include <vector>
+#include <string>
+#include <map>
class cmGlobalGenerator;
class cmMakefile;
class cmLocalGenerator;
+class cmTarget;
+class cmSourceFile;
class cmQtAutoGenerators
{
-----------------------------------------------------------------------
Summary of changes:
Source/CMakeLists.txt | 2 +
Source/cmGlobalGenerator.cxx | 72 ++-
Source/cmGlobalGenerator.h | 5 +-
Source/cmQtAutoGeneratorInitializer.cxx | 1070 +++++++++++++++++++++++++++++++
Source/cmQtAutoGeneratorInitializer.h | 65 ++
Source/cmQtAutoGenerators.cxx | 1047 +-----------------------------
Source/cmQtAutoGenerators.h | 29 +-
7 files changed, 1198 insertions(+), 1092 deletions(-)
create mode 100644 Source/cmQtAutoGeneratorInitializer.cxx
create mode 100644 Source/cmQtAutoGeneratorInitializer.h
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list