What is the correct way to add dependencies on EXPORTED_TARGETS in the same package
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}
?
I had completely misunderstood your question, so I removed my answer.
I believe that should be
add_dependencies(my_prog ..)
, correct?Otherwise the question doesn't really make sense to me.