ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

Is there any way to get QT Creator to show all of a project’s subdirectories?

asked 2013-02-28 15:26:04 -0500

newToRos gravatar image

updated 2014-01-28 17:15:28 -0500

ngrennan gravatar image

I am using rosbuild/CMake for my QT application with QT Creator. My project directory is divided into src, includes, msg, ui, and resources folders and the only folders that show up in QT Creator are resources, src, and ui. Is there any way to get all of the folders to show up, or at least the includes folder to show up? Here is my CMakeLists.txt:

##############################################################################
# Rosbuild2
##############################################################################

if(ROSBUILD)
  include(rosbuild.cmake OPTIONAL)
  return()
endif()

##############################################################################
# CMake
##############################################################################

cmake_minimum_required(VERSION 2.4.6)

##############################################################################
# Ros Initialisation
##############################################################################

include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
rosbuild_init()

#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

rosbuild_genmsg()

# Set the build type.  Options are:
#  Coverage       : w/ debug symbols, w/o optimization, w/ code-coverage
#  Debug          : w/ debug symbols, w/o optimization
#  Release        : w/o debug symbols, w/ optimization
#  RelWithDebInfo : w/ debug symbols, w/ optimization
#  MinSizeRel     : w/o debug symbols, w/ optimization, stripped binaries
#set(ROS_BUILD_TYPE Debug)

##############################################################################
# Qt Environment
##############################################################################

rosbuild_include(qt_build qt-ros)
rosbuild_prepare_qt4(QtCore QtGui QtWebkit QtNetwork) # 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/Google_Maps_CMAKE/*.hpp)

QT4_ADD_RESOURCES(QT_RESOURCES_CPP ${QT_RESOURCES})
QT4_WRAP_UI(QT_FORMS_HPP ${QT_FORMS})
QT4_WRAP_CPP(QT_MOC_HPP ${QT_MOC})

##############################################################################
# Sources
##############################################################################

file(GLOB_RECURSE QT_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS src/*.cpp)

##############################################################################
# Binaries
##############################################################################

rosbuild_add_executable(Google_Maps_CMAKE ${QT_SOURCES} ${QT_RESOURCES_CPP} ${QT_FORMS_HPP} ${QT_MOC_HPP})
target_link_libraries(Google_Maps_CMAKE ${QT_LIBRARIES})
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
4

answered 2013-02-28 23:06:49 -0500

ddimarco gravatar image

updated 2013-03-01 03:30:59 -0500

To make the include files from the project show up in QtCreator, you can just add them as sources for your executable (in your example, add ${QT_MOC} to the rosbuild_add_executable line, or create a new GLOB collecting all the projects header files). This won't mess up the build process, I do that quite often.

However, I do not know whether there is a way to add system headers or other file types to the QtCreator project view.

edit flag offensive delete link more

Comments

So I would just add ${QT_MOC} to rosbuild_add_executable? What about the standard .h files that are not .hpp? That won't mess anything up with the build process?

newToRos gravatar image newToRos  ( 2013-03-01 03:06:52 -0500 )edit

Thank you so much. My main concern was getting my project headers to show up and this worked great.

newToRos gravatar image newToRos  ( 2013-03-01 04:23:12 -0500 )edit
1

answered 2016-05-05 13:36:09 -0500

updated 2016-06-04 08:24:47 -0500

If your concern are the header files I recommend you to use this simple pattern:

FILE(GLOB_RECURSE HEADER_FILES include *.h)

add_executable(executable_name mysourcefile.cpp ${HEADER_FILES} )

It is also possible to create a different target (this may be better) to avoid adding the new files to the executable target.

FILE(GLOB_RECURSE HeadFiles "include/*.h")

add_custom_target(headers SOURCES ${HeadFiles})

It is possible to do this with other files, like msg files, config files, launch files, etc.

The only issue here, is that you are introducing some code in CMake that has no too much sense and it is only useful for qtcreator (while the CMake philosophy is making the development independent to any IDE)

edit flag offensive delete link more

Comments

It works! Thank you!

pulver gravatar image pulver  ( 2016-05-26 12:56:03 -0500 )edit

positive vote?

Pablo Iñigo Blasco gravatar image Pablo Iñigo Blasco  ( 2016-05-28 03:03:56 -0500 )edit

Thank you, it works fine.

stefanoghidini gravatar image stefanoghidini  ( 2019-01-24 04:12:12 -0500 )edit

Question Tools

Stats

Asked: 2013-02-28 15:26:04 -0500

Seen: 14,764 times

Last updated: Jun 04 '16