0
$\begingroup$

Rosanswers logo

Hi all,

I'm using and like QtCreator to code and build my ROS projects written in c++.

Unfortunately the auto-completion for my own header files is not working: e.g. #include "LineTracker.hh"

Building the project works perfectly. And also the auto-completion for other external packages like ros or opencv is working.

Thats how my CMakeLists.txt looks:

cmake_minimum_required(VERSION 2.8.3)
project(line_tracking)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

find_package(catkin REQUIRED COMPONENTS
  roscpp
  tf
  sensor_msgs
  image_transport
  cv_bridge
)

catkin_package()

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
  ${PROJECT_SOURCE_DIR}
)

add_executable(${PROJECT_NAME}
    src/line_tracking.cpp
    src/EDLineDetector.cpp
    src/LineTracker.cpp
)

target_link_libraries(${PROJECT_NAME}
  ${catkin_LIBRARIES}
)

# --- QT CREATOR STUFF ---

#Add all files in subdirectories of the project in
# a dummy_target so qtcreator has access to all files
FILE(GLOB children ${CMAKE_SOURCE_DIR}/*)
FOREACH(child ${children})
  IF(IS_DIRECTORY ${child})
    file(GLOB_RECURSE dir_files "${child}/*")
    LIST(APPEND extra_files ${dir_files})
  ENDIF()
ENDFOREACH()
add_custom_target(dummy_${PROJECT_NAME} SOURCES ${extra_files})
#

The file/package structure looks standard like this:

CMakeLists.txt
 |
 + -- src
 |
 + -- include

How do I have to adapt my CMakeLists.txt that QtCreator finds my headers for auto-completion?

Thank you very much for your help!

Sidenote:

When I use the top CMakeLists.txt file of the catkin workspace in QtCeator and I include the header files under their package path like this: #include <packageName/include/headerFile.h> the auto-completion is working but the build is not working anymore. So this is only a bad and not userfriendly hack to get auto-completion during coding.


Originally posted by jonas- on ROS Answers with karma: 1 on 2016-01-18

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

I had this same issue for a while. In my quest to solve it, I found two possibly related bug reports from QtCreator: 13746 and 15026.

Following the comments of 13746, I found that using QtCreator version 3.2.2 solved the issue; however, 3.2.2 did not do as well with auto completion for pointers as newer versions of QtCreator, so in the end, I found a different IDE.

If it is an option, updating CMake is probably the best way forward, as noted in 15026. Updating CMake standalone is not straightforward, though, and I haven't verified this approach myself.


Originally posted by pdbot with karma: 16 on 2017-01-19

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.