ament / ament_index

Apache License 2.0
13 stars 27 forks source link

Colcon build failed if a package set the requirement of ament_index_cpp #86

Closed tomcattiger1230 closed 2 years ago

tomcattiger1230 commented 2 years ago

-- Found ament_index_cpp: 1.4.0 (/Users/xxx/Develop/ros2/ros2_humble/install/share/ament_index_cpp/cmake) CMake Error at /Users/xxx/Develop/ros2/ros2_humble/install/share/ament_index_cpp/cmake/ament_cmake_export_targets-extras.cmake:18 (message): Failed to find exported target names in '/Users/xxx/Develop/ros2/ros2_humble/install/share/ament_index_cpp/cmake/export_ament_index_cppExport.cmake' Call Stack (most recent call first): /Users/xxx/Develop/ros2/ros2_humble/install/share/ament_index_cpp/cmake/ament_index_cppConfig.cmake:41 (include) CMakeLists.txt:14 (find_package)

ooeygui commented 2 years ago

(Microsoft) I'm working on this. I'm staging a fix in https://github.com/ms-iot/ament_index/tree/humble, and will PR when I can verify it. This repros when compiling resource_retriever.

tomcattiger1230 commented 2 years ago

@ooeygui Thanks for this information. Correct. I've got the first error with resource_retriever. I've tried to skip this package, then I've noticed that almost every package with ament_index_cpp got the same error.

ooeygui commented 2 years ago

@tomcattiger1230 Thanks for confirming. I'm root causing it.

ooeygui commented 2 years ago

The CMake which ships with Visual Studio is later. Cmake recently changed _expectedTarget to _cmake_expected_target.

In C:\opt\ros\humble\x64\share\ament_index_cpp\cmake\ament_cmake_export_targets-extras.cmake There's a block of code which looks for foreach and _expectedTarget:

    # extract the target names associated with the export
    set(_regex "foreach\\(_expectedTarget (.+)\\)")

However, the cmake files themselves reference _cmake_expected_target:

foreach(_cmake_expected_target IN ITEMS ament_index_cpp::ament_index_cpp)
  list(APPEND _cmake_expected_targets "${_cmake_expected_target}")
  if(TARGET "${_cmake_expected_target}")
    list(APPEND _cmake_targets_defined "${_cmake_expected_target}")
  else()
    list(APPEND _cmake_targets_not_defined "${_cmake_expected_target}")
  endif()
endforeach()

And here's the change: https://github.com/Kitware/CMake/commit/59cc92085ea7c5a81de7d79946fa97f045adea78

tomcattiger1230 commented 2 years ago

is there any suggestion to correct this? Thanks.

ooeygui commented 2 years ago

There is a fix in progress - https://github.com/ament/ament_cmake/pull/395

clalancette commented 2 years ago

Actually, I'm going to close this one anyway since this is a duplicate of https://github.com/ament/ament_cmake/issues/396