What is the correct way to add dependencies on EXPORTED_TARGETS in the same package

asked 2018-01-21 05:04:51 -0500

MatthijsBurgh gravatar image

updated 2018-01-21 06:28:04 -0500

When I have a package, which generates msgs and depends on these in the package itself. I have the following lines in my CMakeLists.txt:

add_library(my_lib src/a.cpp)
target_link_libraries(my_lib${catkin_LIBRARIES})
add_dependencies(my_lib ${${PROJECT_NAME}_EXPORTED_TARGETS})

add_executable(my_prog src/exec.cpp)
target_link_libraries(my_prog my_lib)

Would it than be necessary to add to following line? So does the dependency need to be added to executable too?

add_dependencies(my_prog ${${PROJECT_NAME}_EXPORTED_TARGETS})

First question: I don't think it is needed, because these dependencies are inherited from linking to my_lib. Am I correct?

Second question: Does this apply the same way to messages from other packages, so when using ${catkin_EXPORTED_TARGETS} instead of ${${PROJECT_NAME}_EXPORTED_TARGETS}?

edit retag flag offensive close merge delete

Comments

I had completely misunderstood your question, so I removed my answer.

gvdhoorn gravatar image gvdhoorn  ( 2018-01-21 06:15:34 -0500 )edit

Would it than be necessary to add to following line?

add_dependencies(my_lib ..)

I believe that should be add_dependencies(my_prog ..), correct?

Otherwise the question doesn't really make sense to me.

gvdhoorn gravatar image gvdhoorn  ( 2018-01-21 06:16:27 -0500 )edit