Skip to content

CMAKE_PREFIX_PATH broken if package does not export build type ament_cmake #165

Description

@StefanFabian

I've encountered some build issues where my package used headers from the underlay instead of from my source workspace, and traced it back to colcon-ros.
The issue is happening in this function where the AMENT_PREFIX_PATH is added to the CMAKE_PREFIX_PATH.

def add_app_to_cpp(env):
"""
Add AMENT_PREFIX_PATH to CMAKE_PREFIX_PATH.
Each ament prefix path is inserted before the first catkin prefix path or
at the end if none of the CMake prefix paths has a '.catkin' marker file.

The problem is that if you forget to include <export><build_type>ament_cmake</build_type></export> in the package XML of a package.
The build will add a .catkin marker file to the install location.
This causes the linked function to insert the AMENT_PREFIX_PATH with the underlying binary workspace in front of this source package, which may be very early in the list of source packages.
Subsequently, when building, it will now prioritize the underlay over the source workspace, which I don't think is intended behavior.

I don't really understand what the rationale was behind adding AMENT_PREFIX_PATH before the first .catkin marked directory, or why a .catkin marker file is placed when the build_type is not properly exported.
So, I can't propose a solution, but the combination creates some very hard-to-find weird behavior.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions