Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake C++ GTK 4 Community Template #286

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ We encourage you to also contribute templates. The community supported templates
| ![](https://raw.githubusercontent.com/toradex/vscode-torizon-templates-documentation/refs/heads/main/thumbnails/avaloniagtk.png?raw=true) | .NET 8 C# Avalonia GTK MVVM | .NET 8.0 | C# | ![](assets/img/arm32.png?raw=true&id=2) ![](assets/img/arm64.png?raw=true&id=2) | [dotnetAvalonia](./dotnetAvalonia) | ![](https://avatars.githubusercontent.com/u/2633321?v=4&s=64) [@microhobby](https://www.github.com/microhobby) |
| ![](https://raw.githubusercontent.com/toradex/vscode-torizon-templates-documentation/refs/heads/main/thumbnails/gambasform.png?raw=true) | Gambas3 Form Project | Gambas3 | Visual Basic | ![](assets/img/arm32.png?raw=true&id=2) ![](assets/img/arm64.png?raw=true&id=2) | [gambasForms](./gambasForms) | ![](https://avatars.githubusercontent.com/u/2633321?v=4&s=64) [@microhobby](https://www.github.com/microhobby) |
| ![](https://raw.githubusercontent.com/toradex/vscode-torizon-templates-documentation/refs/heads/main/thumbnails/python3console.png?raw=true) | Python 3 Pyside 2(Qt5) QML | Pyside 2 | Python 3 | ![](assets/img/arm32.png?raw=true&id=2) ![](assets/img/arm64.png?raw=true&id=2) | [python3Pyside2QML](./python3Pyside2QML) | ![](https://github.com/toradex/vscode-torizon-templates-documentation/blob/main/thumbnails/none.png?raw=true) [@andreriesco](https://www.github.com/andreriesco) |
| ![](https://raw.githubusercontent.com/toradex/vscode-torizon-templates-documentation/refs/heads/main/thumbnails/gtk3.png?raw=true) | CMake C++ GTK 4 | GTK 4 | C++ | ![](assets/img/arm32.png?raw=true&id=2) ![](assets/img/arm64.png?raw=true&id=2) | [cmakeGTK4](./cmakeGTK4) | ![](https://avatars.githubusercontent.com/u/7726309?v=4&s=64) ![](https://avatars.githubusercontent.com/u/142019321?v=4&s=64) [@torizon](https://www.github.com/torizon) |
| ![](https://raw.githubusercontent.com/toradex/vscode-torizon-templates-documentation/refs/heads/main/thumbnails/cconsole.png?raw=true) | C Makefile Console Application | libc | C | ![](assets/img/arm32.png?raw=true&id=2) ![](assets/img/arm64.png?raw=true&id=2) ![](assets/img/riscv64.png?raw=true&id=2) ![](assets/img/x8664.png?raw=true&id=2) | [cConsole](./cConsole) | ![](https://avatars.githubusercontent.com/u/19562097?v=4&s=64) [@hiagofranco](https://www.github.com/hiagofranco) |
| ![](https://raw.githubusercontent.com/toradex/vscode-torizon-templates-documentation/refs/heads/main/thumbnails/zig-console.png?raw=true) | Zig Console Application | no-libc | Zig | ![](assets/img/arm32.png?raw=true&id=2) ![](assets/img/arm64.png?raw=true&id=2) | [zigConsole](./zigConsole) | ![](https://avatars.githubusercontent.com/u/6756180?v=4&s=64) [@kassane](https://www.github.com/kassane) |
| ![](https://raw.githubusercontent.com/toradex/vscode-torizon-templates-documentation/refs/heads/main/thumbnails/unogtk5.png?raw=true) | .NET 8 C# Uno 5 Platform Skia.GTK | .NET 8.0 | C# | ![](assets/img/arm32.png?raw=true&id=2) ![](assets/img/arm64.png?raw=true&id=2) | [dotnetUno5](./dotnetUno5) | ![](https://avatars.githubusercontent.com/u/2633321?v=4&s=64) [@microhobby](https://www.github.com/microhobby) |
Expand Down
11 changes: 11 additions & 0 deletions cmakeGTK4/.conf/deps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"packages": [
"openssh-client",
"sshpass",
"build-essential",
"cmake",
"gdb",
"g++",
"libgtk-4-dev"
]
}
27 changes: 27 additions & 0 deletions cmakeGTK4/.conf/id_rsa
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAqpUaOa6i/TaSKwpdsHzLfGK95dDcFYpmYH5hUj0cBhVEVdl8
JAG0MEDcZsjQHiBlfUiHmyU2iOWBoKUytpMnzYF6ggdZBv5hBMv3RcTlnNijxzxg
KvbjTm3LqAY8uu4SF9I8oDXVOn7xwZYgiC7s3XRGOP6TowSVEHsLB+cehWs4Y5io
3BngOlcOYZtVrh+i3A7xSHWP7n2IetJEo5C425oaOCZXUJT2egau6ODmvBItZjpG
mNdwVwrEI2H3o+LLI9tieNfyFcUFPNDRXbku1V0mXU9VjZ7WFihZXob11XNCEkY7
Bg3SpzTntSRn9hZD7i3xDU9MSJz90rnn56ID1wIDAQABAoIBACI239i7/3Mcc/rw
DFSu4z2irIYg+1PSu7AVCT4uhaVutJMnmS+7q8GV8N8o3h18z/5uAs0KjMKuje6D
1AUsxOoCU2krQh8V/K2yn3k+AfQQu+DlakCT3onHmfassZeo0rY2c/SKd6dQ+Pqk
Owg1qUrN3Jvn7ALhk2iH1XGTWNrXj44AxVVhK3zADd/688stubo+mhj1vLJvk3IJ
j/cb9UtCnWDZ6U6E4C+5tfXqzrqbtlrWnIBe0qAwYI6+f4bSQxnNa42wNUh0v0mX
tiY9wnHEmE7nCQNQ8sBeBLEJm3xmFRhABNA+iAglsjfeBIbPNpy7rXty412CmHp0
mLG0RskCgYEA4t4Ca3EDq/scg7fiplLjhk2AtsZumkYT/N+42x4VlioKfoaivLKf
6mjWUSr+c7Aq0Ssx9GdOFU0epNGbuvymCGBhq6v27SADMJTP2Dmg83FpcV6opOUM
SBz1tnrL9j74Eo9jGdnBjgxHOl4biO+uCjCZxcLoVjsfPpGnCeNSpFUCgYEAwHzM
GfiBR9wl+7cVrtP4YQgmzyZ6YCnqkfFasVAe6cN/0if5sqQRn3Fg3YFrP9GlKkkn
EMvow56nTWUmpx4KG4yanrocEYIsA4uv4kwyFOC/YD+67SQpgTEOjD0seDJoOgpz
ekkxNjMro8RJCK+DrV17qk3/dGY4b3u2M66P03sCgYEAhHCcswJX5WeD/vUzkGtl
PfsywADZgqCUfJRSg0Bt06sZU0Hf8Q7KQnsPWnUh9IGMjW2NDSPdtpu93vQq2J8z
gkJZ4nFShp2gnxTQvWbvKg80QiXDh/fbEqItY2kOduPNyHACp42y6+0JC+7yXh+l
13cF3ihpoCWFmO5IuIIHtb0CgYEAk5acwEUEi17HWOuWmog4591iNG8iYd2B2Akh
Ktdt/HtD5JV2JX0bbg924CA9ZZ+Pbo7Mf1p5zJQ3X2Zxbq3fviPe4ll88AfJS6at
Y2xc8hkpY9k5sF6L3F0K9IhrMnYj6GzfAiJgs1gk29rCzQAWjLUi/v/zIQLHvuMy
Xwo3iUUCgYEAo/27Qkb5nOdL8sJwFggDrdB1pPrxXN20KmYCJF1P9wPDhnj1fJ7+
0Z/56XYzPA2rQx0vf5idvoGQ3KZS7QkOClLtcyevH3b38fnmAqv+dPLRHmrSd+3G
BspdMlr3rwZK8RKwXjDzLYpwSvjmf7PTGTPO3C7WTzg+m0U9RbSJKi4=
-----END RSA PRIVATE KEY-----
1 change: 1 addition & 0 deletions cmakeGTK4/.conf/id_rsa.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqlRo5rqL9NpIrCl2wfMt8Yr3l0NwVimZgfmFSPRwGFURV2XwkAbQwQNxmyNAeIGV9SIebJTaI5YGgpTK2kyfNgXqCB1kG/mEEy/dFxOWc2KPHPGAq9uNObcuoBjy67hIX0jygNdU6fvHBliCILuzddEY4/pOjBJUQewsH5x6FazhjmKjcGeA6Vw5hm1WuH6LcDvFIdY/ufYh60kSjkLjbmho4JldQlPZ6Bq7o4Oa8Ei1mOkaY13BXCsQjYfej4ssj22J41/IVxQU80NFduS7VXSZdT1WNntYWKFlehvXVc0ISRjsGDdKnNOe1JGf2FkPuLfENT0xInP3SuefnogPX
10 changes: 10 additions & 0 deletions cmakeGTK4/.conf/update.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"source": "CMakeLists.txt",
"target": "CMakeLists.txt"
},
{
"source": ".vscode/c_cpp_properties.json",
"target": ".vscode/c_cpp_properties.json"
}
]
19 changes: 19 additions & 0 deletions cmakeGTK4/.doc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# C++ CMake GTK 4 Template Specific Documentation

> ⚠️ **WARNING:** This is just the documentation part specific of this template. **For the complete and general Torizon IDE documentation, check the [developer website documentation](https://developer.toradex.com/torizon/application-development/ide-extension/)** ⚠️

All projects follow the pipeline of tasks described in the [common contributing documentation](https://github.com/toradex/vscode-torizon-templates/blob/bookworm/CONTRIBUTING.md#contributing-templates). However, each project has its own specificities in terms of technologies and methods used to compile, deploy, and debug the code. Therefore, each of them has their own specific tasks in the `tasks.json` file.

This C++ GTK 4 template uses `cmake` and `make` to compile the code, with tasks named `build-configure-\${architecture}` (creates the destination directory for the future compiled code and generates the Makefile, using `cmake`) and `build-debug-\${architecture}` (compiles the code). It also uses an SDK container to cross-compile the code. This container image is built using the `Dockerfile.sdk` file, and the tasks that build the containers are named `build-container-image-sdk-\${architecture}`.

The compiled code is then copied into the container, in the `torizon_app_root` (which is automatically passed to the `APP_ROOT` variable in the `Dockerfiles`) directory defined at `settings.json`, through the Docker `COPY` command.

The task that has the entire pipeline of executed tasks, from the first step to the last step before the debugging, is the `deploy-torizon-\${architecture}` task.

Finally, remote debugging is performed by attaching to the GDB on the running container on the device using a [VSCode feature called Pipe Transport](https://code.visualstudio.com/docs/cpp/pipe-transport). For local debugging, the [VSCode method for C/C++ Debugging](https://code.visualstudio.com/docs/cpp/launch-json-reference) is used. The tasks that perform the debugging are those present in the `launch.json` file.

The source code of the template is a simple GTK 3 Hello World (Hello Torizon, actually) in C++, using CMake as build system.

## About GTK 4

To learn or use GTK 4, you must refer to the official [GTK 4 Documentation](https://www.gtk.org/docs/).
1 change: 1 addition & 0 deletions cmakeGTK4/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
credentials.zip
84 changes: 84 additions & 0 deletions cmakeGTK4/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@

# Created by https://www.gitignore.io/api/c,c++,cmake

### C ###
# Prerequisites
*.d

# Object files
*.o
*.ko
*.obj
*.elf

# Linker output
*.ilk
*.map
*.exp

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

# Debug files
*.dSYM/
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf

### C++ ###
# Prerequisites

# Compiled Object files
*.slo

# Precompiled Headers

# Compiled Dynamic libraries

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai

# End of https://www.gitignore.io/api/c,c++,cmake

credentials.zip
*.lock.yml

#Build directories
build-*

.conf/.depok
.conf/.docok
16 changes: 16 additions & 0 deletions cmakeGTK4/.vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"configurations": [
{
"name": "__change__",
"includePath": [
"${workspaceFolder}/includes/**",
"/usr/include/**"
],
"intelliSenseMode": "linux-gcc-x64",
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu17",
"cppStandard": "gnu++17"
}
],
"version": 4
}
6 changes: 6 additions & 0 deletions cmakeGTK4/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"ms-vscode.cpptools",
"twxs.cmake"
]
}
171 changes: 171 additions & 0 deletions cmakeGTK4/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Local AMD64",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build-local/bin/__change__",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "build-debug-local"
},
{
"name": "Torizon AMD64",
"type": "cppdbg",
"request": "launch",
"program": "${config:torizon_app_root}/__change__",
"args": [],
"stopAtEntry": false,
"cwd": "${config:torizon_app_root}",
"environment": [],
"externalConsole": false,
"internalConsoleOptions": "openOnSessionStart",
"logging": {
"engineLogging": false, // set this to true for a detailed log on the debug console
},
"sourceFileMap": {
"${config:torizon_app_root}": "${workspaceFolder}"
},
"pipeTransport": {
"debuggerPath": "/usr/bin/gdb",
"pipeProgram": "ssh",
"pipeArgs": [
"-T",
"-q",
"-p",
"${config:torizon_debug_ssh_port}",
"-o",
"StrictHostKeyChecking=no",
"-o",
"UserKnownHostsFile /dev/null",
"${config:torizon_run_as}@${config:torizon_ip}" // user@device
]
},
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "deploy-torizon-amd64"
},
{
"name": "Torizon ARMv7",
"type": "cppdbg",
"request": "launch",
"program": "${config:torizon_app_root}/__change__",
"args": [],
"stopAtEntry": false,
"cwd": "${config:torizon_app_root}",
"environment": [],
"externalConsole": false,
"internalConsoleOptions": "openOnSessionStart",
"logging": {
"engineLogging": false, // set this to true for a detailed log on the debug console
},
"sourceFileMap": {
"${config:torizon_app_root}": "${workspaceFolder}"
},
"pipeTransport": {
"debuggerPath": "/usr/bin/gdb",
"pipeProgram": "ssh",
"pipeArgs": [
"-T",
"-q",
"-p",
"${config:torizon_debug_ssh_port}",
"-o",
"StrictHostKeyChecking=no",
"-o",
"UserKnownHostsFile /dev/null",
"${config:torizon_run_as}@${config:torizon_ip}" // user@device
]
},
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "deploy-torizon-arm"
},
{
"name": "Torizon ARMv8",
"type": "cppdbg",
"request": "launch",
"program": "${config:torizon_app_root}/__change__",
"args": [],
"stopAtEntry": false,
"cwd": "${config:torizon_app_root}",
"environment": [],
"externalConsole": false,
"internalConsoleOptions": "openOnSessionStart",
"logging": {
"engineLogging": false, // set this to true for a detailed log on the debug console
},
"sourceFileMap": {
"${config:torizon_app_root}": "${workspaceFolder}"
},
"pipeTransport": {
"debuggerPath": "/usr/bin/gdb",
"pipeProgram": "ssh",
"pipeArgs": [
"-T",
"-q",
"-p",
"${config:torizon_debug_ssh_port}",
"-o",
"StrictHostKeyChecking=no",
"-o",
"UserKnownHostsFile /dev/null",
"${config:torizon_run_as}@${config:torizon_ip}" // user@device
]
},
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "deploy-torizon-arm64"
},
]
}
21 changes: 21 additions & 0 deletions cmakeGTK4/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"torizon_psswd": "",
"torizon_login": "",
"torizon_ip": "",
"torizon_ssh_port": "",
"host_ip": "",
"torizon_workspace": "${workspaceFolder}",
"torizon_debug_ssh_port": "2230",
"torizon_debug_port1": "2232",
"torizon_debug_port2": "2233",
"torizon_debug_port3": "",
"torizon_gpu": "",
"torizon_arch": "",
"wait_sync": "1",
"torizon_run_as": "torizon",
"torizon_app_root": "/home/torizon/app",
"tcb.packageName": "__change__",
"tcb.version": "3.11.0",
"torizon.gpuPrefixRC": true,
"terminal.integrated.defaultProfile.linux": "bash"
}
Loading
Loading