summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-11-04 09:29:21 (GMT)
committerStephen Kelly <steveire@gmail.com>2013-11-05 19:17:32 (GMT)
commit45735f38275ad4d13e801ba41e7565bcfd5a0f0a (patch)
tree9d49a0142ff6710e25523d59d7ff7c9ea9ff6be8 /Source
parent20a234d1b8d41852bdf401ee6484b1d0e877c7c4 (diff)
downloadCMake-45735f38275ad4d13e801ba41e7565bcfd5a0f0a.zip
CMake-45735f38275ad4d13e801ba41e7565bcfd5a0f0a.tar.gz
CMake-45735f38275ad4d13e801ba41e7565bcfd5a0f0a.tar.bz2
cmAutogen: Move autogen target creation to InitializeMocSourceFile.
The SetupAutoGenerateTarget method will soon be invoked at a later time in a followup commit. We need to ensure that we create the utility autogen target early.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmQtAutoGenerators.cxx139
1 files changed, 72 insertions, 67 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index dcd0300..e07f7b4 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -185,75 +185,9 @@ bool cmQtAutoGenerators::InitializeMocSourceFile(cmTarget* target)
target->AddSourceFile(mocCppSource);
}
- return true;
-}
-
-static void GetCompileDefinitionsAndDirectories(cmTarget *target,
- const char * config,
- std::string &incs,
- std::string &defs)
-{
- cmMakefile* makefile = target->GetMakefile();
- cmLocalGenerator* localGen = makefile->GetLocalGenerator();
- std::vector<std::string> includeDirs;
- cmGeneratorTarget gtgt(target);
- // 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);
- const char* sep = "";
- incs = "";
- for(std::vector<std::string>::const_iterator incDirIt = includeDirs.begin();
- incDirIt != includeDirs.end();
- ++incDirIt)
- {
- incs += sep;
- sep = ";";
- incs += *incDirIt;
- }
-
- std::set<std::string> defines;
- localGen->AddCompileDefinitions(defines, target, config);
-
- sep = "";
- for(std::set<std::string>::const_iterator defIt = defines.begin();
- defIt != defines.end();
- ++defIt)
- {
- defs += sep;
- sep = ";";
- defs += *defIt;
- }
-}
-
-void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target)
-{
- cmMakefile* makefile = target->GetMakefile();
- const char* targetName = target->GetName();
-
- // forget the variables added here afterwards again:
- cmMakefile::ScopePushPop varScope(makefile);
- static_cast<void>(varScope);
-
- const char *qtVersion = makefile->GetDefinition("Qt5Core_VERSION_MAJOR");
- if (!qtVersion)
- {
- qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR");
- }
- if (const char *targetQtVersion =
- target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", 0))
- {
- qtVersion = targetQtVersion;
- }
- if (qtVersion)
- {
- makefile->AddDefinition("_target_qt_version", qtVersion);
- }
// create a custom target for running generators at buildtime:
std::string autogenTargetName = getAutogenTargetName(target);
- makefile->AddDefinition("_moc_target_name",
- cmLocalGenerator::EscapeForCMake(autogenTargetName.c_str()).c_str());
-
std::string targetDir = getAutogenTargetDir(target);
cmCustomCommandLine currentLine;
@@ -296,7 +230,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target)
tools += " and " + toolNames[0];
}
std::string autogenComment = "Automatic " + tools + " for target ";
- autogenComment += targetName;
+ autogenComment += target->GetName();
#if defined(_WIN32) && !defined(__CYGWIN__)
bool usePRE_BUILD = false;
@@ -353,6 +287,77 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target)
target->AddUtility(autogenTargetName.c_str());
}
+ return true;
+}
+
+static void GetCompileDefinitionsAndDirectories(cmTarget *target,
+ const char * config,
+ std::string &incs,
+ std::string &defs)
+{
+ cmMakefile* makefile = target->GetMakefile();
+ cmLocalGenerator* localGen = makefile->GetLocalGenerator();
+ std::vector<std::string> includeDirs;
+ cmGeneratorTarget gtgt(target);
+ // 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);
+ const char* sep = "";
+ incs = "";
+ for(std::vector<std::string>::const_iterator incDirIt = includeDirs.begin();
+ incDirIt != includeDirs.end();
+ ++incDirIt)
+ {
+ incs += sep;
+ sep = ";";
+ incs += *incDirIt;
+ }
+
+ std::set<std::string> defines;
+ localGen->AddCompileDefinitions(defines, target, config);
+
+ sep = "";
+ for(std::set<std::string>::const_iterator defIt = defines.begin();
+ defIt != defines.end();
+ ++defIt)
+ {
+ defs += sep;
+ sep = ";";
+ defs += *defIt;
+ }
+}
+
+void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* 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",
+ cmLocalGenerator::EscapeForCMake(autogenTargetName.c_str()).c_str());
+
+ std::string targetDir = getAutogenTargetDir(target);
+
+ const char *qtVersion = makefile->GetDefinition("Qt5Core_VERSION_MAJOR");
+ if (!qtVersion)
+ {
+ qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR");
+ }
+ if (const char *targetQtVersion =
+ target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", 0))
+ {
+ qtVersion = targetQtVersion;
+ }
+ if (qtVersion)
+ {
+ makefile->AddDefinition("_target_qt_version", qtVersion);
+ }
+
std::map<std::string, std::string> configIncludes;
std::map<std::string, std::string> configDefines;