skip to Main Content

I am trying to get Qt6 working on my Raspberry Pi 4 B 2GB. It’s running Ubuntu 22.04. I installed all necessary packages with qt6-base-dev and any dependent packages (build-essential, cmake and so on)

But I can’t get QT to work with it. I keep getting the error Unknown CMake command "qt_standard_project_setup"

My CMakeLists.txt looks like this:

cmake_minimum_required(VERSION 3.22)

project(test LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

find_package(Qt6 REQUIRED COMPONENTS Widgets Core) 
qt_standard_project_setup()

add_executable(test 
    main.cpp
    mainwindow.cpp
    mainwindow.h
    mainwindow.ui
)

target_link_libraries(test PRIVATE
    Qt6::Widgets
)

I also passed the Qt install path via -DCMAKE_PREFIX_PATH=...but it doesn’t work.

It doesn’t seem like it fails to find the QT6 package, it seems to just not recognize the qt_standard_project_setup() itself, which seems weird to me. Why is this happening?

2

Answers


  1. Chosen as BEST ANSWER

    Just something I learned in the meantime: It seems to me, that generally there are three ways to install QT on my Ubuntu system:

    • Use the unified installer from the QT website (doesn't work on arm64)
    • Use debian packages (whatever version it is)
    • Build QT yourself with CMake

    I came to understand that the last option is the best, since it is also platform agnostic and you get to decide exaxtly which version you get and also which components you want, similar to the unified installer. Also, it will install QT to the standard install directory for any C++ library, so you won't have to set any special environment variables or edit CMAKE_PREFIX_PATH for CMake to find it. I definitely prefer the third option now.


  2. As mentioned in the comments, at the time of this writing, Ubuntu 22.04 only has Qt 6.2.4. See https://launchpad.net/ubuntu/+source/qt6-base/6.2.4+dfsg-2ubuntu1 and https://packages.ubuntu.com/jammy/qt6-base-dev.

    And as stated in the docs for qt_standard_project_setup, that command was introduced in Qt 6.3. If you don’t mind, you can just do things the old way manually without the convenience of qt_standard_project_setup.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search