From 885f9cee488909f2fb3b5efed6ed5024569545a3 Mon Sep 17 00:00:00 2001 From: mlodhi Date: Mon, 28 Mar 2022 13:58:26 +0200 Subject: [PATCH 01/20] Adapt to qt5 --- src/CMakeLists.txt | 19 ++++++++++++------- src/MyWidget.h | 4 ++-- src/MyWidgetPlugin.cc | 2 -- src/MyWidgetPlugin.h | 4 ++-- src/main.cpp | 2 +- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 34bf105..81b5a03 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,11 @@ -find_package(Qt4 REQUIRED QtCore QtGui QtOpengl QtDesigner) -include_directories(${QT_INCLUDE_DIR}) -include_directories(${QT_QTCORE_INCLUDE_DIR}) -include_directories(${QT_QTGUI_INCLUDE_DIR}) +rock_find_qt5(Core Gui Widgets UiPlugin REQUIRED) + +INCLUDE_DIRECTORIES(${QT5_INCLUDE_DIRS}) +INCLUDE_DIRECTORIES(${Qt5Core_INCLUDE_DIRS}) +INCLUDE_DIRECTORIES(${Qt5Gui_INCLUDE_DIRS}) +INCLUDE_DIRECTORIES(${Qt5Widgets_INCLUDE_DIRS}) +INCLUDE_DIRECTORIES(${QT5UiPlugin_INCLUDE_DIRS}) + set(CMAKE_INCLUDE_CURRENT_DIR ON) SET(MOC_HDRS @@ -18,15 +22,16 @@ FILE(GLOB SRCS ) SET(QtApp_RCCS resources.qrc) -QT4_ADD_RESOURCES(QtApp_RCC_SRCS ${QtApp_RCCS}) +QT5_ADD_RESOURCES(QtApp_RCC_SRCS ${QtApp_RCCS}) rock_vizkit_widget(MyWidget SOURCES ${SRCS} ${QtApp_RCC_SRCS} HEADERS ${HDRS} MOC ${MOC_HDRS} - DEPS_PKGCONFIG base-types base-lib QtCore QtGui + DEPS Qt5::Core Qt5::Gui Qt5::Widgets + DEPS_PKGCONFIG base-types base-lib DEPS_CMAKE - LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${QT_QTDESIGNER_LIBRARY} + LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${QT_QTDESIGNER_LIBRARY} ) rock_executable(mywidgetTest diff --git a/src/MyWidget.h b/src/MyWidget.h index e2a3529..75b60cd 100644 --- a/src/MyWidget.h +++ b/src/MyWidget.h @@ -1,7 +1,7 @@ #ifndef MYWIDGET_H #define MYWIDGET_H -#include +#include #include @@ -11,9 +11,9 @@ class MyWidget : public QWidget public: MyWidget(QWidget *parent = 0); virtual ~MyWidget(); + base::samples::RigidBodyState getPose(); public slots: - base::samples::RigidBodyState getPose(); void setPose(const base::samples::RigidBodyState pose); private: diff --git a/src/MyWidgetPlugin.cc b/src/MyWidgetPlugin.cc index d7ae3c3..86c0e92 100644 --- a/src/MyWidgetPlugin.cc +++ b/src/MyWidgetPlugin.cc @@ -1,8 +1,6 @@ #include "MyWidgetPlugin.h" #include "MyWidget.h" -Q_EXPORT_PLUGIN2(MyWidget, MyWidgetPlugin) - MyWidgetPlugin::MyWidgetPlugin(QObject *parent) : QObject(parent) { diff --git a/src/MyWidgetPlugin.h b/src/MyWidgetPlugin.h index dc45aa9..35c355f 100644 --- a/src/MyWidgetPlugin.h +++ b/src/MyWidgetPlugin.h @@ -1,12 +1,12 @@ #ifndef MYWIDGETPLUGIN_H #define MYWIDGETPLUGIN_H -#include -#include +#include class MyWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.dfki-rock-tutorial") Q_INTERFACES(QDesignerCustomWidgetInterface) public: diff --git a/src/main.cpp b/src/main.cpp index ec14b17..af58200 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,4 @@ -#include +#include #include "MyWidget.h" From 5352d73858f5b9eb00b23e8d8612701ba362cb63 Mon Sep 17 00:00:00 2001 From: mlodhi Date: Mon, 28 Mar 2022 14:36:25 +0200 Subject: [PATCH 02/20] Remove extra includes and add missing libs --- CMakeLists.txt | 5 +++-- src/CMakeLists.txt | 7 ++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ddad98a..bcbc4f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ # CMakeLists.txt has to be located in the project folder and cmake has to be # executed from 'project/build' with 'cmake ../'. -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 3.0) find_package(Rock) -rock_init(MyWidget 0.1) +project(MyWidget VERSION 0.1 DESCRIPTION "Widget tutorial") +rock_init() rock_standard_layout() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 81b5a03..763e090 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,10 +1,7 @@ -rock_find_qt5(Core Gui Widgets UiPlugin REQUIRED) +rock_find_qt5(Core Gui Widgets UiPlugin OpenGL Designer REQUIRED) -INCLUDE_DIRECTORIES(${QT5_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${Qt5Core_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${Qt5Gui_INCLUDE_DIRS}) -INCLUDE_DIRECTORIES(${Qt5Widgets_INCLUDE_DIRS}) -INCLUDE_DIRECTORIES(${QT5UiPlugin_INCLUDE_DIRS}) set(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -31,7 +28,7 @@ rock_vizkit_widget(MyWidget DEPS Qt5::Core Qt5::Gui Qt5::Widgets DEPS_PKGCONFIG base-types base-lib DEPS_CMAKE - LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${QT_QTDESIGNER_LIBRARY} + LIBS ${QT5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${QT5OpenGL_LIBRARIES} ${QT5Designer_LIBRARIES} ) rock_executable(mywidgetTest From 9b720472cee97c43c12684d417c19acf38495729 Mon Sep 17 00:00:00 2001 From: mlodhi Date: Mon, 25 Apr 2022 14:01:53 +0200 Subject: [PATCH 03/20] Remove global include directories as they are not needed anymore --- manifest.xml | 4 ++-- src/CMakeLists.txt | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/manifest.xml b/manifest.xml index 326d502..88e7e61 100644 --- a/manifest.xml +++ b/manifest.xml @@ -8,7 +8,7 @@ http:// - + - + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 763e090..7bf569e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,8 +1,5 @@ rock_find_qt5(Core Gui Widgets UiPlugin OpenGL Designer REQUIRED) -INCLUDE_DIRECTORIES(${Qt5Core_INCLUDE_DIRS}) -INCLUDE_DIRECTORIES(${Qt5Gui_INCLUDE_DIRS}) - set(CMAKE_INCLUDE_CURRENT_DIR ON) SET(MOC_HDRS From 6537d55ab561e248ae33c67a6f4d3d5a35d0a4c3 Mon Sep 17 00:00:00 2001 From: Pierre Willenbrock Date: Wed, 15 Jun 2022 18:39:05 +0200 Subject: [PATCH 04/20] Use qt5-designer as package dependency --- manifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.xml b/manifest.xml index 88e7e61..ec055ec 100644 --- a/manifest.xml +++ b/manifest.xml @@ -9,6 +9,6 @@ - + From 21e0c9a71f670a8f85108336693445872b65f0bf Mon Sep 17 00:00:00 2001 From: Pierre Willenbrock Date: Tue, 23 Sep 2025 09:53:10 +0200 Subject: [PATCH 05/20] fix: Remove .pc file someone errornously stuck into the repository Those are generated from the .pc.in --- src/MyWidget.pc | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 src/MyWidget.pc diff --git a/src/MyWidget.pc b/src/MyWidget.pc deleted file mode 100644 index c49cdb4..0000000 --- a/src/MyWidget.pc +++ /dev/null @@ -1,12 +0,0 @@ -prefix=/home/conquest/dev/ROCK-DEV/install -exec_prefix=/home/conquest/dev/ROCK-DEV/install -libdir=${prefix}/lib -includedir=${prefix}/include - -Name: MyWidget -Description: -Version: 0.1 -Requires: base-types base-lib QtCore QtGui -Libs: -L${libdir} -lMyWidget -Cflags: -I${includedir} - From 851df9ed52aa1600c79597fb70a07ef2d7c2bc54 Mon Sep 17 00:00:00 2001 From: Pierre Willenbrock Date: Tue, 23 Sep 2025 10:57:21 +0200 Subject: [PATCH 06/20] chore: Change to #pragma once instead of include guard --- src/MyWidget.h | 5 +---- src/MyWidgetPlugin.h | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/MyWidget.h b/src/MyWidget.h index e2a3529..a53cff5 100644 --- a/src/MyWidget.h +++ b/src/MyWidget.h @@ -1,5 +1,4 @@ -#ifndef MYWIDGET_H -#define MYWIDGET_H +#pragma once #include @@ -31,5 +30,3 @@ public slots: QLabel* l3; }; - -#endif /* MYWIDGET_H */ diff --git a/src/MyWidgetPlugin.h b/src/MyWidgetPlugin.h index dc45aa9..d1286ec 100644 --- a/src/MyWidgetPlugin.h +++ b/src/MyWidgetPlugin.h @@ -1,5 +1,4 @@ -#ifndef MYWIDGETPLUGIN_H -#define MYWIDGETPLUGIN_H +#pragma once #include #include @@ -28,5 +27,3 @@ class MyWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface private: bool initialized; }; - -#endif /* MYWIDGETPLUGIN_H */ From 957e40739f2c9285267bc3fc4b9fba3e3d2c84ca Mon Sep 17 00:00:00 2001 From: Pierre Willenbrock Date: Tue, 23 Sep 2025 15:37:34 +0200 Subject: [PATCH 07/20] chore: Only use includes needed, use forward declarations in headers --- src/MyWidgetPlugin.cc | 1 + src/MyWidgetPlugin.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MyWidgetPlugin.cc b/src/MyWidgetPlugin.cc index d7ae3c3..96b3eab 100644 --- a/src/MyWidgetPlugin.cc +++ b/src/MyWidgetPlugin.cc @@ -1,5 +1,6 @@ #include "MyWidgetPlugin.h" #include "MyWidget.h" +#include // for Q_EXPORT_PLUGIN2 Q_EXPORT_PLUGIN2(MyWidget, MyWidgetPlugin) diff --git a/src/MyWidgetPlugin.h b/src/MyWidgetPlugin.h index 129f434..9aee048 100644 --- a/src/MyWidgetPlugin.h +++ b/src/MyWidgetPlugin.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include From 4b6e0994a4f9d8e2f06a7d714bf033cff2320147 Mon Sep 17 00:00:00 2001 From: Pierre Willenbrock Date: Tue, 23 Sep 2025 11:26:39 +0200 Subject: [PATCH 08/20] fix: remove opengl requirement This is not a tutorial about using opengl, it does not showcase how to use opengl, and does not include qt-opengl correctly. --- manifest.xml | 1 - src/CMakeLists.txt | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/manifest.xml b/manifest.xml index 326d502..c672e05 100644 --- a/manifest.xml +++ b/manifest.xml @@ -10,5 +10,4 @@ - diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 34bf105..c55e57c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -find_package(Qt4 REQUIRED QtCore QtGui QtOpengl QtDesigner) +find_package(Qt4 REQUIRED QtCore QtGui QtDesigner) include_directories(${QT_INCLUDE_DIR}) include_directories(${QT_QTCORE_INCLUDE_DIR}) include_directories(${QT_QTGUI_INCLUDE_DIR}) @@ -26,7 +26,7 @@ rock_vizkit_widget(MyWidget MOC ${MOC_HDRS} DEPS_PKGCONFIG base-types base-lib QtCore QtGui DEPS_CMAKE - LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${QT_QTDESIGNER_LIBRARY} + LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTDESIGNER_LIBRARY} ) rock_executable(mywidgetTest From 7045da7c4010da39e49dd7c12c4038e7e1146cd5 Mon Sep 17 00:00:00 2001 From: Pierre Willenbrock Date: Tue, 23 Sep 2025 15:00:40 +0200 Subject: [PATCH 09/20] fix: properly use QtDesigner Qt component Realizing that this is to be replaced entirely later. --- src/CMakeLists.txt | 1 + src/MyWidgetPlugin.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c55e57c..3a27b98 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,6 +2,7 @@ find_package(Qt4 REQUIRED QtCore QtGui QtDesigner) include_directories(${QT_INCLUDE_DIR}) include_directories(${QT_QTCORE_INCLUDE_DIR}) include_directories(${QT_QTGUI_INCLUDE_DIR}) +include_directories(${QT_QTDESIGNER_INCLUDE_DIR}) set(CMAKE_INCLUDE_CURRENT_DIR ON) SET(MOC_HDRS diff --git a/src/MyWidgetPlugin.h b/src/MyWidgetPlugin.h index 9aee048..8642f8d 100644 --- a/src/MyWidgetPlugin.h +++ b/src/MyWidgetPlugin.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include class MyWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface { From 9b51875eea5fe267e5bc617caeb6d63a4269a80b Mon Sep 17 00:00:00 2001 From: Pierre Willenbrock Date: Tue, 23 Sep 2025 10:56:37 +0200 Subject: [PATCH 10/20] chore: Only use includes needed, use forward declarations in headers --- src/MyWidget.cc | 3 +++ src/MyWidget.h | 10 +++++++++- src/MyWidgetPlugin.h | 1 + src/main.cpp | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/MyWidget.cc b/src/MyWidget.cc index 7aa7ed7..55b16cf 100644 --- a/src/MyWidget.cc +++ b/src/MyWidget.cc @@ -1,4 +1,7 @@ #include "MyWidget.h" +#include +#include +#include MyWidget::MyWidget(QWidget *parent) : QWidget(parent) diff --git a/src/MyWidget.h b/src/MyWidget.h index a53cff5..35a8357 100644 --- a/src/MyWidget.h +++ b/src/MyWidget.h @@ -1,9 +1,17 @@ #pragma once -#include +#include #include +QT_BEGIN_NAMESPACE + +class QGroupBox; +class QFormLayout; +class QLabel; + +QT_END_NAMESPACE + class MyWidget : public QWidget { Q_OBJECT diff --git a/src/MyWidgetPlugin.h b/src/MyWidgetPlugin.h index d1286ec..129f434 100644 --- a/src/MyWidgetPlugin.h +++ b/src/MyWidgetPlugin.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include class MyWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface diff --git a/src/main.cpp b/src/main.cpp index ec14b17..59a91f5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,4 @@ -#include +#include #include "MyWidget.h" From 092829becc364f47cf1e43b11d6d343d3cb52e78 Mon Sep 17 00:00:00 2001 From: Pierre Willenbrock Date: Tue, 23 Sep 2025 13:02:53 +0200 Subject: [PATCH 11/20] fix: MyWidget::getPose does not really make sense as a Qt slot --- src/MyWidget.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MyWidget.h b/src/MyWidget.h index 35a8357..49ed805 100644 --- a/src/MyWidget.h +++ b/src/MyWidget.h @@ -18,9 +18,9 @@ class MyWidget : public QWidget public: MyWidget(QWidget *parent = 0); virtual ~MyWidget(); + base::samples::RigidBodyState getPose(); public slots: - base::samples::RigidBodyState getPose(); void setPose(const base::samples::RigidBodyState pose); private: From c94296865be2f81d7ade4f069d6ed6a5b8c33ff2 Mon Sep 17 00:00:00 2001 From: Pierre Willenbrock Date: Tue, 23 Sep 2025 10:56:37 +0200 Subject: [PATCH 12/20] chore: Only use includes needed, use forward declarations in headers --- src/MyWidgetPlugin.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/MyWidgetPlugin.h b/src/MyWidgetPlugin.h index ac02706..036cf15 100644 --- a/src/MyWidgetPlugin.h +++ b/src/MyWidgetPlugin.h @@ -1,7 +1,8 @@ #pragma once #include -#include +#include // for Q_PLUGIN_METADATA +#include class MyWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface { From 644470b21e0acd19f84405a78fe18bd7e3353973 Mon Sep 17 00:00:00 2001 From: Pierre Willenbrock Date: Tue, 23 Sep 2025 11:26:39 +0200 Subject: [PATCH 13/20] fix: remove opengl requirement This is not a tutorial about using opengl, it does not showcase how to use opengl, and does not include qt-opengl correctly. --- manifest.xml | 1 - src/CMakeLists.txt | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/manifest.xml b/manifest.xml index ec055ec..320d0cb 100644 --- a/manifest.xml +++ b/manifest.xml @@ -10,5 +10,4 @@ - diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7bf569e..630d6c2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -rock_find_qt5(Core Gui Widgets UiPlugin OpenGL Designer REQUIRED) +rock_find_qt5(Core Gui Widgets UiPlugin Designer REQUIRED) set(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -25,7 +25,7 @@ rock_vizkit_widget(MyWidget DEPS Qt5::Core Qt5::Gui Qt5::Widgets DEPS_PKGCONFIG base-types base-lib DEPS_CMAKE - LIBS ${QT5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${QT5OpenGL_LIBRARIES} ${QT5Designer_LIBRARIES} + LIBS ${QT5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${QT5Designer_LIBRARIES} ) rock_executable(mywidgetTest From 9b319b0b0f58caedfd2406ab86fc472acc2ab9b9 Mon Sep 17 00:00:00 2001 From: Pierre Willenbrock Date: Tue, 23 Sep 2025 11:54:59 +0200 Subject: [PATCH 14/20] fix: Use UiPlugin Qt5 component instead of Designer component --- src/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 630d6c2..e8e9a68 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -rock_find_qt5(Core Gui Widgets UiPlugin Designer REQUIRED) +rock_find_qt5(Core Gui Widgets UiPlugin REQUIRED) set(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -23,9 +23,10 @@ rock_vizkit_widget(MyWidget HEADERS ${HDRS} MOC ${MOC_HDRS} DEPS Qt5::Core Qt5::Gui Qt5::Widgets + DEPS_TARGET Qt5::UiPlugin DEPS_PKGCONFIG base-types base-lib DEPS_CMAKE - LIBS ${QT5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${QT5Designer_LIBRARIES} + LIBS ${QT5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${QT5UiPlugin_LIBRARIES} ) rock_executable(mywidgetTest From e482ba9e7563c3110d21471eb5c23ada87acca65 Mon Sep 17 00:00:00 2001 From: Pierre Willenbrock Date: Tue, 23 Sep 2025 15:01:51 +0200 Subject: [PATCH 15/20] feat: Prepare master branch to also host Qt5 build --- CMakeLists.txt | 6 ++++-- src/CMakeLists.txt | 10 ++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ddad98a..bcbb559 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ # CMakeLists.txt has to be located in the project folder and cmake has to be # executed from 'project/build' with 'cmake ../'. -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 3.5) +project(MyWidget VERSION 0.1 DESCRIPTION "Widget tutorial") find_package(Rock) -rock_init(MyWidget 0.1) +rock_init() +rock_feature(NOCURDIR) rock_standard_layout() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3a27b98..497dc80 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,8 +1,4 @@ -find_package(Qt4 REQUIRED QtCore QtGui QtDesigner) -include_directories(${QT_INCLUDE_DIR}) -include_directories(${QT_QTCORE_INCLUDE_DIR}) -include_directories(${QT_QTGUI_INCLUDE_DIR}) -include_directories(${QT_QTDESIGNER_INCLUDE_DIR}) +rock_find_qt4(QtCore QtGui QtDesigner) set(CMAKE_INCLUDE_CURRENT_DIR ON) SET(MOC_HDRS @@ -25,9 +21,7 @@ rock_vizkit_widget(MyWidget SOURCES ${SRCS} ${QtApp_RCC_SRCS} HEADERS ${HDRS} MOC ${MOC_HDRS} - DEPS_PKGCONFIG base-types base-lib QtCore QtGui - DEPS_CMAKE - LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTDESIGNER_LIBRARY} + DEPS_PKGCONFIG base-types base-lib QtCore QtGui QtDesigner ) rock_executable(mywidgetTest From ff5002d4062552a994b099fe9d56ff21fb645733 Mon Sep 17 00:00:00 2001 From: Pierre Willenbrock Date: Tue, 23 Sep 2025 15:52:22 +0200 Subject: [PATCH 16/20] feat: Move to using RockQt macros --- src/CMakeLists.txt | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 497dc80..7a837f5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,7 @@ rock_find_qt4(QtCore QtGui QtDesigner) + +include(RockQt) + set(CMAKE_INCLUDE_CURRENT_DIR ON) SET(MOC_HDRS @@ -17,13 +20,19 @@ FILE(GLOB SRCS SET(QtApp_RCCS resources.qrc) QT4_ADD_RESOURCES(QtApp_RCC_SRCS ${QtApp_RCCS}) -rock_vizkit_widget(MyWidget - SOURCES ${SRCS} ${QtApp_RCC_SRCS} +rock_qt_vizkit_widget( + TARGETPREFIX MyWidget + QT4_SUFFIX "" + SOURCES ${SRCS} + SOURCES_QT4 ${QtApp_RCC_SRCS} HEADERS ${HDRS} MOC ${MOC_HDRS} - DEPS_PKGCONFIG base-types base-lib QtCore QtGui QtDesigner + DEPS_PKGCONFIG base-types base-lib + DEPS_PKGCONFIG_QT4 QtCore QtGui QtDesigner ) -rock_executable(mywidgetTest - main.cpp - DEPS MyWidget) +rock_qt_executable( + TARGETPREFIX mywidgetTest + QT4_SUFFIX "" + SOURCES main.cpp + DEPS_QT MyWidget) From b7c0984d7a2719ed93cce90bb3643f56331381ac Mon Sep 17 00:00:00 2001 From: Pierre Willenbrock Date: Tue, 23 Sep 2025 16:12:32 +0200 Subject: [PATCH 17/20] feat: Move to using RockQt macros --- CMakeLists.txt | 4 ++-- src/CMakeLists.txt | 23 +++++++++++++--------- src/{MyWidget.pc.in => MyWidget-qt5.pc.in} | 0 3 files changed, 16 insertions(+), 11 deletions(-) rename src/{MyWidget.pc.in => MyWidget-qt5.pc.in} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index bcbc4f9..39ca35d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # CMakeLists.txt has to be located in the project folder and cmake has to be # executed from 'project/build' with 'cmake ../'. -cmake_minimum_required(VERSION 3.0) -find_package(Rock) +cmake_minimum_required(VERSION 3.5) project(MyWidget VERSION 0.1 DESCRIPTION "Widget tutorial") +find_package(Rock) rock_init() rock_standard_layout() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e8e9a68..91276b3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,7 @@ rock_find_qt5(Core Gui Widgets UiPlugin REQUIRED) +include(RockQt) + set(CMAKE_INCLUDE_CURRENT_DIR ON) SET(MOC_HDRS @@ -18,17 +20,20 @@ FILE(GLOB SRCS SET(QtApp_RCCS resources.qrc) QT5_ADD_RESOURCES(QtApp_RCC_SRCS ${QtApp_RCCS}) -rock_vizkit_widget(MyWidget - SOURCES ${SRCS} ${QtApp_RCC_SRCS} +rock_qt_vizkit_widget( + TARGETPREFIX MyWidget + QT4_SUFFIX "" + SOURCES ${SRCS} + SOURCES_QT5 ${QtApp_RCC_SRCS} HEADERS ${HDRS} MOC ${MOC_HDRS} - DEPS Qt5::Core Qt5::Gui Qt5::Widgets - DEPS_TARGET Qt5::UiPlugin + DEPS_QT5 Qt5::Core Qt5::Gui Qt5::Widgets + DEPS_TARGET_QT5 Qt5::UiPlugin DEPS_PKGCONFIG base-types base-lib - DEPS_CMAKE - LIBS ${QT5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${QT5UiPlugin_LIBRARIES} ) -rock_executable(mywidgetTest - main.cpp - DEPS MyWidget) +rock_qt_executable( + TARGETPREFIX mywidgetTest + QT4_SUFFIX "" + SOURCES main.cpp + DEPS_QT MyWidget) diff --git a/src/MyWidget.pc.in b/src/MyWidget-qt5.pc.in similarity index 100% rename from src/MyWidget.pc.in rename to src/MyWidget-qt5.pc.in From a7872378ae269a709f58cd2a465a0445bb00c019 Mon Sep 17 00:00:00 2001 From: Pierre Willenbrock Date: Tue, 23 Sep 2025 16:49:03 +0200 Subject: [PATCH 18/20] Rename HDRS to INSTALLED_HDRS to clearly communicate why they are declared --- src/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b6130ec..3e30bc5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,7 +10,7 @@ SET(MOC_HDRS MyWidgetPlugin.h ) -SET(HDRS +SET(INSTALLED_HDRS MyWidget.h ) @@ -32,7 +32,7 @@ rock_qt_vizkit_widget( SOURCES ${SRCS} SOURCES_QT4 ${QtApp_RCC_SRCS_QT4} SOURCES_QT5 ${QtApp_RCC_SRCS_QT5} - HEADERS ${HDRS} + HEADERS ${INSTALLED_HDRS} MOC ${MOC_HDRS} DEPS_QT5 Qt5::Core Qt5::Gui Qt5::Widgets DEPS_TARGET_QT5 Qt5::UiPlugin From 95928c927f95e357e01d20d9bc92b5c4b20cd7bd Mon Sep 17 00:00:00 2001 From: Pierre Willenbrock Date: Tue, 23 Sep 2025 17:08:34 +0200 Subject: [PATCH 19/20] Set SRCS to the relevant file names instead of searching for *.cc In my opinion the better style. --- src/CMakeLists.txt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3e30bc5..a40945f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,9 +14,15 @@ SET(INSTALLED_HDRS MyWidget.h ) -FILE(GLOB SRCS - *.cc -) +SET(SRCS + MyWidget.cc + MyWidgetPlugin.cc + ) +# Alternatively, FILE(GLOB) can find any matching file in the directory. +# For this reason, the mywidgetTest executable uses main.cpp instead of main.cc. +#FILE(GLOB SRCS +# *.cc +#) SET(QtApp_RCCS resources.qrc) if(ROCK_QT4) From a60e479a9f2227b567a5bdebd9cd841acdac3863 Mon Sep 17 00:00:00 2001 From: Pierre Willenbrock Date: Tue, 23 Sep 2025 17:09:48 +0200 Subject: [PATCH 20/20] feat: Use namespaced targets in cmake, pkgconfig package in .pc --- src/CMakeLists.txt | 16 +++++++++++++--- src/MyWidget-qt5.pc.in | 2 +- src/MyWidget.pc.in | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a40945f..d810d30 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -40,10 +40,20 @@ rock_qt_vizkit_widget( SOURCES_QT5 ${QtApp_RCC_SRCS_QT5} HEADERS ${INSTALLED_HDRS} MOC ${MOC_HDRS} - DEPS_QT5 Qt5::Core Qt5::Gui Qt5::Widgets - DEPS_TARGET_QT5 Qt5::UiPlugin DEPS_PKGCONFIG base-types base-lib - DEPS_PKGCONFIG_QT4 QtCore QtGui QtDesigner +# Using the cmake targets for target_link_libraries but the +# pkgconfig packages in the .pc file. +# equivalent pkgconfig based configuration: +# DEPS_PKGCONFIG_QT4 QtCore QtGui +# DEPS_PKGCONFIG_QT5 Qt5Core Qt5Gui Qt5Widgets +# above will also add the dependencies to the .pc file, so they +# are not needed in the .pc.in. + LIBS_QT4 Qt4::QtCore Qt4::QtGui + LIBS_QT5 Qt5::Core Qt5::Gui Qt5::Widgets +# for include directories. These do not need to be added to the .pc files, +# the INSTALLED_HDRS do not use them. + LIBS_QT4 Qt4::QtDesigner + LIBS_QT5 Qt5::UiPlugin ) rock_qt_executable( diff --git a/src/MyWidget-qt5.pc.in b/src/MyWidget-qt5.pc.in index 7759a93..0459dd8 100644 --- a/src/MyWidget-qt5.pc.in +++ b/src/MyWidget-qt5.pc.in @@ -6,7 +6,7 @@ includedir=${prefix}/include Name: @TARGET_NAME@ Description: @PROJECT_DESCRIPTION@ Version: @PROJECT_VERSION@ -Requires: @DEPS_PKGCONFIG@ +Requires: @DEPS_PKGCONFIG@ Qt5Core Qt5Gui Qt5Widgets Libs: -L${libdir} -l@TARGET_NAME@ Cflags: -I${includedir} diff --git a/src/MyWidget.pc.in b/src/MyWidget.pc.in index 7759a93..4dd93b8 100644 --- a/src/MyWidget.pc.in +++ b/src/MyWidget.pc.in @@ -6,7 +6,7 @@ includedir=${prefix}/include Name: @TARGET_NAME@ Description: @PROJECT_DESCRIPTION@ Version: @PROJECT_VERSION@ -Requires: @DEPS_PKGCONFIG@ +Requires: @DEPS_PKGCONFIG@ QtCore QtGui Libs: -L${libdir} -l@TARGET_NAME@ Cflags: -I${includedir}