6

我已经从 ubuntu-developers 存储库(我在 Ubuntu 13.04 下)安装了 Qt5 和 Qt3d,我想用 CMake 编译一个非常简单的应用程序(我的版本是 2.8.10.1)。Qt helloworld 的工作 CMakeLists.txt 如下:

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)

但是像这个例子这样的基本 Qt3d 程序的 CMakeLists.txt 是什么: https ://gitorious.org/wiki-sources/wiki-sources/trees/master/qt3d/glview

4

1 回答 1

6

Qt3d 是一个常规的 Qt 模块,就像 Qt Widgets 一样。因此,您应该将 Qt3d 添加到您的项目中,就像为小部件添加一样:

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)

我已经用 Teapot 示例测试了这个 CMakeLists.txt。它在这里可用。请注意,您发布的示例是为 Qt4 编写的,不适用于 Qt5。

我已经使用了 Ubuntu 13.04 和qt3d5-dev主存储库中可用的包。

于 2013-05-25T08:52:05.683 回答