summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutoGenerators.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-01-24 12:02:16 (GMT)
committerStephen Kelly <steveire@gmail.com>2014-01-28 20:04:10 (GMT)
commit321e348e133f2f62dd51cd663fe30c7513ea53d8 (patch)
tree284062c935e209110b204d06b07ebeb07be9cecf /Source/cmQtAutoGenerators.cxx
parente96683b048e1d710b1bb0791b816638207283ef0 (diff)
downloadCMake-321e348e133f2f62dd51cd663fe30c7513ea53d8.zip
CMake-321e348e133f2f62dd51cd663fe30c7513ea53d8.tar.gz
CMake-321e348e133f2f62dd51cd663fe30c7513ea53d8.tar.bz2
QtAutogen: Use Qt 4 IMPORTED targets to find executable locations.
Avoid using the moc from Qt 5 with Qt 4 based targets. Moc generates a version check to ensure that such generated code does not compile. The Qt4And5Automoc unit test should have been testing this, but it was not because the test was broken. In that unit test, moc was run on trivial files which have no significant content, and in particular no Q_OBJECT macro. Therefore moc was generating empty files which do not even contain the version check. Fix this by generating files for input to moc at cmake time.
Diffstat (limited to 'Source/cmQtAutoGenerators.cxx')
-rw-r--r--Source/cmQtAutoGenerators.cxx58
1 files changed, 36 insertions, 22 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index da22ab5..2987c25 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -549,9 +549,6 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target,
}
}
- const char *qtMoc = makefile->GetSafeDefinition("QT_MOC_EXECUTABLE");
- makefile->AddDefinition("_qt_moc_executable", qtMoc);
-
const char *qtVersion = makefile->GetDefinition("_target_qt_version");
if (strcmp(qtVersion, "5") == 0)
{
@@ -564,13 +561,21 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target,
}
makefile->AddDefinition("_qt_moc_executable", qt5Moc->GetLocation(0));
}
- else
+ else if (strcmp(qtVersion, "4") == 0)
{
- if (strcmp(qtVersion, "4") != 0)
+ cmTarget *qt4Moc = makefile->FindTargetToUse("Qt4::moc");
+ if (!qt4Moc)
{
- cmSystemTools::Error("The CMAKE_AUTOMOC feature supports only Qt 4 and "
- "Qt 5 ", autogenTargetName.c_str());
+ cmSystemTools::Error("Qt4::moc target not found ",
+ autogenTargetName.c_str());
+ return;
}
+ makefile->AddDefinition("_qt_moc_executable", qt4Moc->GetLocation(0));
+ }
+ else
+ {
+ cmSystemTools::Error("The CMAKE_AUTOMOC feature supports only Qt 4 and "
+ "Qt 5 ", autogenTargetName.c_str());
}
}
@@ -641,9 +646,6 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,
{
cmMakefile *makefile = target->GetMakefile();
- const char *qtUic = makefile->GetSafeDefinition("QT_UIC_EXECUTABLE");
- makefile->AddDefinition("_qt_uic_executable", qtUic);
-
std::vector<cmSourceFile*> srcFiles;
target->GetSourceFiles(srcFiles);
@@ -747,20 +749,27 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,
if (!qt5Uic)
{
// Project does not use Qt5Widgets, but has AUTOUIC ON anyway
- makefile->RemoveDefinition("_qt_uic_executable");
}
else
{
makefile->AddDefinition("_qt_uic_executable", qt5Uic->GetLocation(0));
}
}
- else
+ else if (strcmp(qtVersion, "4") == 0)
{
- if (strcmp(qtVersion, "4") != 0)
+ cmTarget *qt4Uic = makefile->FindTargetToUse("Qt4::uic");
+ if (!qt4Uic)
{
- cmSystemTools::Error("The CMAKE_AUTOUIC feature supports only Qt 4 and "
- "Qt 5 ", targetName);
+ cmSystemTools::Error("Qt4::uic target not found ",
+ targetName);
+ return;
}
+ makefile->AddDefinition("_qt_uic_executable", qt4Uic->GetLocation(0));
+ }
+ else
+ {
+ cmSystemTools::Error("The CMAKE_AUTOUIC feature supports only Qt 4 and "
+ "Qt 5 ", targetName);
}
}
@@ -927,9 +936,6 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
makefile->AddDefinition("_qt_rcc_options_options",
cmLocalGenerator::EscapeForCMake(rccFileOptions.c_str()).c_str());
- const char *qtRcc = makefile->GetSafeDefinition("QT_RCC_EXECUTABLE");
- makefile->AddDefinition("_qt_rcc_executable", qtRcc);
-
const char* targetName = target->GetName();
if (strcmp(qtVersion, "5") == 0)
{
@@ -942,13 +948,21 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
}
makefile->AddDefinition("_qt_rcc_executable", qt5Rcc->GetLocation(0));
}
- else
+ else if (strcmp(qtVersion, "4") == 0)
{
- if (strcmp(qtVersion, "4") != 0)
+ cmTarget *qt4Rcc = makefile->FindTargetToUse("Qt4::rcc");
+ if (!qt4Rcc)
{
- cmSystemTools::Error("The CMAKE_AUTORCC feature supports only Qt 4 and "
- "Qt 5 ", targetName);
+ cmSystemTools::Error("Qt4::rcc target not found ",
+ targetName);
+ return;
}
+ makefile->AddDefinition("_qt_rcc_executable", qt4Rcc->GetLocation(0));
+ }
+ else
+ {
+ cmSystemTools::Error("The CMAKE_AUTORCC feature supports only Qt 4 and "
+ "Qt 5 ", targetName);
}
}