QtAutogen: Port API to cmGeneratorTarget.
This commit is contained in:
parent
f7738fd122
commit
15c02cf14e
|
@ -1267,7 +1267,7 @@ bool cmGlobalGenerator::Compute()
|
||||||
for (std::vector<cmGeneratorTarget const*>::iterator it =
|
for (std::vector<cmGeneratorTarget const*>::iterator it =
|
||||||
autogenTargets.begin(); it != autogenTargets.end(); ++it)
|
autogenTargets.begin(); it != autogenTargets.end(); ++it)
|
||||||
{
|
{
|
||||||
cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget((*it)->Target);
|
cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(*it);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1451,15 +1451,14 @@ cmGlobalGenerator::CreateQtAutoGeneratorsTargets()
|
||||||
|
|
||||||
cmGeneratorTarget* gt = this->GetGeneratorTarget(&ti->second);
|
cmGeneratorTarget* gt = this->GetGeneratorTarget(&ti->second);
|
||||||
|
|
||||||
cmQtAutoGeneratorInitializer::InitializeAutogenSources(gt->Target);
|
cmQtAutoGeneratorInitializer::InitializeAutogenSources(gt);
|
||||||
filteredTargets.push_back(gt);
|
filteredTargets.push_back(gt);
|
||||||
}
|
}
|
||||||
for(std::vector<cmGeneratorTarget*>::iterator ti = filteredTargets.begin();
|
for(std::vector<cmGeneratorTarget*>::iterator ti = filteredTargets.begin();
|
||||||
ti != filteredTargets.end(); ++ti)
|
ti != filteredTargets.end(); ++ti)
|
||||||
{
|
{
|
||||||
cmTarget* target = (*ti)->Target;
|
|
||||||
cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
|
cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
|
||||||
this->LocalGenerators[i], target);
|
this->LocalGenerators[i], *ti);
|
||||||
autogenTargets.push_back(*ti);
|
autogenTargets.push_back(*ti);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,19 +25,16 @@
|
||||||
# include "cmGlobalVisualStudioGenerator.h"
|
# include "cmGlobalVisualStudioGenerator.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void SetupSourceFiles(cmTarget const* target,
|
static void SetupSourceFiles(cmGeneratorTarget const* target,
|
||||||
std::vector<std::string>& skipMoc,
|
std::vector<std::string>& skipMoc,
|
||||||
std::vector<std::string>& mocSources,
|
std::vector<std::string>& mocSources,
|
||||||
std::vector<std::string>& mocHeaders,
|
std::vector<std::string>& mocHeaders,
|
||||||
std::vector<std::string>& skipUic)
|
std::vector<std::string>& skipUic)
|
||||||
{
|
{
|
||||||
cmMakefile* makefile = target->GetMakefile();
|
cmMakefile* makefile = target->Target->GetMakefile();
|
||||||
|
|
||||||
std::vector<cmSourceFile*> srcFiles;
|
std::vector<cmSourceFile*> srcFiles;
|
||||||
cmGeneratorTarget *gtgt = target->GetMakefile()
|
target->GetConfigCommonSourceFiles(srcFiles);
|
||||||
->GetGlobalGenerator()
|
|
||||||
->GetGeneratorTarget(target);
|
|
||||||
gtgt->GetConfigCommonSourceFiles(srcFiles);
|
|
||||||
|
|
||||||
std::vector<std::string> newRccFiles;
|
std::vector<std::string> newRccFiles;
|
||||||
|
|
||||||
|
@ -67,7 +64,7 @@ static void SetupSourceFiles(cmTarget const* target,
|
||||||
std::string basename = cmsys::SystemTools::
|
std::string basename = cmsys::SystemTools::
|
||||||
GetFilenameWithoutLastExtension(absFile);
|
GetFilenameWithoutLastExtension(absFile);
|
||||||
|
|
||||||
std::string rcc_output_dir = target->GetSupportDirectory();
|
std::string rcc_output_dir = target->Target->GetSupportDirectory();
|
||||||
cmSystemTools::MakeDirectory(rcc_output_dir.c_str());
|
cmSystemTools::MakeDirectory(rcc_output_dir.c_str());
|
||||||
std::string rcc_output_file = rcc_output_dir;
|
std::string rcc_output_file = rcc_output_dir;
|
||||||
rcc_output_file += "/qrc_" + basename + ".cpp";
|
rcc_output_file += "/qrc_" + basename + ".cpp";
|
||||||
|
@ -104,40 +101,38 @@ static void SetupSourceFiles(cmTarget const* target,
|
||||||
fileIt != newRccFiles.end();
|
fileIt != newRccFiles.end();
|
||||||
++fileIt)
|
++fileIt)
|
||||||
{
|
{
|
||||||
const_cast<cmTarget*>(target)->AddSource(*fileIt);
|
const_cast<cmTarget*>(target->Target)->AddSource(*fileIt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GetCompileDefinitionsAndDirectories(cmTarget const* target,
|
static void GetCompileDefinitionsAndDirectories(
|
||||||
const std::string& config,
|
cmGeneratorTarget const* target,
|
||||||
std::string &incs,
|
const std::string& config,
|
||||||
std::string &defs)
|
std::string &incs,
|
||||||
|
std::string &defs)
|
||||||
{
|
{
|
||||||
cmMakefile* makefile = target->GetMakefile();
|
|
||||||
cmGlobalGenerator* globalGen = makefile->GetGlobalGenerator();
|
|
||||||
std::vector<std::string> includeDirs;
|
std::vector<std::string> includeDirs;
|
||||||
cmGeneratorTarget *gtgt = globalGen->GetGeneratorTarget(target);
|
cmLocalGenerator *localGen = target->GetLocalGenerator();
|
||||||
cmLocalGenerator *localGen = gtgt->GetLocalGenerator();
|
|
||||||
// Get the include dirs for this target, without stripping the implicit
|
// Get the include dirs for this target, without stripping the implicit
|
||||||
// include dirs off, see http://public.kitware.com/Bug/view.php?id=13667
|
// include dirs off, see http://public.kitware.com/Bug/view.php?id=13667
|
||||||
localGen->GetIncludeDirectories(includeDirs, gtgt, "CXX", config, false);
|
localGen->GetIncludeDirectories(includeDirs, target, "CXX", config, false);
|
||||||
|
|
||||||
incs = cmJoin(includeDirs, ";");
|
incs = cmJoin(includeDirs, ";");
|
||||||
|
|
||||||
std::set<std::string> defines;
|
std::set<std::string> defines;
|
||||||
localGen->AddCompileDefinitions(defines, target, config, "CXX");
|
localGen->AddCompileDefinitions(defines, target->Target, config, "CXX");
|
||||||
|
|
||||||
defs += cmJoin(defines, ";");
|
defs += cmJoin(defines, ";");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetupAutoMocTarget(cmTarget const* target,
|
static void SetupAutoMocTarget(cmGeneratorTarget const* target,
|
||||||
const std::string &autogenTargetName,
|
const std::string &autogenTargetName,
|
||||||
std::vector<std::string> const& skipMoc,
|
std::vector<std::string> const& skipMoc,
|
||||||
std::vector<std::string> const& mocHeaders,
|
std::vector<std::string> const& mocHeaders,
|
||||||
std::map<std::string, std::string> &configIncludes,
|
std::map<std::string, std::string> &configIncludes,
|
||||||
std::map<std::string, std::string> &configDefines)
|
std::map<std::string, std::string> &configDefines)
|
||||||
{
|
{
|
||||||
cmMakefile* makefile = target->GetMakefile();
|
cmMakefile* makefile = target->Target->GetMakefile();
|
||||||
|
|
||||||
const char* tmp = target->GetProperty("AUTOMOC_MOC_OPTIONS");
|
const char* tmp = target->GetProperty("AUTOMOC_MOC_OPTIONS");
|
||||||
std::string _moc_options = (tmp!=0 ? tmp : "");
|
std::string _moc_options = (tmp!=0 ? tmp : "");
|
||||||
|
@ -222,22 +217,20 @@ static void SetupAutoMocTarget(cmTarget const* target,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GetUicOpts(cmTarget const* target, const std::string& config,
|
static void GetUicOpts(cmGeneratorTarget const* target,
|
||||||
|
const std::string& config,
|
||||||
std::string &optString)
|
std::string &optString)
|
||||||
{
|
{
|
||||||
cmGeneratorTarget *gtgt = target->GetMakefile()
|
|
||||||
->GetGlobalGenerator()
|
|
||||||
->GetGeneratorTarget(target);
|
|
||||||
std::vector<std::string> opts;
|
std::vector<std::string> opts;
|
||||||
gtgt->GetAutoUicOptions(opts, config);
|
target->GetAutoUicOptions(opts, config);
|
||||||
optString = cmJoin(opts, ";");
|
optString = cmJoin(opts, ";");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetupAutoUicTarget(cmTarget const* target,
|
static void SetupAutoUicTarget(cmGeneratorTarget const* target,
|
||||||
std::vector<std::string> const& skipUic,
|
std::vector<std::string> const& skipUic,
|
||||||
std::map<std::string, std::string> &configUicOptions)
|
std::map<std::string, std::string> &configUicOptions)
|
||||||
{
|
{
|
||||||
cmMakefile *makefile = target->GetMakefile();
|
cmMakefile *makefile = target->Target->GetMakefile();
|
||||||
|
|
||||||
std::set<std::string> skipped;
|
std::set<std::string> skipped;
|
||||||
skipped.insert(skipUic.begin(), skipUic.end());
|
skipped.insert(skipUic.begin(), skipUic.end());
|
||||||
|
@ -340,12 +333,9 @@ static void SetupAutoUicTarget(cmTarget const* target,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string GetRccExecutable(cmTarget const* target)
|
static std::string GetRccExecutable(cmGeneratorTarget const* target)
|
||||||
{
|
{
|
||||||
cmGeneratorTarget *gtgt = target->GetMakefile()
|
cmMakefile *makefile = target->Target->GetMakefile();
|
||||||
->GetGlobalGenerator()
|
|
||||||
->GetGeneratorTarget(target);
|
|
||||||
cmMakefile *makefile = target->GetMakefile();
|
|
||||||
const char *qtVersion = makefile->GetDefinition("_target_qt_version");
|
const char *qtVersion = makefile->GetDefinition("_target_qt_version");
|
||||||
if (!qtVersion)
|
if (!qtVersion)
|
||||||
{
|
{
|
||||||
|
@ -355,7 +345,8 @@ static std::string GetRccExecutable(cmTarget const* target)
|
||||||
qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR");
|
qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR");
|
||||||
}
|
}
|
||||||
if (const char *targetQtVersion =
|
if (const char *targetQtVersion =
|
||||||
gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", ""))
|
target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION",
|
||||||
|
""))
|
||||||
{
|
{
|
||||||
qtVersion = targetQtVersion;
|
qtVersion = targetQtVersion;
|
||||||
}
|
}
|
||||||
|
@ -434,7 +425,7 @@ static void MergeRccOptions(std::vector<std::string> &opts,
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetAutogenTargetName(
|
std::string GetAutogenTargetName(
|
||||||
cmTarget const* target)
|
cmGeneratorTarget const* target)
|
||||||
{
|
{
|
||||||
std::string autogenTargetName = target->GetName();
|
std::string autogenTargetName = target->GetName();
|
||||||
autogenTargetName += "_automoc";
|
autogenTargetName += "_automoc";
|
||||||
|
@ -442,9 +433,9 @@ std::string GetAutogenTargetName(
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetAutogenTargetDir(
|
std::string GetAutogenTargetDir(
|
||||||
cmTarget const* target)
|
cmGeneratorTarget const* target)
|
||||||
{
|
{
|
||||||
cmMakefile* makefile = target->GetMakefile();
|
cmMakefile* makefile = target->Target->GetMakefile();
|
||||||
std::string targetDir = makefile->GetCurrentBinaryDirectory();
|
std::string targetDir = makefile->GetCurrentBinaryDirectory();
|
||||||
targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory();
|
targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory();
|
||||||
targetDir += "/";
|
targetDir += "/";
|
||||||
|
@ -485,7 +476,7 @@ static std::string ReadAll(const std::string& filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string ListQt5RccInputs(cmSourceFile* sf,
|
static std::string ListQt5RccInputs(cmSourceFile* sf,
|
||||||
cmTarget const* target,
|
cmGeneratorTarget const* target,
|
||||||
std::vector<std::string>& depends)
|
std::vector<std::string>& depends)
|
||||||
{
|
{
|
||||||
std::string rccCommand
|
std::string rccCommand
|
||||||
|
@ -591,17 +582,14 @@ static std::string ListQt4RccInputs(cmSourceFile* sf,
|
||||||
return entriesList;
|
return entriesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetupAutoRccTarget(cmTarget const* target)
|
static void SetupAutoRccTarget(cmGeneratorTarget const* target)
|
||||||
{
|
{
|
||||||
std::string _rcc_files;
|
std::string _rcc_files;
|
||||||
const char* sepRccFiles = "";
|
const char* sepRccFiles = "";
|
||||||
cmMakefile *makefile = target->GetMakefile();
|
cmMakefile *makefile = target->Target->GetMakefile();
|
||||||
|
|
||||||
std::vector<cmSourceFile*> srcFiles;
|
std::vector<cmSourceFile*> srcFiles;
|
||||||
cmGeneratorTarget *gtgt = target->GetMakefile()
|
target->GetConfigCommonSourceFiles(srcFiles);
|
||||||
->GetGlobalGenerator()
|
|
||||||
->GetGeneratorTarget(target);
|
|
||||||
gtgt->GetConfigCommonSourceFiles(srcFiles);
|
|
||||||
|
|
||||||
std::string qrcInputs;
|
std::string qrcInputs;
|
||||||
const char* qrcInputsSep = "";
|
const char* qrcInputsSep = "";
|
||||||
|
@ -705,9 +693,10 @@ static void SetupAutoRccTarget(cmTarget const* target)
|
||||||
GetRccExecutable(target).c_str());
|
GetRccExecutable(target).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmQtAutoGeneratorInitializer::InitializeAutogenSources(cmTarget* target)
|
void cmQtAutoGeneratorInitializer::InitializeAutogenSources(
|
||||||
|
cmGeneratorTarget* target)
|
||||||
{
|
{
|
||||||
cmMakefile* makefile = target->GetMakefile();
|
cmMakefile* makefile = target->Target->GetMakefile();
|
||||||
|
|
||||||
if (target->GetPropertyAsBool("AUTOMOC"))
|
if (target->GetPropertyAsBool("AUTOMOC"))
|
||||||
{
|
{
|
||||||
|
@ -720,15 +709,15 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenSources(cmTarget* target)
|
||||||
makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
|
makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
|
||||||
mocCppFile.c_str(), false);
|
mocCppFile.c_str(), false);
|
||||||
|
|
||||||
target->AddSource(mocCppFile);
|
target->Target->AddSource(mocCppFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
|
void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
|
||||||
cmLocalGenerator* lg,
|
cmLocalGenerator* lg,
|
||||||
cmTarget* target)
|
cmGeneratorTarget* target)
|
||||||
{
|
{
|
||||||
cmMakefile* makefile = target->GetMakefile();
|
cmMakefile* makefile = target->Target->GetMakefile();
|
||||||
|
|
||||||
std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR");
|
std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR");
|
||||||
if (qtMajorVersion == "")
|
if (qtMajorVersion == "")
|
||||||
|
@ -825,9 +814,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
std::vector<cmSourceFile*> srcFiles;
|
std::vector<cmSourceFile*> srcFiles;
|
||||||
cmGeneratorTarget* gtgt =
|
target->GetConfigCommonSourceFiles(srcFiles);
|
||||||
lg->GetGlobalGenerator()->GetGeneratorTarget(target);
|
|
||||||
gtgt->GetConfigCommonSourceFiles(srcFiles);
|
|
||||||
for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
|
for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
|
||||||
fileIt != srcFiles.end();
|
fileIt != srcFiles.end();
|
||||||
++fileIt)
|
++fileIt)
|
||||||
|
@ -846,7 +833,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
|
||||||
std::string basename = cmsys::SystemTools::
|
std::string basename = cmsys::SystemTools::
|
||||||
GetFilenameWithoutLastExtension(absFile);
|
GetFilenameWithoutLastExtension(absFile);
|
||||||
|
|
||||||
std::string rcc_output_dir = target->GetSupportDirectory();
|
std::string rcc_output_dir = target->Target->GetSupportDirectory();
|
||||||
cmSystemTools::MakeDirectory(rcc_output_dir.c_str());
|
cmSystemTools::MakeDirectory(rcc_output_dir.c_str());
|
||||||
std::string rcc_output_file = rcc_output_dir;
|
std::string rcc_output_file = rcc_output_dir;
|
||||||
rcc_output_file += "/qrc_" + basename + ".cpp";
|
rcc_output_file += "/qrc_" + basename + ".cpp";
|
||||||
|
@ -887,7 +874,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
|
||||||
workingDirectory.c_str());
|
workingDirectory.c_str());
|
||||||
cc.SetEscapeOldStyle(false);
|
cc.SetEscapeOldStyle(false);
|
||||||
cc.SetEscapeAllowMakeVars(true);
|
cc.SetEscapeAllowMakeVars(true);
|
||||||
target->AddPreBuildCommand(cc);
|
target->Target->AddPreBuildCommand(cc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
@ -916,17 +903,17 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// inherit FOLDER property from target (#13688)
|
// inherit FOLDER property from target (#13688)
|
||||||
copyTargetProperty(autogenTarget, target, "FOLDER");
|
copyTargetProperty(gt->Target, target->Target, "FOLDER");
|
||||||
}
|
}
|
||||||
|
|
||||||
target->AddUtility(autogenTargetName);
|
target->Target->AddUtility(autogenTargetName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(
|
void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(
|
||||||
cmTarget const* target)
|
cmGeneratorTarget const* target)
|
||||||
{
|
{
|
||||||
cmMakefile* makefile = target->GetMakefile();
|
cmMakefile* makefile = target->Target->GetMakefile();
|
||||||
|
|
||||||
// forget the variables added here afterwards again:
|
// forget the variables added here afterwards again:
|
||||||
cmMakefile::ScopePushPop varScope(makefile);
|
cmMakefile::ScopePushPop varScope(makefile);
|
||||||
|
@ -947,11 +934,8 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(
|
||||||
{
|
{
|
||||||
qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR");
|
qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR");
|
||||||
}
|
}
|
||||||
cmGeneratorTarget *gtgt = target->GetMakefile()
|
|
||||||
->GetGlobalGenerator()
|
|
||||||
->GetGeneratorTarget(target);
|
|
||||||
if (const char *targetQtVersion =
|
if (const char *targetQtVersion =
|
||||||
gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", ""))
|
target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", ""))
|
||||||
{
|
{
|
||||||
qtVersion = targetQtVersion;
|
qtVersion = targetQtVersion;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,15 +21,16 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
class cmSourceFile;
|
class cmSourceFile;
|
||||||
class cmTarget;
|
class cmGeneratorTarget;
|
||||||
class cmLocalGenerator;
|
class cmLocalGenerator;
|
||||||
|
|
||||||
class cmQtAutoGeneratorInitializer
|
class cmQtAutoGeneratorInitializer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void InitializeAutogenSources(cmTarget* target);
|
static void InitializeAutogenSources(cmGeneratorTarget* target);
|
||||||
static void InitializeAutogenTarget(cmLocalGenerator* lg, cmTarget* target);
|
static void InitializeAutogenTarget(cmLocalGenerator* lg,
|
||||||
static void SetupAutoGenerateTarget(cmTarget const* target);
|
cmGeneratorTarget* target);
|
||||||
|
static void SetupAutoGenerateTarget(cmGeneratorTarget const* target);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue