- Language: C++23 and QML.
- Framework: Qt 6.11 (QuickControls2, SerialPort).
- Build System: CMake (minimum 3.31).
- Platform: Desktop (Linux/Windows/macOS) and Android.
Quick CMake build (recommended):
cmake -B build/ai -S . -G Ninja -DCMAKE_BUILD_TYPE=Debug
cmake --build build/aiNotes:
- To enable AddressSanitizer set
-DUSE_ASAN=ONin the CMake configure command (see examples below). - On platforms that require
libusbfor Android builds set-DANDROID_LIBUSB_DIR=/path/to/libusb.
-DUSE_ASAN=ON: Enables Address Sanitizer (default OFF).-DBUILD_TESTS=ON: Build the test targets (default OFF).-DUSE_QT_SERIAL_PORT=ON/OFF: Toggles betweenQSerialPortandlibusb-1.0. Defaults toONfor Desktop,OFFfor Android.-DANDROID_LIBUSB_DIR=/path/to/libusb: Required when building for Android to locate libusb.
-
Strings (CRITICAL):
QT_NO_CAST_FROM_ASCIIis strictly enforced. You must wrap raw C-strings when passing to Qt APIs. Prefer the Qt string literal operatoru"text"_s(enabled viausing namespace Qt::StringLiterals;) orQString::fromUtf8("text"). Do not pass"text"directly to functions expectingQString. -
String Concatenation:
QT_USE_QSTRINGBUILDERis enabled globally, sooperator+is already optimized via QStringBuilder. Always use+for concatenation (e.g.,u"a"_s + u"b"_s). Do not use%. Never assign a QStringBuilder expression toauto— the builder type is a temporary proxy and can cause dangling references; always assign toQStringexplicitly. -
Centralized header: This project provides a single shared header at
Headers.hpp(root of the repo) that pulls common Qt/std headers and also declares global using directives:using namespace Qt::StringLiterals;(enablesu""_sliterals)using namespace std;
If you change how string literals are used (or edit
Headers.hpp), consider refreshing it and recompiling the project so all translation units pick up the change. Avoid making accidental edits to the globalusingdirectives without coordinating with the team — changing them can silently affect many files. -
Compiler Warnings:
-Wsign-compareis explicitly enabled. Ensure signed/unsigned types match in comparisons. -
QML Architecture: The project uses Qt 6's
qt_add_qml_modulefor QML compilation to C++.AppQmlSingleton.qmlis configured as a singleton type.
- Verify successful compilation locally after modifying C++ or QML files.
- Run the executable locally from the build directory to ensure QML engine loads correctly.
- Tests live in the
tests/directory (for exampletests/AlgorithmTests.cpp) and are built by the CMake project.
How to run tests:
- Using the
build/aidirectory from the build example above:- Note: tests are only built if
-DBUILD_TESTS=ONis passed to CMake (default OFF). - Configure & build tests:
cmake -B build/ai -S . -G Ninja -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON && cmake --build build/ai - Run all tests:
ctest --test-dir build/ai --output-on-failure - List tests:
ctest --test-dir build/ai -N - Run tests matching a regex:
ctest --test-dir build/ai -R <regex> - Or run a test binary directly (typically under
build/ai/tests/).
- Note: tests are only built if
ASAN (AddressSanitizer):
- Enable ASAN at configure time:
cmake -B build/ai -S . -G Ninja -DCMAKE_BUILD_TYPE=Debug -DUSE_ASAN=ON -DBUILD_TESTS=ONthen build and run tests. ASAN builds are useful for finding memory issues; when running under ASAN prefer single-threaded test execution for clearer reports:ctest --test-dir build/ai -j1 --output-on-failure.