Skip to content

Commit

Permalink
cppQML: Add the hardware acceleration support for the Qt template
Browse files Browse the repository at this point in the history
Add the hardware acceleration support for the Qt template, by
using the newly release Torizon Qt6 containers (torizon/qt6-wayland and
torizon/qt6-wayland-vivante).
Also change the build tool from qmake6 to cmake, because at the moment
the "quick" module when added through qmake6 (in the .pro file),
adds the requirement of libGLX on the Makefile, which is not available
for the iMX8 modules.
Therefore, before it gets fixed, to use qmake6 you have remove the
/usr/lib/aarch64-linux-gnu/libGLX.so from the LIBS of the Makefile
generated by qmake6 before running "make". Because of that, the
recommended way is to use CMake, the default of this new
hardware accelerated Qt6 template.

Signed-off-by: Andre Riesco <[email protected]>
  • Loading branch information
andreriesco committed Oct 16, 2023
1 parent a614d22 commit e3eab9c
Show file tree
Hide file tree
Showing 9 changed files with 195 additions and 95 deletions.
2 changes: 1 addition & 1 deletion cppQML/.conf/deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"gdb",
"gdb-multiarch",
"g++",
"qmake6",
"cmake",
"qt6-base-dev",
"qt6-declarative-dev",
"netcat-traditional",
Expand Down
1 change: 1 addition & 0 deletions cppQML/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ amd64
.qt
credentials.zip
*.lock.yml
build-*
8 changes: 4 additions & 4 deletions cppQML/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Local AMD64",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/x86_64/debug/__change__",
"program": "${workspaceFolder}/build-local/debug/__change__",
"args": [
],
"stopAtEntry": false,
Expand Down Expand Up @@ -49,7 +49,7 @@
],
"externalConsole": false,
"sourceFileMap": {
"/app/amd64": "${workspaceFolder}/amd64"
"/app": "${workspaceFolder}"
},
"pipeTransport": {
"debuggerPath": "/usr/bin/gdb",
Expand Down Expand Up @@ -104,7 +104,7 @@
],
"externalConsole": false,
"sourceFileMap": {
"/app/aarch64": "${workspaceFolder}/aarch64"
"/app": "${workspaceFolder}"
},
"pipeTransport": {
"debuggerPath": "/usr/bin/gdb",
Expand Down Expand Up @@ -159,7 +159,7 @@
],
"externalConsole": false,
"sourceFileMap": {
"/app/armhf": "${workspaceFolder}/armhf"
"/app": "${workspaceFolder}"
},
"pipeTransport": {
"debuggerPath": "/usr/bin/gdb",
Expand Down
128 changes: 66 additions & 62 deletions cppQML/.vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,13 @@
}
},
{
"label": "run-qmake-debug-amd64-local",
"label": "build-configure-amd64-local",
"hide": true,
"command": "qmake6",
"command": "cmake",
"type": "shell",
"args": [
"-o",
"x86_64/Makefile",
"CONFIG+=debug",
"CONFIG+=qml_debug"
"-DCMAKE_BUILD_TYPE=Debug",
"-B${workspaceFolder}/build-local"
],
"problemMatcher": [
"$gcc"
Expand All @@ -312,13 +310,12 @@
},
{
"label": "build-debug-amd64-local",
"detail": "Build the application debug for amd64 using the\ndevelopment host toolchain.",
"command": "make",
"detail": "Build a debug version of the application for amd64 using\nthe toolchain installed in the host.",
"command": "cmake",
"type": "shell",
"options": {
"cwd": "${workspaceFolder}/x86_64"
},
"args": [
"--build",
"${workspaceFolder}/build-local"
],
"problemMatcher": [
"$gcc"
Expand All @@ -329,18 +326,18 @@
},
"dependsOrder": "sequence",
"dependsOn": [
"run-qmake-debug-amd64-local",
"copy-assets-amd64-local"
"build-configure-amd64-local"
]
},
},
{
"label": "clean-amd64-local",
"command": "make",
"label": "clean-local",
"detail": "Clean the local application build directory.",
"command": "cmake",
"type": "shell",
"options": {
"cwd": "${workspaceFolder}/x86_64"
},
"args": [
"--build",
"build-local",
"--target",
"clean"
],
"problemMatcher": [
Expand All @@ -352,7 +349,7 @@
}
},
{
"label": "run-qmake-debug-arm64",
"label": "build-configure-arm64",
"hide": true,
"command": "DOCKER_HOST=",
"type": "shell",
Expand All @@ -364,9 +361,11 @@
"-v",
"${workspaceFolder}:/app",
"cross-toolchain-arm64-__container__",
"bash",
"-c",
"qmake6 -o aarch64/Makefile CONFIG+=debug CONFIG+=qml_debug"
"cmake",
"-DCMAKE_BUILD_TYPE=Debug",
"-DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++",
"-DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc",
"-Bbuild-arm64"
],
"problemMatcher": [
"$gcc"
Expand All @@ -382,7 +381,7 @@
},
{
"label": "build-debug-arm64",
"detail": "Build the application debug for arm64 using the\ncontainer SDK toolchain.",
"detail": "Build a debug version of the application for arm64 using\nthe toolchain from the SDK container.",
"command": "DOCKER_HOST=",
"type": "shell",
"args": [
Expand All @@ -393,9 +392,9 @@
"-v",
"${workspaceFolder}:/app",
"cross-toolchain-arm64-__container__",
"bash",
"-c",
"cd aarch64 && make -j12"
"cmake",
"--build",
"build-arm64"
],
"problemMatcher": [
"$gcc"
Expand All @@ -406,8 +405,7 @@
},
"dependsOrder": "sequence",
"dependsOn": [
"run-qmake-debug-arm64",
"copy-assets-arm64"
"build-configure-arm64"
]
},
{
Expand All @@ -423,9 +421,11 @@
"-v",
"${workspaceFolder}:/app",
"cross-toolchain-arm64-__container__",
"bash",
"-c",
"\"cd aarch64 && make clean\""
"cmake",
"--build",
"build-arm64",
"--target",
"clean"
],
"problemMatcher": [
"$gcc"
Expand Down Expand Up @@ -455,7 +455,7 @@
"-P",
"${config:torizon_debug_ssh_port}",
"-pr",
"${workspaceFolder}/aarch64/debug",
"${workspaceFolder}/build-arm64/debug",
"${config:torizon_run_as}@${config:torizon_ip}:~/app"
],
"dependsOn": [
Expand All @@ -480,7 +480,7 @@
}
},
{
"label": "run-qmake-debug-arm",
"label": "build-configure-arm",
"hide": true,
"command": "DOCKER_HOST=",
"type": "shell",
Expand All @@ -492,9 +492,11 @@
"-v",
"${workspaceFolder}:/app",
"cross-toolchain-arm-__container__",
"bash",
"-c",
"\"qmake6 -o armhf/Makefile CONFIG+=debug CONFIG+=qml_debug\""
"cmake",
"-DCMAKE_BUILD_TYPE=Debug",
"-DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++",
"-DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc",
"-Bbuild-armhf"
],
"problemMatcher": [
"$gcc"
Expand All @@ -510,7 +512,7 @@
},
{
"label": "build-debug-arm",
"detail": "Build the application debug for armhf using the\ncontainer SDK toolchain.",
"detail": "Build a debug version of the application for armhf using\nthe toolchain from the SDK container.",
"command": "DOCKER_HOST=",
"type": "shell",
"args": [
Expand All @@ -521,9 +523,9 @@
"-v",
"${workspaceFolder}:/app",
"cross-toolchain-arm-__container__",
"bash",
"-c",
"\"cd armhf && make -j12\""
"cmake",
"--build",
"build-armhf"
],
"problemMatcher": [
"$gcc"
Expand All @@ -534,8 +536,7 @@
},
"dependsOrder": "sequence",
"dependsOn": [
"run-qmake-debug-arm",
"copy-assets-arm"
"build-configure-arm"
]
},
{
Expand All @@ -551,9 +552,11 @@
"-v",
"${workspaceFolder}:/app",
"cross-toolchain-arm-__container__",
"bash",
"-c",
"\"cd armhf && make clean\""
"cmake",
"--build",
"build-armhf",
"--target",
"clean"
],
"problemMatcher": [
"$gcc"
Expand Down Expand Up @@ -583,7 +586,7 @@
"-P",
"${config:torizon_debug_ssh_port}",
"-pr",
"${workspaceFolder}/armhf/debug",
"${workspaceFolder}/build-armhf/debug",
"${config:torizon_run_as}@${config:torizon_ip}:~/app"
],
"dependsOn": [
Expand All @@ -608,7 +611,7 @@
}
},
{
"label": "run-qmake-debug-amd64",
"label": "build-configure-amd64",
"hide": true,
"command": "DOCKER_HOST=",
"type": "shell",
Expand All @@ -620,9 +623,9 @@
"-v",
"${workspaceFolder}:/app",
"cross-toolchain-amd64-__container__",
"bash",
"-c",
"\"qmake6 -o amd64/Makefile CONFIG+=debug CONFIG+=qml_debug\""
"cmake",
"-DCMAKE_BUILD_TYPE=Debug",
"-Bbuild-amd64"
],
"problemMatcher": [
"$gcc"
Expand All @@ -638,7 +641,7 @@
},
{
"label": "build-debug-amd64",
"detail": "Build the application debug for amd64 using the\ncontainer SDK toolchain.",
"detail": "Build a debug version of the application for arm64 using\nthe toolchain from the SDK container.",
"command": "DOCKER_HOST=",
"type": "shell",
"args": [
Expand All @@ -649,9 +652,9 @@
"-v",
"${workspaceFolder}:/app",
"cross-toolchain-amd64-__container__",
"bash",
"-c",
"\"cd amd64 && make -j12\""
"cmake",
"--build",
"build-amd64"
],
"problemMatcher": [
"$gcc"
Expand All @@ -662,8 +665,7 @@
},
"dependsOrder": "sequence",
"dependsOn": [
"run-qmake-debug-amd64",
"copy-assets-amd64"
"build-configure-amd64"
]
},
{
Expand All @@ -678,10 +680,12 @@
"-it",
"-v",
"${workspaceFolder}:/app",
"cross-toolchain-amd64-__change__",
"bash",
"-c",
"\"cd amd64 && make clean\""
"cross-toolchain-amd64-__container__",
"cmake",
"--build",
"build-amd64",
"--target",
"clean"
],
"problemMatcher": [
"$gcc"
Expand Down Expand Up @@ -711,7 +715,7 @@
"-P",
"${config:torizon_debug_ssh_port}",
"-pr",
"${workspaceFolder}/amd64/debug",
"${workspaceFolder}/build-amd64/debug",
"${config:torizon_run_as}@${config:torizon_ip}:~/app"
],
"dependsOn": [
Expand Down
36 changes: 36 additions & 0 deletions cppQML/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
cmake_minimum_required(VERSION 3.16)
project(__change__ LANGUAGES CXX C)

set(CMAKE_AUTOMOC ON)

find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick)

qt_add_executable(__change__ WIN32
main.cpp
)

set_target_properties(__change__ PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "debug"
ARCHIVE_OUTPUT_DIRECTORY "debug"
LIBRARY_OUTPUT_DIRECTORY "debug"
WIN32_EXECUTABLE TRUE
)

target_link_libraries(__change__ PRIVATE
Qt::Core
Qt::Gui
Qt::Qml
Qt::Quick
)

qt6_add_qml_module(__change__
URI __change__
VERSION 1.0
QML_FILES
"QML/main.qml"
"QML/Scene.ui.qml"
RESOURCES
"QML/assets/torizon-logo.png"
)


Loading

0 comments on commit e3eab9c

Please sign in to comment.