How to trigger cpack with catkin? Run custom build target?
Is there a way to trigger a custom build target for a specific catkin package?
I have a catkin package that builds a release ZIP using cpack.
CMakeLists.txt:
...
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib)
install(...)
set(CPACK_GENERATOR "ZIP")
include(CPack)
If this were a normal cmake project I could trigger this step using make package
or cmake --build . --target package
, however we're using catkin. The only way I've found to run cpack using catkin is by using
catkin build mypackage
catkin build mypackage --no-deps --make-args package
The second, separate step is necessary because --make-args package
would otherwise cause catkin to try to run make package
for every package, which will of course fail because that target is usually not defined.
This works fine if my catkin workspace is extending the standard ROS workspace (/opt/ros/melodic). However, if I use a workspace that does not extend any other result space and manually add the catkin and cmake_modules sources to my workspace it won't work because the 'catkin' package will always be built:
$ catkin build mypackage --no-deps --make-args package
---------------------------------------------
Profile: default
Extending: [cached] /tmp/foo/devel
Workspace: /tmp/foo
---------------------------------------------
Build Space: [exists] /tmp/foo/build
Devel Space: [exists] /tmp/foo/devel
Install Space: [exists] /tmp/foo/install
Log Space: [exists] /tmp/foo/logs
Source Space: [exists] /tmp/foo/src
DESTDIR: [unused] None
---------------------------------------------
Devel Space Layout: linked
Install Space Layout: merged
---------------------------------------------
Additional CMake Args: None
Additional Make Args: package
Additional catkin Make Args: None
Internal Make Job Server: True
Cache Job Environments: False
---------------------------------------------
Whitelisted Packages: None
Blacklisted Packages: None
---------------------------------------------
Workspace configuration appears valid.
NOTE: Forcing CMake to run for each package.
---------------------------------------------
[build] Found '38' packages in 0.0 seconds.
Starting >>> catkin
Starting >>> mypackage
_____________________________________________________________
Errors << catkin:make /tmp/foo/logs/catkin/build.make.002.log
make: *** No rule to make target 'package'. Stop.
cd /tmp/foo/build/catkin; catkin build --get-env catkin | catkin env -si /usr/bin/make package --jobserver-fds=6,7 -j; cd -
.......................................................................................
Failed << catkin:make [ Exited with code 2 ]
Failed <<< catkin [ 0.8 seconds ]
Finished <<< mypackage [ 0.9 seconds ]
[build] Summary: 1 of 2 packages succeeded.
[build] Ignored: 36 packages were skipped or are blacklisted.
[build] Warnings: None.
[build] Abandoned: None.
[build] Failed: 1 packages failed.
[build] Runtime: 1.0 seconds total.
Mypackage still gets built and cpack runs successfully, so the only issue I have is that catkin fails to build the 'catkin' package and complains. Not a big issue, just inconvenient for a continuous integration setup...
I'm posting this here also because I haven't found much about the combination of cpack and catkin.
Asked by iliis on 2020-08-18 10:00:22 UTC
Answers
One solution is to manually execute make:
cd /tmp/foo/build/mypackage
catkin build --get-env mypackage | catkin env -si /usr/bin/make -j package
This is fine for CI but not all that convenient to do manually. Ideally the package target would be built automatically whenever you compile the catkin package.
Asked by iliis on 2020-08-18 10:15:03 UTC
Comments