来自这个主题: Ubuntu CMake添加到CMAKE_MODULE_PATH的路径
我尝试在我的项目中运行QT5,因为QT4不允许我包含QWebView.
按照上述主题的指南,我现在有一个CMakeList.txt:
cmake_minimum_required (VERSION 2.6 FATAL_ERROR)
project (simpleTree)
find_package(Qt5 REQUIRED COMPONENTS Widgets Core)
find_package (VTK REQUIRED)
find_package (PCL 1.8.0 REQUIRED)
include_directories (${PCL_INCLUDE_DIRS})
link_directories (${PCL_LIBRARY_DIRS})
add_definitions (${PCL_DEFINITIONS})
set (project_SOURCES export/exportply.cpp export/writecsv.cpp main.cpp
controller.cpp
gui/pclviewer.cpp
import/importpcd.cpp
method/SphereFollowing.cpp
Model/crown.cpp
Model/Cylinder.cpp
Model/Segment.cpp
Model/Tree.cpp)
set (project_HEADERS controller.h
export/writecsv.h
export/exportply.h
gui/pclviewer.h
import/importpcd.h
method/SphereFollowing.h
Model/crown.h
Model/Cylinder.h
Model/Segment.h
Model/Tree.h)
set (project_FORMS gui/pclviewer.ui)
set (VTK_LIBRARIES vtkRendering vtkGraphics vtkHybrid QVTK)
QT5_WRAP_CPP (project_HEADERS_MOC ${project_HEADERS})
QT5_WRAP_UI (project_FORMS_HEADERS ${project_FORMS})
INCLUDE (${QT_USE_FILE})
ADD_DEFINITIONS (${QT_DEFINITIONS})
ADD_EXECUTABLE (simpleTree ${project_SOURCES}
${project_FORMS_HEADERS}
${project_HEADERS_MOC})
TARGET_LINK_LIBRARIES (simpleTree ${QT_LIBRARIES} ${PCL_LIBRARIES} ${VTK_LIBRARIES})
Run Code Online (Sandbox Code Playgroud)
将QT4线切换到QT5后,出现以下错误:
CMake Error at CMakeLists.txt:36 (INCLUDE):
include called with wrong number of arguments. Include only takes one
file.
Run Code Online (Sandbox Code Playgroud)
所以这告诉我变量QT_USE_FILE现在是一个列表,它不是之前的.不确定这是否正确,不确定我能做什么.
谢谢Jan
CMake Error at CMakeLists.txt:36 (INCLUDE):
include called with wrong number of arguments. Include only takes one
file.
Run Code Online (Sandbox Code Playgroud)
这意味着变量QT_USE_FILE是空的.
在使用Qt5的CMake中,您应该使用宏qt5_use_modules而不是QT_USE_FILE和QT_LIBRARIES.
所以在CMakeLists.txt你的需要删除行:
INCLUDE (${QT_USE_FILE})
更改行:
TARGET_LINK_LIBRARIES (simpleTree ${QT_LIBRARIES} ${PCL_LIBRARIES} ${VTK_LIBRARIES})
在:
TARGET_LINK_LIBRARIES (simpleTree ${PCL_LIBRARIES} ${VTK_LIBRARIES})
和添加行:
qt5_use_modules (simpleTree Widgets)
UPD:
现在使用qt5_use_modules已弃用,target_link_libraries simpleTree Qt5::Widgets应该使用(请参阅此答案).
| 归档时间: |
|
| 查看次数: |
6147 次 |
| 最近记录: |