Unknown CMake command "qt_standard_project_setup" on Raspberry Pi
Asked Answered
D

1

11

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?

Darn answered 3/3, 2023 at 7:39 Comment(3)
You need to specify the core component doc.qt.io/qt-6/qt-standard-project-setup.html and make sure you're using qt 6.3 or newerMande
@AlanBirtles I just did that, but it still doesn't work. Updated my questionDarn
Looks like Ubuntu 22.04 only comes with qt 6.2 launchpad.net/ubuntu/+source/qt6-base/6.2.4+dfsg-2ubuntu1Mande
A
13

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.

Alrzc answered 3/3, 2023 at 8:6 Comment(1)
Thanks. I installed QT with the unified installer on my regular PC, but since the pi has arm64 architecture you can't use that. Installing it via apt was the next best thing and I just assumed it would have the newest version. When I replace qt_standard_project_setup() with set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) it works fineDarn

© 2022 - 2024 — McMap. All rights reserved.