summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-01-24 16:01:59 (GMT)
committerStephen Kelly <steveire@gmail.com>2014-01-28 20:04:40 (GMT)
commitf7ae1d8ad6d0db2b6656ed77f7de12189badf05c (patch)
treec45b1921831766ea0242d769e28e915b4dbf47a7
parent4b989d5f158e5135bf543438af00b03db0102ade (diff)
downloadCMake-f7ae1d8ad6d0db2b6656ed77f7de12189badf05c.zip
CMake-f7ae1d8ad6d0db2b6656ed77f7de12189badf05c.tar.gz
CMake-f7ae1d8ad6d0db2b6656ed77f7de12189badf05c.tar.bz2
QtAutogen: Short-circut some logic when moc is not available.
This is the case when AUTOMOC is false. This prevents creating rules to moc the files in the absense of moc.
-rw-r--r--Source/cmQtAutoGenerators.cxx17
-rw-r--r--Tests/QtAutogen/CMakeLists.txt14
-rw-r--r--Tests/QtAutogen/uiconly.cpp13
-rw-r--r--Tests/QtAutogen/uiconly.h20
-rw-r--r--Tests/QtAutogen/uiconly.ui24
5 files changed, 85 insertions, 3 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 758466b..cab59fe 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -1444,6 +1444,12 @@ void cmQtAutoGenerators::ParseCppFile(const std::string& absFilename,
<< std::endl;
return;
}
+ this->ParseForUic(absFilename, contentsString, includedUis);
+ if (this->MocExecutable.empty())
+ {
+ return;
+ }
+
const std::string absPath = cmsys::SystemTools::GetFilenamePath(
cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/';
const std::string scannedFileBasename = cmsys::SystemTools::
@@ -1572,7 +1578,6 @@ void cmQtAutoGenerators::ParseCppFile(const std::string& absFilename,
matchOffset += mocIncludeRegExp.end();
} while(mocIncludeRegExp.find(contentsString.c_str() + matchOffset));
}
- this->ParseForUic(absFilename, contentsString, includedUis);
// In this case, check whether the scanned file itself contains a Q_OBJECT.
// If this is the case, the moc_foo.cpp should probably be generated from
@@ -1627,6 +1632,12 @@ void cmQtAutoGenerators::StrictParseCppFile(const std::string& absFilename,
<< std::endl;
return;
}
+ this->ParseForUic(absFilename, contentsString, includedUis);
+ if (this->MocExecutable.empty())
+ {
+ return;
+ }
+
const std::string absPath = cmsys::SystemTools::GetFilenamePath(
cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/';
const std::string scannedFileBasename = cmsys::SystemTools::
@@ -1705,7 +1716,6 @@ void cmQtAutoGenerators::StrictParseCppFile(const std::string& absFilename,
matchOffset += mocIncludeRegExp.end();
} while(mocIncludeRegExp.find(contentsString.c_str() + matchOffset));
}
- this->ParseForUic(absFilename, contentsString, includedUis);
// In this case, check whether the scanned file itself contains a Q_OBJECT.
// If this is the case, the moc_foo.cpp should probably be generated from
@@ -1830,7 +1840,8 @@ void cmQtAutoGenerators::ParseHeaders(const std::set<std::string>& absHeaders,
const std::string& headerName = *hIt;
const std::string contents = ReadAll(headerName);
- if (includedMocs.find(headerName) == includedMocs.end())
+ if (!this->MocExecutable.empty()
+ && includedMocs.find(headerName) == includedMocs.end())
{
if (this->Verbose)
{
diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt
index 7b99395..515bf5b 100644
--- a/Tests/QtAutogen/CMakeLists.txt
+++ b/Tests/QtAutogen/CMakeLists.txt
@@ -11,6 +11,11 @@ if (QT_TEST_VERSION STREQUAL 4)
include(UseQt4)
set(QT_QTCORE_TARGET Qt4::QtCore)
+
+ macro(qtx_wrap_cpp)
+ qt4_wrap_cpp(${ARGN})
+ endmacro()
+
else()
if (NOT QT_TEST_VERSION STREQUAL 5)
message(SEND_ERROR "Invalid Qt version specified.")
@@ -25,6 +30,11 @@ else()
if(Qt5_POSITION_INDEPENDENT_CODE)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
+
+ macro(qtx_wrap_cpp)
+ qt5_wrap_cpp(${ARGN})
+ endmacro()
+
endif()
@@ -77,3 +87,7 @@ set_target_properties(empty PROPERTIES AUTOMOC TRUE)
target_link_libraries(empty no_link_language)
add_library(no_link_language STATIC empty.h)
set_target_properties(no_link_language PROPERTIES AUTOMOC TRUE)
+
+qtx_wrap_cpp(uicOnlyMoc uiconly.h)
+add_executable(uiconly uiconly.cpp ${uicOnlyMoc})
+target_link_libraries(uiconly ${QT_LIBRARIES})
diff --git a/Tests/QtAutogen/uiconly.cpp b/Tests/QtAutogen/uiconly.cpp
new file mode 100644
index 0000000..cdb3318
--- /dev/null
+++ b/Tests/QtAutogen/uiconly.cpp
@@ -0,0 +1,13 @@
+
+#include "uiconly.h"
+
+UicOnly::UicOnly(QWidget *parent)
+ : QWidget(parent), ui(new Ui::UicOnly)
+{
+
+}
+
+int main()
+{
+ return 0;
+}
diff --git a/Tests/QtAutogen/uiconly.h b/Tests/QtAutogen/uiconly.h
new file mode 100644
index 0000000..9e21f82
--- /dev/null
+++ b/Tests/QtAutogen/uiconly.h
@@ -0,0 +1,20 @@
+
+#ifndef UIC_ONLY_H
+#define UIC_ONLY_H
+
+#include <QWidget>
+#include <memory>
+
+#include "ui_uiconly.h"
+
+class UicOnly : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit UicOnly(QWidget *parent = 0);
+
+private:
+ const std::auto_ptr<Ui::UicOnly> ui;
+};
+
+#endif
diff --git a/Tests/QtAutogen/uiconly.ui b/Tests/QtAutogen/uiconly.ui
new file mode 100644
index 0000000..13fb832
--- /dev/null
+++ b/Tests/QtAutogen/uiconly.ui
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>UicOnly</class>
+ <widget class="QWidget" name="UicOnly">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QTreeView" name="treeView"/>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>