Ask Your Question
0

qt moc header in different packages

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

Wolf gravatar image

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

In a typical project is set in CMakeLists.txt

catkin_package(
  INCLUDE_DIRS include
  LIBRARIES ${PROJECT_NAME}
)

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
1

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

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

Comments

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 -0500 )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

Stats

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

Seen: 396 times

Last updated: Aug 15 '14