From e2ff9e3b9957f844d6530cc92096bed3c16fa46a Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Tue, 22 Jan 2019 10:00:34 +0100 Subject: [PATCH] CMake: Introduce Q_OBJECT qdoc macro CMake's moc file scanning is rather primitive: It will run moc on any file containing a line that starts with Q_OBJECT (and similar macros). We have four files in QtBase that contain such a macro at the start of the line in a qdoc comment. These four files were excluded from automatic moc handling by cmake, which is not ideal, since this will silently fail when somebody actually adds a Q_OBJECT macro in code. This patch introduces a macro Q_OBJECT for qdoc. This macro will be replaced with Q_OBJECT in the generated documentation. While not nice, at least a failure to use \Q_OBJECT is noticeable: Moc will warn about the file. Change-Id: I829893c1166eee306fe30058d4ea0256affd45ea Reviewed-by: Simon Hausmann Reviewed-by: Paul Wicking --- doc/global/macros.qdocconf | 1 + src/corelib/CMakeLists.txt | 3 --- src/corelib/tools/qsharedpointer.cpp | 2 +- src/gui/CMakeLists.txt | 9 --------- src/gui/opengl/qopenglfunctions.cpp | 2 +- src/network/CMakeLists.txt | 8 -------- src/opengl/CMakeLists.txt | 6 ------ src/opengl/qglfunctions.cpp | 2 +- src/opengl/qgraphicsshadereffect.cpp | 2 +- 9 files changed, 5 insertions(+), 30 deletions(-) diff --git a/doc/global/macros.qdocconf b/doc/global/macros.qdocconf index 704b1da277e..0eaaf2cd2f7 100644 --- a/doc/global/macros.qdocconf +++ b/doc/global/macros.qdocconf @@ -17,6 +17,7 @@ macro.ouml.HTML = "ö" macro.QA = "\\e{Qt Assistant}" macro.QD = "\\e{Qt Designer}" macro.QL = "\\e{Qt Linguist}" +macro.Q_OBJECT = "Q_OBJECT" macro.QQV = "\\e{Qt QML Viewer}" macro.QtVersion = "$QT_VERSION" macro.QtVer = "$QT_VER" diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index 26292a7c75b..a847d07adef 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -260,9 +260,6 @@ target_include_directories(Core_qobject PRIVATE target_link_libraries(Core_qobject PRIVATE Qt::Platform Qt::GlobalConfig) target_link_libraries(Core PRIVATE Core_qobject) -# Comments trigger moc for these, so skip automoc: -set_source_files_properties(tools/qsharedpointer.cpp PROPERTIES SKIP_AUTOMOC ON) - set_property(TARGET Core APPEND PROPERTY PUBLIC_HEADER "${CMAKE_CURRENT_BINARY_DIR}/global/qconfig.h") set_property(TARGET Core APPEND PROPERTY PRIVATE_HEADER "${CMAKE_CURRENT_BINARY_DIR}/global/qconfig_p.h") diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index 2d5fd2a00ef..be8b6a7aab0 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -414,7 +414,7 @@ \code class ScriptInterface : public QObject { - Q_OBJECT + \Q_OBJECT // ... diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 81ef8b1b665..60b5dec2df0 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -233,15 +233,6 @@ add_qt_module(Gui Qt::Core ) -set_source_files_properties( - # Comment triggering moc: - opengl/qopenglfunctions.cpp - PROPERTIES - SKIP_AUTOMOC ON - SKIP_AUTOUIC ON - SKIP_AUTORCC ON) - - ## Scopes: ##################################################################### diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp index 4f48604a889..700fb77ad71 100644 --- a/src/gui/opengl/qopenglfunctions.cpp +++ b/src/gui/opengl/qopenglfunctions.cpp @@ -93,7 +93,7 @@ void CLASS::init(QOpenGLContext *context) \ \code class MyGLWindow : public QWindow, protected QOpenGLFunctions { - Q_OBJECT + \Q_OBJECT public: MyGLWindow(QScreen *screen = 0); diff --git a/src/network/CMakeLists.txt b/src/network/CMakeLists.txt index 48ae64bb28e..fd684c7eb2f 100644 --- a/src/network/CMakeLists.txt +++ b/src/network/CMakeLists.txt @@ -58,14 +58,6 @@ add_qt_module(Network Qt::CorePrivate ) -set_source_files_properties( - # Comment triggering moc: - access/qnetworkaccessdebugpipebackend_p.h - PROPERTIES - SKIP_AUTOMOC ON - SKIP_AUTOUIC ON - SKIP_AUTORCC ON) - ## Scopes: ##################################################################### diff --git a/src/opengl/CMakeLists.txt b/src/opengl/CMakeLists.txt index 14750f3a3f0..f67fea4d160 100644 --- a/src/opengl/CMakeLists.txt +++ b/src/opengl/CMakeLists.txt @@ -31,12 +31,6 @@ add_qt_module(OpenGL Qt::GuiPrivate Qt::WidgetsPrivate ) -set_source_files_properties(qglfunctions.cpp qgraphicsshadereffect.cpp PROPERTIES - SKIP_AUTOMOC ON - SKIP_AUTOUIC ON - SKIP_AUTORCC ON -) - ## Scopes: ##################################################################### diff --git a/src/opengl/qglfunctions.cpp b/src/opengl/qglfunctions.cpp index 07e11943421..aa1854dd3dd 100644 --- a/src/opengl/qglfunctions.cpp +++ b/src/opengl/qglfunctions.cpp @@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE \code class MyGLWidget : public QGLWidget, protected QGLFunctions { - Q_OBJECT + \Q_OBJECT public: MyGLWidget(QWidget *parent = 0) : QGLWidget(parent) {} diff --git a/src/opengl/qgraphicsshadereffect.cpp b/src/opengl/qgraphicsshadereffect.cpp index cf3d307d719..4959c804b8c 100644 --- a/src/opengl/qgraphicsshadereffect.cpp +++ b/src/opengl/qgraphicsshadereffect.cpp @@ -87,7 +87,7 @@ QT_BEGIN_NAMESPACE \code class ColorizeEffect : public QGraphicsShaderEffect { - Q_OBJECT + \Q_OBJECT public: ColorizeEffect(QObject *parent = 0) : QGraphicsShaderEffect(parent), color(Qt::black)