Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cmake and QT5 - Include only takes one argument

Tags:

c++

cmake

qt

coming from this topic: Ubuntu CMake what path to add to CMAKE_MODULE_PATH

I try to get QT5 in my project running, as QT4 does not allow me to include QWebView.

Following the guides from the mentioned topics I now have a 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})

I get the following error, after switching QT4 lines to QT5:

CMake Error at CMakeLists.txt:36 (INCLUDE):
include called with wrong number of arguments.  Include only takes one
file.

So this tells me that the variable QT_USE_FILE is now a list, which it was not before. Not sure if this is right, and not sure what I can do.

Thanks Jan

like image 940
BuddhaWithBigBelly Avatar asked Jan 31 '15 14:01

BuddhaWithBigBelly


1 Answers

CMake Error at CMakeLists.txt:36 (INCLUDE):
include called with wrong number of arguments.  Include only takes one
file.

It means that variable QT_USE_FILE is empty.

In CMake with Qt5 you should use macro qt5_use_modules instead of QT_USE_FILE and QT_LIBRARIES.

So in your CMakeLists.txt you need to remove line:
INCLUDE (${QT_USE_FILE})
change line:
TARGET_LINK_LIBRARIES (simpleTree ${QT_LIBRARIES} ${PCL_LIBRARIES} ${VTK_LIBRARIES})
on the:
TARGET_LINK_LIBRARIES (simpleTree ${PCL_LIBRARIES} ${VTK_LIBRARIES})
and add line:
qt5_use_modules (simpleTree Widgets)

UPD:
For now using qt5_use_modules is deprecated and target_link_libraries simpleTree Qt5::Widgets should be used instead (see also this answer).

like image 187
Gluttton Avatar answered Oct 03 '22 00:10

Gluttton