summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmQtAutoGenerators.cxx58
-rw-r--r--Tests/Qt4And5Automoc/CMakeLists.txt15
-rw-r--r--Tests/Qt4And5Automoc/main.cpp.in (renamed from Tests/Qt4And5Automoc/main.cpp)0
-rw-r--r--Tests/Qt4And5Automoc/main_qt4.cpp4
-rw-r--r--Tests/Qt4And5Automoc/main_qt5.cpp4
5 files changed, 49 insertions, 32 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);
}
}
diff --git a/Tests/Qt4And5Automoc/CMakeLists.txt b/Tests/Qt4And5Automoc/CMakeLists.txt
index 0cc80fe..61d5743 100644
--- a/Tests/Qt4And5Automoc/CMakeLists.txt
+++ b/Tests/Qt4And5Automoc/CMakeLists.txt
@@ -1,3 +1,4 @@
+cmake_minimum_required(VERSION 2.8.12)
project(Qt4And5Automoc)
@@ -7,7 +8,17 @@ find_package(Qt5Core REQUIRED)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
-add_executable(qt4_exe main_qt4.cpp)
+macro(generate_main_file VERSION)
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/main.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/main_qt${VERSION}.cpp" COPYONLY)
+ file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/main_qt${VERSION}.cpp"
+ "#include \"main_qt${VERSION}.moc\"\n"
+ )
+endmacro()
+
+generate_main_file(4)
+generate_main_file(5)
+
+add_executable(qt4_exe "${CMAKE_CURRENT_BINARY_DIR}/main_qt4.cpp")
target_link_libraries(qt4_exe Qt4::QtCore)
-add_executable(qt5_exe main_qt5.cpp)
+add_executable(qt5_exe "${CMAKE_CURRENT_BINARY_DIR}/main_qt5.cpp")
target_link_libraries(qt5_exe Qt5::Core)
diff --git a/Tests/Qt4And5Automoc/main.cpp b/Tests/Qt4And5Automoc/main.cpp.in
index 00fd641..00fd641 100644
--- a/Tests/Qt4And5Automoc/main.cpp
+++ b/Tests/Qt4And5Automoc/main.cpp.in
diff --git a/Tests/Qt4And5Automoc/main_qt4.cpp b/Tests/Qt4And5Automoc/main_qt4.cpp
deleted file mode 100644
index a84ce89..0000000
--- a/Tests/Qt4And5Automoc/main_qt4.cpp
+++ /dev/null
@@ -1,4 +0,0 @@
-
-#include "main.cpp"
-
-#include "main_qt4.moc"
diff --git a/Tests/Qt4And5Automoc/main_qt5.cpp b/Tests/Qt4And5Automoc/main_qt5.cpp
deleted file mode 100644
index 287b261..0000000
--- a/Tests/Qt4And5Automoc/main_qt5.cpp
+++ /dev/null
@@ -1,4 +0,0 @@
-
-#include "main.cpp"
-
-#include "main_qt5.moc"