Best practices for ExternalProject #97
Replies: 9 comments 3 replies
-
I'm not the maintainer here, nor is this an answer, but do you really need to wrap your library in a Catkin package? If you're just trying to use If you're looking to be able to build it as part of a Catkin workspace, it would not be needed (as you could just place a minimal If you're attempting to release Edit: and this is highly opinionated, but:
Both |
Beta Was this translation helpful? Give feedback.
-
I totally aggree with you that including amqpcpp as system package would be the better solution. However, creating and maintaining a release repository seems to require some amount of extra maintenance effort. Just throwing a package.xml into the project does not work for catkin_make. Also, integrating own modifications (using a forked version for development purposes) does not seem to be possible while I could always change the URL in the CMakeLists.txt. |
Beta Was this translation helpful? Give feedback.
-
more than what you're doing now? It's a trade-off, but a third-party release is essentially a one-time configuration job, followed by periodic rebasing of your manifest + any potential patches you want to include + running That's not really that much work, and seems comparable to what you'd be doing with the wrapper you're creating now.
No, as it does not support mixed-build-tool builds. You'd use
I'm not sure I understand this. I've not checked whether boilerplate cmake buildtool manifest<?xml version="1.0"?>
<package format="2">
<name>amqpcpp</name>
<version>0.1.0</version>
<description>Something</description>
<maintainer email="someone@someone.somewhere">Someone</maintainer>
<author>Someone</author>
<license>Apache 2.0</license>
<buildtool_depend>cmake</buildtool_depend>
<export>
<build_type>cmake</build_type>
</export>
</package> builds ls -al devel/ outputroot@machine:/catkin_ws# ll devel/lib/
total 2288
drwxr-xr-x 3 root root 4096 Feb 22 16:55 ./
drwxr-xr-x 8 root root 4096 Feb 22 16:55 ../
lrwxrwxrwx 1 root root 17 Feb 22 16:55 libamqpcpp.so -> libamqpcpp.so.4.3
-rw-r--r-- 1 root root 2328792 Feb 22 16:55 libamqpcpp.so.4.3
drwxr-xr-x 2 root root 4096 Feb 22 16:55 pkgconfig/
root@machine:/catkin_ws# ll devel/include/
total 16
drwxr-xr-x 3 root root 4096 Feb 22 16:55 ./
drwxr-xr-x 8 root root 4096 Feb 22 16:55 ../
drwxr-xr-x 3 root root 4096 Feb 22 16:55 amqpcpp/
-rw-r--r-- 1 root root 2201 Feb 22 16:51 amqpcpp.h Could be that the location of I haven't checked the vanilla Edit 2: anyway, I'll mark this as off-topic, as that's what it is. I just wanted to make you aware of options other than wrapping your library in a Catkin package. |
Beta Was this translation helpful? Give feedback.
-
I don't think there's much to add on my part. @gavanderhoorn pretty much laid out the most sensible options and I don't think there's enough of a use case for me to add support for |
Beta Was this translation helpful? Give feedback.
-
Once the package is released into the ROS ecosystem, people might depend on it even when my current project does not use this library any more. So releasing something with bloom comes with a responsibility to maintain the package, I think.
Yes. I do see the rationale for using these, but for deveopment I prefer catkin_make due to the faster build times.
There are situations in which I need a modified version of a package (for example when working on a PR) while testing my ROS workspace. In such situations, I just put the source package into the workspace and it gets built by catkin automatically.
Yes, this can be turned into a discussion. Sorry for opening an issue for this! |
Beta Was this translation helpful? Give feedback.
-
final comment:
I don't really understand how having a Google Cartographer for instance is setup and distributed in exactly the same way, and has almost infinite forks which can all be built from source in a Catkin workspace. Perhaps unclear, but adding a manifest does not equal 3rd party release. It's perfectly possible to have a manifest in an unreleased package. |
Beta Was this translation helpful? Give feedback.
-
No need to be sorry. It's a legitimate question to ask, and I hope the answers have been helpful for you. |
Beta Was this translation helpful? Give feedback.
-
Okay, I played around with forking the upstream repository and adding a package.xml. Building with colcon kind of works (catkin_make_isolated and catkin_tools do not generate a single compile_commands.json for my IDE, colcon does) up to a certain point. Contrary to my previous assumptions, this is something I can live with. (Thank you for your help so far.) Now I need to set some CMake options (enable TCP support and shared libraries). Besides adding EDIT: Made myself a small script to automatically add package.xml and patch CMakeLists.txt: #!/bin/sh
set -e
TYPE_TO_UPDATE=$1
TARGET_TO_UPDATE=$2
usage() {
echo "Usage: $0 [branch|tag] <target>" >&2
echo "Examples:" >&2
echo " $0 branch master" >&2
echo " $0 tag v4.3.11" >&2
exit 1
}
# Basic validation
if [ -z "${TYPE_TO_UPDATE}" ] || [ -z "${TARGET_TO_UPDATE}" ]; then
usage
fi
# Configure upstream remote if not exists
if ! git config remote.upstream.url > /dev/null; then
git remote add --no-tags upstream https://github.com/CopernicaMarketingSoftware/AMQP-CPP.git
fi
# Configure how to fetch branches or tags
if [ "${TYPE_TO_UPDATE}" = "branch" ]; then
git config --replace-all remote.upstream.fetch "+refs/heads/*:refs/remotes/upstream/*"
elif [ "${TYPE_TO_UPDATE}" = "tag" ]; then
git config --replace-all remote.upstream.fetch "+refs/tags/*:refs/tags/upstream/*"
else
usage
fi
# Fetch the thing to update
git fetch upstream ${TARGET_TO_UPDATE}
# Checkout thing to update
if [ "${TYPE_TO_UPDATE}" = "branch" ]; then
# And create new branch (overwriting existing)
git checkout -B ros-patched/${TARGET_TO_UPDATE} upstream/${TARGET_TO_UPDATE}
elif [ "${TYPE_TO_UPDATE}" = "tag" ]; then
git checkout upstream/${TARGET_TO_UPDATE}
fi
# Create package.xml with git data
cat > package.xml << PACKAGE_XML_END
<?xml version="1.0"?>
<package format="2">
<name>amqpcpp</name>
<version>$(git describe --tags | cut -d/ -f2)</version>
<description>
AMQP-CPP is a C++ library for communicating with a RabbitMQ message broker. The library can be used to parse
incoming data from a RabbitMQ server, and to generate frames that can be sent to a RabbitMQ server.
</description>
<maintainer email="$(git config user.email)">$(git config user.name)</maintainer>
<license>Apache-2.0</license>
<buildtool_depend>cmake</buildtool_depend>
<depend>libssl-dev</depend>
<exec_depend>catkin</exec_depend>
<export>
<build_type>cmake</build_type>
</export>
</package>
PACKAGE_XML_END
# Enable shared libraries and TCP support
sed -i 's/^option(\(AMQP-CPP_BUILD_SHARED ".*"\) OFF)$/option(\1 ON)/g' CMakeLists.txt
sed -i 's/^option(\(AMQP-CPP_LINUX_TCP ".*"\) OFF)$/option(\1 ON)/g' CMakeLists.txt
# Append install for package.xml
cat >> CMakeLists.txt << CMAKELISTS_TXT_END
# Install ROS package.xml
install(FILES package.xml DESTINATION share)
CMAKELISTS_TXT_END
# Create commit with our new package.xml
git add package.xml CMakeLists.txt
git commit -m "Add package.xml and enable shared libraries and TCP"
# Create tag if we are updating a tag
if [ "${TYPE_TO_UPDATE}" = "tag" ]; then
git tag -f ros-patched/${TARGET_TO_UPDATE}
fi
# Inform user how to continue
if [ "${TYPE_TO_UPDATE}" = "branch" ]; then
echo "Finished. Please review commit/branch and push using:"
echo "git push --set-upstream origin ros-patched/${TARGET_TO_UPDATE}"
elif [ "${TYPE_TO_UPDATE}" = "tag" ]; then
echo "Finished. Please review commit/tag and push using:"
echo "git push origin ros-patched/${TARGET_TO_UPDATE}"
fi |
Beta Was this translation helpful? Give feedback.
-
Although this is a fairly old discussion it is still very relevant. What if several different ROS packages in the workspace depend on the same external package via the described just-add-package.xml-method? Wouldn't the packages collide? |
Beta Was this translation helpful? Give feedback.
-
Hello folks.
Currently I'm trying to integrate an external C++ library into my ROS workspace using ExternalProject. I cannot use FetchContent which is not available on Kinetic and Melodic.
While it is possible to perform this task working for both devel and install destinations, catkin_lint has a lot to complain about:
Especially the lines
and
bother me because they clearly circumvent checks performed by catkin_lint.
Even with these workarounds, I get warnings about installing files from the devel space (because that's where the external project is installed to). I think most issues boil down to doing things in the devel space and exporting references to the devel space.
So can I somehow use ExternalProject with catkin and still satisfy catkin_lint?
Beta Was this translation helpful? Give feedback.
All reactions