summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-03-13 17:34:24 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2013-03-13 17:34:24 (GMT)
commit26bfece1af0e3b06778e56eddd9cdd1f448a5c77 (patch)
tree4f02773d060565a5e40f1a40ab5d5e0a49cae7fd /Source
parent9a02a267021b4bced796ac73e1a69fd095883d15 (diff)
parenta223a3b65f518f59a73967f0087b0d67842d9f0d (diff)
downloadCMake-26bfece1af0e3b06778e56eddd9cdd1f448a5c77.zip
CMake-26bfece1af0e3b06778e56eddd9cdd1f448a5c77.tar.gz
CMake-26bfece1af0e3b06778e56eddd9cdd1f448a5c77.tar.bz2
Merge topic 'fix-automoc-no-qt'
a223a3b Automoc: Don't create automoc targets if Qt is not used (#13999) 65b5c1e Merge branch 'property-link-depends-no-crash' into fix-automoc-no-qt
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalGenerator.cxx6
-rw-r--r--Source/cmQtAutomoc.cxx26
-rw-r--r--Source/cmQtAutomoc.h2
3 files changed, 19 insertions, 15 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index fcd6f71..df14331 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1086,8 +1086,10 @@ void cmGlobalGenerator::CreateAutomocTargets()
if(target.GetPropertyAsBool("AUTOMOC") && !target.IsImported())
{
cmQtAutomoc automoc;
- automoc.InitializeMocSourceFile(&target);
- automocs.push_back(std::make_pair(automoc, &target));
+ if(automoc.InitializeMocSourceFile(&target))
+ {
+ automocs.push_back(std::make_pair(automoc, &target));
+ }
}
}
}
diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index 10ce641..5730c8c 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -119,10 +119,21 @@ cmQtAutomoc::cmQtAutomoc()
}
}
-void cmQtAutomoc::InitializeMocSourceFile(cmTarget* target)
+bool cmQtAutomoc::InitializeMocSourceFile(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;
+ }
+
std::string automocTargetName = target->GetName();
- cmMakefile *makefile = target->GetMakefile();
automocTargetName += "_automoc";
std::string mocCppFile = makefile->GetCurrentOutputDirectory();
mocCppFile += "/";
@@ -134,6 +145,7 @@ void cmQtAutomoc::InitializeMocSourceFile(cmTarget* target)
mocCppFile.c_str(), false);
target->AddSourceFile(mocCppSource);
+ return true;
}
void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
@@ -141,16 +153,6 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
cmMakefile* makefile = target->GetMakefile();
cmLocalGenerator* localGen = makefile->GetLocalGenerator();
const char* targetName = target->GetName();
- // 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;
- }
bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE");
diff --git a/Source/cmQtAutomoc.h b/Source/cmQtAutomoc.h
index 962e254..01b68fc 100644
--- a/Source/cmQtAutomoc.h
+++ b/Source/cmQtAutomoc.h
@@ -23,7 +23,7 @@ public:
cmQtAutomoc();
bool Run(const char* targetDirectory);
- void InitializeMocSourceFile(cmTarget* target);
+ bool InitializeMocSourceFile(cmTarget* target);
void SetupAutomocTarget(cmTarget* target);
private: