Closed sloretz closed 4 years ago
If I remember properly, this has something to do with either ament or colcon automatically doing this for you. Can you confirm whether this works if you make the plain CMake package an ament package, or building it with colcon (or both), makes it work?
Can you confirm whether this works if you make the plain CMake package an ament package, or building it with colcon (or both), makes it work?
I am building it with colcon
.
If I add a package.xml
then the build succeeds. Nothing else changed. It's still a plain CMake package and I'm building the same way using ROS Rolling deb packages.
<?xml version="1.0"?>
<package format="2">
<name>find_fastrtps_test</name>
<version>0.1.0</version>
<description>Debugging issues with FastRTPS CMake module.</description>
<maintainer email="sloretz@openrobotics.org">Shane Loretz</maintainer>
<license>Apache License 2.0</license>
<build_depend>rclcpp</build_depend>
<export>
<build_type>cmake</build_type>
</export>
</package>
If I add a
package.xml
then the build succeeds. Nothing else changed. It's still a plain CMake package and I'm building the same way using ROS Rolling deb packages.
Weird. I'm guessing that colcon is doing something differently there with regards to CMAKE_PREFIX_PATH when it finds a package.xml. But we are deep into speculation territory, so I'll stop guessing here.
Weird. I'm guessing that colcon is doing something differently there with regards to CMAKE_PREFIX_PATH when it finds a package.xml. But we are deep into speculation territory, so I'll stop guessing here.
Very weird. With and without the package.xml
all CMake variables are identical (edit: in the top-level CMakeLists.txt).
get_cmake_property(_variableNames VARIABLES)
list (SORT _variableNames)
foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
That didn't include the path variables in the CMAKE_PREFIX_PATH
documentation, but those are exactly the same too with and without a package.xml
.
message(STATUS "CMAKE_SYSTEM_PREFIX_PATH=${CMAKE_SYSTEM_PREFIX_PATH}")
message(STATUS "CMAKE_INCLUDE_PATH=${CMAKE_INCLUDE_PATH}")
message(STATUS "CMAKE_LIBRARY_PATH=${CMAKE_LIBRARY_PATH}")
message(STATUS "CMAKE_PROGRAM_PATH=${CMAKE_PROGRAM_PATH}")
message(STATUS "CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}")
message(STATUS "CMAKE_IGNORE_PATH=${CMAKE_IGNORE_PATH}")
-- CMAKE_SYSTEM_PREFIX_PATH=/usr/local;/usr;/;/usr;/home/sloretz/bigssd/drake_ros_demos/ws/install/find_fastrtps_test;/usr/X11R6;/usr/pkg;/opt
-- CMAKE_INCLUDE_PATH=
-- CMAKE_LIBRARY_PATH=
-- CMAKE_PROGRAM_PATH=
-- CMAKE_PREFIX_PATH=
-- CMAKE_IGNORE_PATH=
I'm not sure what's different here, might have to read the find_library()
docs for more clues.
Regardless, if the Find module can find_package()
the two projects, it should have enough info to find the libraries from them. Maybe the fastrtps-config.cmake
and fastcdr-config.cmake
are setting variables that can be put into HINTS
to the find_library()
calls?
:tada: made a wrapper script to catch how CMake is invoked. The (first) cmake command is exactly the same with and without a package.xml
/usr/bin/cmake /home/sloretz/bigssd/drake_ros_demos/ws/src/find_fastrtps_test -DCMAKE_INSTALL_PREFIX=/home/sloretz/bigssd/drake_ros_demos/ws/install/find_fastrtps_test
When I made the script echo environment variables it shows a single diff between two builds: CMAKE_PREFIX_PATH
is set to /opt/ros/rolling
. No idea why that only happens when this package has a package.xml
. No idea why echoing the CMake variable CMAKE_PREFIX_PATH
in CMake shows a blank value when the environment variable is set. No idea why colcon
(nor which colcon extension) would only set the environment variable when the package has a package.xml
.
declare -x CMAKE_PREFIX_PATH="/opt/ros/rolling"
I think I understand what's going on here. I think colcon-ros
identifies a ROS package because a package.xml
is present. Even though the build type is plain cmake
, the colcon-ros
CmakeBuildTask
modifies the environment with add_app_to_cpp
which appends AMENT_PREFIX_PATH
to CMAKE_PREFIX_PATH
.
There's a few things I think should be different.
fastcdr
and fastrtps
, then it should be able to find the libraries without CMAKE_PREFIX_PATH
being set. There's probably something that can be done with HINTS
to fix that. (that should be enough to close this ticket)package.xml
should be the same, except that colcon could use the package.xml
to make more packages available to a plain CMake package if they're listed in it's package.xml
. There shouldn't be any magic in having a package.xml
beyond listing a package's build type and dependencies.AMENT_PREFIX_PATH
should be appended to CMAKE_PREFIX_PATH
at all, regardless of build type. IIUC packages using ament_cmake
create setup scripts that can be sourced to set environment variables. ament_python
packages have a hook for setting PYTHONPATH
. There should be a similar hook for CMAKE_PREFIX_PATH
set by any ament_cmake
package. That is, sourcing /opt/ros/<distro>/setup.bash
should set CMAKE_PREFIX_PATH
. This would enable plain CMake packages to be built without using colcon
+package.xml
or manually setting CMAKE_PREFIX_PATH
/-DCMAKE_PREFIX_PATH
.@sloretz Do you think https://github.com/ros2/rosidl_typesupport_fastrtps/pull/56 would solve this issue? It was committed at the end of October, but we haven't done a release of that package into Rolling since.
Do you think #56 would solve this issue? It was committed at the end of October, but we haven't done a release of that package into Rolling since.
Gah. Yup that should fix it. https://github.com/ros2/ros2/issues/943 looks like exactly this issue.
Bug report
Required Info:
Steps to reproduce issue
Create a workspace with a plain CMake package
find_fastrtps_test
Build that package
Runing with
--trace-expand
shows FastRTPS and FastCDR are found, but thefind_library()
calls appear to have been unsuccessfulExpected behavior
I would expect the CMake module to successfully find FastRTPS.
Additional information
The libraries exist:
/opt/ros/rolling/setup.bash
is sourced, but noCMAKE_PREFIX_PATH
variable is set. I thought it would have been set to/opt/ros/rolling
.