CMake with Qt3d for Qt5?

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

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 will be the CMakeLists.txt of the Qt3d base program, like this example: https://gitorious.org/wiki-sources/wiki-sources/trees/master/qt3d/glview

+6
source share
1 answer

Qt3d is a regular Qt module, like Qt Widgets. Therefore, you should add Qt3d to your project in the same way as you do 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 tested this CMakeLists.txt with an example of a teapot. It is available here . Please note that the example you posted was written for Qt4 and will not work with Qt5.

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

+6
source

Source: https://habr.com/ru/post/945395/


All Articles