AprilRobotics / apriltag

AprilTag is a visual fiducial system popular for robotics research.
https://april.eecs.umich.edu/software/apriltag
Other
1.47k stars 522 forks source link

Improve CMakeLists config path by using CMAKE_CURRENT_BINARY_DIR #319

Closed EwingKang closed 4 months ago

EwingKang commented 4 months ago

Change CMAKE_BINARY_DIR to CMAKE_CURRENT_BINARY_DIR during configuration. This is useful when the project is a subdirectory/ submodule another project (e.g. apriltags_ros).

christian-rauch commented 4 months ago

Specifically for ROS packages, you should rely on the binary packages or build the library as part of your workspace. But this seems useful nevertheless for projects that do not rely on colcon etc.

EwingKang commented 3 months ago

@christian-rauch Thanks for the merge. I'm sorry that I'm not sure what do you mean by "as part of your workspace". I encountered the problem when building apriltags_ros project. The apriltags_ros's CMake include this project as a cmake subdirectory. It looks something like this:

apriltags_ros
├── apriltag_ros           # the project that needs apriltag
│   ├── CMakeLists.txt
├── apriltag                  # this project
│   ├── CMakeLists.txt

So when building using colcon it tries to search the files from apriltags_ros_build/ instead of apriltags_ros_build/apriltag/ (this is only an illustration, not the actual path). So that is the motive of changing the prefixes. Since it only uses CMake commands, that led me to believe that it is not related to ROS. Maybe I'm not understanding this correctly, I'll be happy to answer any further questions. Thanks again for the review.

christian-rauch commented 3 months ago

In this particular case, apriltag_ros manually checks out the library in its own source tree. But the correct way to depend on a ROS / colcon package is to specify the dependency in the package.xml and use the ROS ecosystem to resolve dependencies in the same way as all other dependencies (rclcpp, cv_bridge, image_transport, ...) are resolved.