Can we change the order of package compilation in catkin_make command?
$ catkin_make
compiles all the ros packages available inside the catkin_ws
.
so, do we have any provision to change the order of the packages to be compiled.
with example:
catkin_ws:
/package_1
/package_2
/package_3: dependent on package_1 and package_2
if I want to compile all packages with
$ catkin_make
, I don't have control over which package should compile 1st. I want it to be compiled as above order.
So , do we have any provision for reordering the compilation of packages with catkin_make
. or should I go with .sh
file having individual compilation command?
Asked by rama_bhuyan on 2018-09-11 07:30:07 UTC
Answers
catkin_make
builds all packages in a workspace within the same CMake context. So there is no "order" between packages.
To make sure your packages still compile correctly with catkin_make
you have to make sure to also specify cross-package target dependencies (e.g. using the "EXPORTED_TARGETS" mentioned in the docs).
If you actually want to build the packages in separate CMake invocations (which will avoid the need for cross-package target dependencies) you can use either of the following build tools: catkin_make_isolated
(recommended for ROS 1), catkin_tools
(not recommended but very powerful and used by many people already), colcon
(developed for ROS 2 and should work for ROS 1 too, very young so not as robust as the other ones yet).
Asked by Dirk Thomas on 2018-09-11 10:45:04 UTC
Comments
Well, this should be done automatically when you specify the dependencies in your
CMakeLists.txt
correctly...Asked by mgruhler on 2018-09-11 08:03:16 UTC
I second @mgruhler the correct method is to specify the package dependencies in your CMakeLists file then catkin_make will automatically build things in the right order.
Asked by PeteBlackerThe3rd on 2018-09-11 08:21:38 UTC
@mgruhler , would you please explaion what changes I need to make in the CMakeLists.txt of /package_3 . I have done: package_3/CMakeLists.txt/ find_package( package_1,package_2)
what else things need to be added ?
Asked by rama_bhuyan on 2018-09-11 23:34:32 UTC
see the answer by @Dirk Thomas and the link to the docs therein. Basically, for every target (which is found in the calls
add_library(TARGET ..)
andadd_executable(TARGET ..)
) you need the respectiveadd_dependencies(TARGET ${catkin_EXPORTED_TARGETS})
calls.Asked by mgruhler on 2018-09-12 00:58:44 UTC
I have done all necessary changes but still I could not arrange the projects. after $catkin_make , the packages are arranged as /package_3 then /package_2, /package_1. @mgruhler
Asked by rama_bhuyan on 2018-09-14 00:10:26 UTC
the error I am getting is: Could not find configuration file provided by "/package_1" with any of the following name package_1Config.cmake package_1-Config.cmake
Asked by rama_bhuyan on 2018-09-14 00:12:49 UTC
You might want to share the exact content of your packages otherwise there is too much guessing involved.
Asked by Dirk Thomas on 2018-09-14 00:26:21 UTC