Merge topic 'simplify-qt-autogen'

1fe39020 QtAutogen: Port away from cmLocalGenerator.
59a729b2 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.
This commit is contained in:
Brad King 2015-09-29 10:08:10 -04:00 committed by CMake Topic Stage
commit ee1b041108
7 changed files with 1208 additions and 1107 deletions

View File

@ -327,6 +327,8 @@ set(SRCS
cmPropertyDefinitionMap.h cmPropertyDefinitionMap.h
cmPropertyMap.cxx cmPropertyMap.cxx
cmPropertyMap.h cmPropertyMap.h
cmQtAutoGeneratorInitializer.cxx
cmQtAutoGeneratorInitializer.h
cmQtAutoGenerators.cxx cmQtAutoGenerators.cxx
cmQtAutoGenerators.h cmQtAutoGenerators.h
cmRST.cxx cmRST.cxx

View File

@ -22,7 +22,7 @@
#include "cmake.h" #include "cmake.h"
#include "cmState.h" #include "cmState.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmQtAutoGenerators.h" #include "cmQtAutoGeneratorInitializer.h"
#include "cmSourceFile.h" #include "cmSourceFile.h"
#include "cmVersion.h" #include "cmVersion.h"
#include "cmTargetExport.h" #include "cmTargetExport.h"
@ -1251,8 +1251,8 @@ bool cmGlobalGenerator::Compute()
#ifdef CMAKE_BUILD_WITH_CMAKE #ifdef CMAKE_BUILD_WITH_CMAKE
// Iterate through all targets and set up automoc for those which have // Iterate through all targets and set up automoc for those which have
// the AUTOMOC, AUTOUIC or AUTORCC property set // the AUTOMOC, AUTOUIC or AUTORCC property set
AutogensType autogens; std::vector<cmTarget const*> autogenTargets =
this->CreateQtAutoGeneratorsTargets(autogens); this->CreateQtAutoGeneratorsTargets();
#endif #endif
unsigned int i; unsigned int i;
@ -1266,10 +1266,10 @@ bool cmGlobalGenerator::Compute()
this->InitGeneratorTargets(); this->InitGeneratorTargets();
#ifdef CMAKE_BUILD_WITH_CMAKE #ifdef CMAKE_BUILD_WITH_CMAKE
for (AutogensType::iterator it = autogens.begin(); it != autogens.end(); for (std::vector<cmTarget const*>::iterator it = autogenTargets.begin();
++it) it != autogenTargets.end(); ++it)
{ {
it->first.SetupAutoGenerateTarget(it->second); cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(*it);
} }
#endif #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 #ifdef CMAKE_BUILD_WITH_CMAKE
for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
{ {
@ -1421,37 +1424,48 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens)
{ {
continue; 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;
}
if((!ti->second.GetPropertyAsBool("AUTOMOC")
&& !ti->second.GetPropertyAsBool("AUTOUIC")
&& !ti->second.GetPropertyAsBool("AUTORCC"))
|| ti->second.IsImported())
{
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;
}
cmQtAutoGeneratorInitializer::InitializeAutogenSources(&ti->second);
targetNames.push_back(ti->second.GetName()); targetNames.push_back(ti->second.GetName());
} }
for(std::vector<std::string>::iterator ti = targetNames.begin(); for(std::vector<std::string>::iterator ti = targetNames.begin();
ti != targetNames.end(); ++ti) ti != targetNames.end(); ++ti)
{ {
cmTarget& target = *this->LocalGenerators[i] cmTarget* target = this->LocalGenerators[i]
->GetMakefile()->FindTarget(*ti, true); ->GetMakefile()->FindTarget(*ti, true);
if(target.GetType() == cmTarget::EXECUTABLE || cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
target.GetType() == cmTarget::STATIC_LIBRARY || this->LocalGenerators[i], target);
target.GetType() == cmTarget::SHARED_LIBRARY || autogenTargets.push_back(target);
target.GetType() == cmTarget::MODULE_LIBRARY ||
target.GetType() == cmTarget::OBJECT_LIBRARY)
{
if((target.GetPropertyAsBool("AUTOMOC")
|| target.GetPropertyAsBool("AUTOUIC")
|| target.GetPropertyAsBool("AUTORCC"))
&& !target.IsImported())
{
cmQtAutoGenerators autogen;
if(autogen.InitializeAutogenTarget(this->LocalGenerators[i],
&target))
{
autogens.push_back(std::make_pair(autogen, &target));
}
}
}
} }
} }
#else
(void)autogens;
#endif #endif
return autogenTargets;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -41,7 +41,6 @@ class cmTarget;
class cmInstallTargetGenerator; class cmInstallTargetGenerator;
class cmInstallFilesGenerator; class cmInstallFilesGenerator;
class cmExportBuildFileGenerator; class cmExportBuildFileGenerator;
class cmQtAutoGenerators;
/** \class cmGlobalGenerator /** \class cmGlobalGenerator
* \brief Responsible for overseeing the generation process for the entire tree * \brief Responsible for overseeing the generation process for the entire tree
@ -385,9 +384,7 @@ protected:
virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const; virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const;
typedef std::vector<std::pair<cmQtAutoGenerators, std::vector<cmTarget const*> CreateQtAutoGeneratorsTargets();
cmTarget const*> > AutogensType;
void CreateQtAutoGeneratorsTargets(AutogensType& autogens);
std::string SelectMakeProgram(const std::string& makeProgram, std::string SelectMakeProgram(const std::string& makeProgram,
const std::string& makeDefault = "") const; const std::string& makeDefault = "") const;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,67 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2004-2011 Kitware, Inc.
Copyright 2011 Alexander Neundorf (neundorf@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 "cmStandardIncludes.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

File diff suppressed because it is too large Load Diff

View File

@ -15,10 +15,11 @@
#define cmQtAutoGenerators_h #define cmQtAutoGenerators_h
#include <list> #include <list>
#include <vector>
#include <string>
#include <map>
class cmGlobalGenerator;
class cmMakefile; class cmMakefile;
class cmLocalGenerator;
class cmQtAutoGenerators class cmQtAutoGenerators
{ {
@ -26,18 +27,7 @@ public:
cmQtAutoGenerators(); cmQtAutoGenerators();
bool Run(const std::string& targetDirectory, const std::string& config); bool Run(const std::string& targetDirectory, const std::string& config);
bool InitializeAutogenTarget(cmLocalGenerator* lg, cmTarget* target);
void SetupAutoGenerateTarget(cmTarget const* target);
void SetupSourceFiles(cmTarget const* target);
private: private:
void SetupAutoMocTarget(cmTarget const* target,
const std::string &autogenTargetName,
std::map<std::string, std::string> &configIncludes,
std::map<std::string, std::string> &configDefines);
void SetupAutoUicTarget(cmTarget const* target,
std::map<std::string, std::string> &configUicOptions);
void SetupAutoRccTarget(cmTarget const* target);
bool ReadAutogenInfoFile(cmMakefile* makefile, bool ReadAutogenInfoFile(cmMakefile* makefile,
const std::string& targetDirectory, const std::string& targetDirectory,
@ -83,20 +73,9 @@ private:
bool EndsWith(const std::string& str, const std::string& with); bool EndsWith(const std::string& str, const std::string& with);
bool StartsWith(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); const std::vector<std::string> &fileOpts, bool isQt5);
void MergeRccOptions(std::vector<std::string> &opts,
const std::vector<std::string> &fileOpts, bool isQt5);
std::string GetRccExecutable(cmTarget const* target);
std::string ListQt5RccInputs(cmSourceFile* sf, cmTarget const* target,
std::vector<std::string>& depends);
std::string ListQt4RccInputs(cmSourceFile* sf,
std::vector<std::string>& depends);
bool InputFilesNewerThanQrc(const std::string& qrcFile, bool InputFilesNewerThanQrc(const std::string& qrcFile,
const std::string& rccOutput); const std::string& rccOutput);