2013-05-20 91 views
7

我已經從ubuntu-developers存儲庫(我在Ubuntu 13.04下)安裝了Qt5和Qt3d,並且我想用CMake編譯一個非常簡單的應用程序(我的版本是2.8.10.1)。一個工作的CMakeLists.txt爲一個Qt的HelloWorld如下:CMake與Qt3d Qt5?

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

回答

7

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) 

我測試過這個的CMakeLists.txt與茶壺的例子。它可用here。請注意,您發佈的示例是爲Qt4編寫的,不適用於Qt5。

我已經在主存儲庫中使用了Ubuntu 13.04和qt3d5-dev包。

+0

'Qt53D'似乎想要配置文件後綴,例如'Qt53DCore'而不是'Qt53D' – Smar