Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set the project find qt59's modules? #26

Open
sunyuzhe2017 opened this issue May 18, 2018 · 2 comments
Open

How to set the project find qt59's modules? #26

sunyuzhe2017 opened this issue May 18, 2018 · 2 comments

Comments

@sunyuzhe2017
Copy link

sunyuzhe2017 commented May 18, 2018

Ubuntu 16.04,ros kinetic,I installed qt59 at /opt/qt59
I created a project with 'catkin_create_qt_pkg'command ,then the CMakeLists file is build with QT4,which from "/usr/include/qt4",I change the CMakeLists file to qt5,like follow sentences:

cmake_minimum_required(VERSION 2.8.0)
project(test1)
set(CMAKE_INCLUDE_CURRENT_DIR ON)#added necessary
##############################################################################
# Catkin
##############################################################################

# qt_build provides the qt cmake glue, roscpp the comms for a default talker
find_package(catkin REQUIRED COMPONENTS roscpp)
find_package(Qt5 REQUIRED Core Widgets)#added
set(QT_LIBRARIES Qt5::Widgets)#added
include_directories(${catkin_INCLUDE_DIRS})

# Use this to define what the package will export (e.g. libs, headers).
# Since the default here is to produce only a binary, we don't worry about
# exporting anything. 
catkin_package()
##############################################################################
# Qt Environment
##############################################################################
# this comes from qt_build's qt-ros.cmake which is automatically 
# included via the dependency call in package.xml
#rosbuild_prepare_qt4(QtCore QtGui) # Add the appropriate components to the component list here
##############################################################################
# Sections
##############################################################################
file(GLOB QT_FORMS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ui/*.ui)
file(GLOB QT_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} resources/*.qrc)
file(GLOB_RECURSE QT_MOC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS include/test1/*.hpp)

QT5_ADD_RESOURCES(QT_RESOURCES_CPP ${QT_RESOURCES})
QT5_WRAP_UI(QT_FORMS_HPP ${QT_FORMS})
QT5_WRAP_CPP(QT_MOC_HPP ${QT_MOC}) 

then I find that the Qt modules path changed to "/usr/lib/x86_64-linux-gnu/qt5",still it wasn't from qt59 (/opt/qt59),how could I change the CMakeLists file to make cmake find qt modules from /opt/qt59?
I have searched for several days ,tried like change set(CMAKE_PREFIX_PATH /opt/qt59)and so on,but all that doesn't work,so I 'm here looking for help from you.
I do appreciate if you could give me some advices about how to change the CMakeLists file to make it find Qt modules from the set path "/opt/qt59".

@stonier
Copy link
Owner

stonier commented May 18, 2018

You'll need to dig deeper into /opt/qt59 to find the path to the cmake modules, not the root of qt5. e.g. I have /usr/lib/x86_64-linux-gnu/cmake/Qt5/Qt5Config.cmake on my system, so probably setting CMAKE_PREFIX_PATH to /usr/lib/x86_64-linux-gnu/cmake/ or /usr/lib/x86_64-linux-gnu/cmake/Qt5 would work.

@sunyuzhe2017
Copy link
Author

I'm sorry for reply you so late,I have tried ,it still doesn't work.I think I need to rebuild qt59 in my computer,or it can not find the qt59's cmake file.Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants