status-desktop/app
Stefan 1e8c851283 chore(CPP): Basic project configuration setup using Qt6
Considerations

- Use versioned files. Versioned Qt CMake APIs are disabled to force explicit calls and say that we don't support older `QT`s
- Don't use blobbing. Use `target_sources` and `qt_target_qml_sources`
- Distribute `CMake` definitions closer to the context: main folders with their own `CMakeLists.txt`
- Everything in libraries under `Status` namespace for cleaner code.
- Includes are exposed with Module folder externally and without prefix internally
- File/Folders name matches definitions they contain for uniformity that leads to cleaner code
- All source files (cpp, qml, js ...) have to be added to one of the CMakeLists.txt files to be tracked by CMake build system.
- Use BUILD_DEBUG, BUILD_RELEASE and BUILD_DEVELOPMENT variables from Helpers library
- Avoid Include directories. Not needed anymore CMake `target_*` APIs handles this through `INTERFACE`, `PUBLIC` and `PRIVATE` scope identifiers
- `StatusQ` is meant to be compiled as an external library, therefore StatusQ tests are kept inside its own directory
- Forced CMake version to `3.21` for the latest features and fixes. It is desired to be kept as recent as possible due to its backward compatibility. Following Qt's shipped version might be an option
- Depends on status-go changes to allow forcing of arm for apple silicon

Found limitations to CMake Qt API with Qt 6.3

- Having `0` as major version when using `qt_add_qml_module` doesn't work. Qml engine reports loading the `qmldir` but won't load the plugin library and no error is reported outside that exposed types are not found.
- `qt_target_qml_sources` doesn't work now, it generate a double copy error when deploying qml files in bin-directory. For now we stick with adding files using `qt_add_qml_module` central place
  - Need to add `OUTPUT_DIRECTORY` to `qt_add_qml_module` to use the workaround
- If `MACOSX_BUNDLE` target property is set breaks importing of QML files. Disabled until fixed or workaround found
- For an unknown reason application executable tries to include the `QML_ELEMENT` include files, therefore for now I include all the C++ qml elements in INTERFACE
2022-06-30 12:16:33 +02:00
..
qml chore(CPP): Basic project configuration setup using Qt6 2022-06-30 12:16:33 +02:00
res chore(CPP): Basic project configuration setup using Qt6 2022-06-30 12:16:33 +02:00
src chore(CPP): Basic project configuration setup using Qt6 2022-06-30 12:16:33 +02:00
CMakeLists.txt chore(CPP): Basic project configuration setup using Qt6 2022-06-30 12:16:33 +02:00
README.md chore(CPP): Basic project configuration setup using Qt6 2022-06-30 12:16:33 +02:00

README.md

CPP App

Setup dependencies

1. conancenter

Execute conan remote list. It should return this line among the results:

conancenter: https://center.conan.io [Verify SSL: True]

If it doesn't, consider upgrading conan with pip install conan --upgrade and then executing. conan remote add -i 0 conancenter https://center.conan.io. See conan's documentation for more info.

2. conan libstdc++11

This applies to linux: the default conan profile does not work, since GCC uses the new C++ ABI since version 5.1 and conan, for compatibility purposes uses the old C++ ABI. Execute this to update the profile:

conan profile update settings.compiler.libcxx=libstdc++11 default

2. Install dependencies

conan install . --profile=<Platform specific conan profile> -s build_type=Release --build=missing -if=build/conan

Platform specific conan profile

  • Macos:
    • Intel: vendor/conan-configs/apple-arm64.ini
    • Apple silicon: vendor/conan-configs/apple-x86_64.ini
  • Windows: TODO
  • Linux: TODO

Buid, test & run

Platform specific Qt prefix path

  • Macos: $HOME/Qt/6.3.0/macos
  • Windows: TODO
  • Linux: TODO

Build with conan

CMAKE_PREFIX_PATH=<Qt prefix path> conan build . -if=build/conan -bf=build
ctest -VV -C Release
./status-desktop

Build with cmake

cmake -B build -S . -DCMAKE_PREFIX_PATH=<Qt prefix path> -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=build/conan/conan_toolchain.cmake
cmake --build build --config Release