ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

qt moc header in different packages

asked 2014-08-15 10:24:07 -0600

Wolf gravatar image

updated 2014-08-15 10:24:48 -0600

In a typical project is set in CMakeLists.txt

  INCLUDE_DIRS include

if i create a lib and have headers in the include folders that depending packages require....

Now I have an rqt package, where I want to use a custom widget I create in this package in several sub packages. Is there any way to do that? Because now I cannot just add the include folder to INCLUDE_DIRS because the headers lying there might need to be moc'ed... I cannot directly compile against them...

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-08-15 17:08:55 -0600

ahendrix gravatar image

From what I've seen, the existing C++ libraries in ROS that expose QT widgets don't do anything special to expose the MOC'd files that are generated from headers.

Between reading the qt_gui_cpp CMakeLists.txt and some MOC documentation it looks like MOC creates C++ implementation files only (My interpretation of the documentation is that MOC does not generate header files). These generated C++ files are then compiled into a library within the source project. Downstream projects then include the original headers and link against the compiled library.

In your case, you'd want to make sure that the ${PROJECT_NAME} library contains both your source and the MOC-generated files.

edit flag offensive delete link more


Thank you very much, exposing widgets works as you suggested.... Addition: Some pkgs expose ${CMAKE_CURRENT_BINARY_DIR} in catkin_package INCLUDE_DIRS; This might be necessary, however, I could not test if necessary because both of my packages add it to include_directories anyway...

Wolf gravatar image Wolf  ( 2014-08-18 02:32:35 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-08-15 10:24:07 -0600

Seen: 496 times

Last updated: Aug 15 '14