summaryrefslogtreecommitdiff
path: root/Source/cmQtAutomoc.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2012-11-20 11:48:09 -0500
committerCMake Topic Stage <kwrobot@kitware.com>2012-11-20 11:48:09 -0500
commit8faf4e93801a025d4cb17d2ef12437e5554798b1 (patch)
tree9b73f6af583744b11f14f926124a82cb75640340 /Source/cmQtAutomoc.cxx
parentd82200df2652c913244ba09c15e9059ef1048aa2 (diff)
parentd2536579d51e77827b8e55f39123316324314781 (diff)
downloadcmake-8faf4e93801a025d4cb17d2ef12437e5554798b1.tar.gz
Merge topic 'FixAutomocRegression3'
d253657 Automoc: fix regression #13667, broken build in phonon
Diffstat (limited to 'Source/cmQtAutomoc.cxx')
-rw-r--r--Source/cmQtAutomoc.cxx59
1 files changed, 59 insertions, 0 deletions
diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index 94232084d1..83688dd751 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -211,6 +211,34 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
}
}
+
+ const char* qtIncDir = 0;
+ const char* qtCoreIncDir = 0;
+
+ // check whether ${QT_INCLUDE_DIR} is part of the implicit include dirs,
+ // see http://public.kitware.com/Bug/view.php?id=13667
+ bool qtIncludeDirMayHaveBeenRemoved = false;
+ if (makefile->IsSet("QT_INCLUDE_DIR"))
+ {
+ qtIncDir = makefile->GetDefinition("QT_INCLUDE_DIR");
+ std::string s =
+ makefile->GetSafeDefinition("CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES");
+ std::vector<std::string> implIncDirs;
+ cmSystemTools::ExpandListArgument(s, implIncDirs);
+ if (std::find(implIncDirs.begin(), implIncDirs.end(),std::string(qtIncDir))
+ != implIncDirs.end())
+ {
+ qtIncludeDirMayHaveBeenRemoved = true;
+ if (makefile->IsSet("QT_QTCORE_INCLUDE_DIR"))
+ {
+ qtCoreIncDir = makefile->GetDefinition("QT_QTCORE_INCLUDE_DIR");
+ }
+ }
+ }
+
+ bool haveQtCoreIncDir = false;
+ bool haveQtIncDir = false;
+
std::vector<std::string> includeDirs;
cmGeneratorTarget gtgt(target);
localGen->GetIncludeDirectories(includeDirs, &gtgt, "CXX");
@@ -223,6 +251,37 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
_moc_incs += sep;
sep = ";";
_moc_incs += *incDirIt;
+
+ if (qtIncludeDirMayHaveBeenRemoved && qtCoreIncDir && qtIncDir) // #13667
+ {
+ if (*incDirIt == qtIncDir)
+ {
+ haveQtIncDir = true;
+ qtIncludeDirMayHaveBeenRemoved = false; // it's here, i.e. not removed
+ }
+ if (*incDirIt == qtCoreIncDir)
+ {
+ haveQtCoreIncDir = true;
+ }
+ }
+ }
+
+ // Some projects (kdelibs, phonon) query the compiler for its default
+ // include search dirs, and add those to
+ // CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES.
+ // These may include e.g./usr/lib/qt/include . This is typically also part
+ // of ${QT_INCLUDES}. If this directory is then contained in the implicit
+ // include dirs, it is removed from the include dirs returned from the
+ // target above. So we add ${QT_INCLUDE_DIR} manually for moc if we detected
+ // that ${QT_QTCORE_INCLUDE_DIR} is among the include dirs (there shouldn't
+ // be a way to use Qt4 without using ${QT_QTCORE_INCLUDE_DIR} I think.
+ // See #13646 and #13667.
+ if (qtIncludeDirMayHaveBeenRemoved && qtCoreIncDir && qtIncDir
+ && (haveQtCoreIncDir == true) && (haveQtIncDir == false))
+ {
+ _moc_incs += sep;
+ sep = ";";
+ _moc_incs += qtIncDir;
}
const char* tmp = target->GetProperty("COMPILE_DEFINITIONS");