CMake with Qt3d for Qt5?
Asked Answered
A

1

6

I have installed Qt5 and Qt3d from the ubuntu-developers repository (I'm under Ubuntu 13.04) and I would like to compile a very simple application with CMake (my version is 2.8.10.1). A working CMakeLists.txt for a Qt helloworld is the following :

cmake_minimum_required(VERSION 2.8.8)

project(testproject)

# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)

# Find the QtWidgets library
find_package(Qt5Widgets)

# Tell CMake to create the helloworld executable
add_executable(helloworld helloworld.cpp)

# Use the Widgets module from Qt 5.
qt5_use_modules(helloworld Widgets)

But what would be the CMakeLists.txt of a basic Qt3d program like this example : https://gitorious.org/wiki-sources/wiki-sources/trees/master/qt3d/glview

Acidic answered 20/5, 2013 at 5:27 Comment(0)
H
6

Qt3d is a regular Qt module, just like Qt Widgets. So you should add Qt3d to your project just as you do it for Widgets:

cmake_minimum_required(VERSION 2.8.8)
project(testproject)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
find_package(Qt5Widgets)
find_package(Qt53D)
add_executable(helloworld teapotview.cpp main.cpp)
qt5_use_modules(helloworld Widgets 3D)

I've tested this CMakeLists.txt with Teapot example. It's available here. Note that the example you've posted was written for Qt4 and will not work with Qt5.

I've used Ubuntu 13.04 with qt3d5-dev package available in the main repository.

Halfwitted answered 25/5, 2013 at 8:52 Comment(3)
Qt53D seems to want profile suffixes, for example Qt53DCore instead of Qt53DSelfmastery
Im getting CMakeLists.txt:46: error: By not providing "FindQt53D.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Qt53D", but CMake did not find one. Could not find a package configuration file provided by "Qt53D" with any of the following names: Qt53DConfig.cmake qt53d-config.cmake Add the installation prefix of "Qt53D" to CMAKE_PREFIX_PATH or set "Qt53D_DIR" to a directory containing one of the above files. If "Qt53D" provides a separate development package or SDK, be sure it has been installed.Horvitz
find_package(Qt53D) fails for meHorvitz

© 2022 - 2024 — McMap. All rights reserved.