Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find_package not working correctly #33

Closed
hellantos opened this issue Apr 28, 2022 · 1 comment
Closed

find_package not working correctly #33

hellantos opened this issue Apr 28, 2022 · 1 comment

Comments

@hellantos
Copy link

hellantos commented Apr 28, 2022

Bug report

When including yaml_cpp_vendor as Package dependency with ament_cmake package.

Required Info:

Operating System: Ubuntu 20.04
Installation type: binaries
Version or commit hash: galactic & foxy latest dockers
Client library (if applicable): rclcpp

Steps to reproduce:
In header file include yaml-cpp/yaml.h

#ifndef CONFIGURATION_MANAGER_HPP
#define CONFIGURATION_MANAGER_HPP

#include <string>
#include <iostream>
#include <map>
#include <vector>
#include <optional>
#include "yaml-cpp/yaml.h"

In CMakeLists.txt find_package and add as target dependency.

find_package(yaml_cpp_vendor REQUIRED)
find_package(std_msgs REQUIRED)
find_package(std_srvs REQUIRED)
find_package(rclcpp_lifecycle REQUIRED)
find_package(lifecycle_msgs REQUIRED)

find_package(lely_core_libraries REQUIRED)
find_package(canopen_interfaces REQUIRED)

[...]

add_library(configuration_manager
  src/configuration_manager.cpp
)
target_compile_features(configuration_manager  PUBLIC c_std_99 cxx_std_17)  # Require C99 and C++17
target_include_directories(configuration_manager PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>
  )
ament_target_dependencies(configuration_manager 
  rclcpp
  yaml_cpp_vendor
)

Resulting compiler error:

--- stderr: canopen_core
  In file included from /root/target_ws/src/ros2_canopen/canopen_core/include/canopen_core/device.hpp:27,
                   from /root/target_ws/src/ros2_canopen/canopen_core/include/canopen_core/master_node.hpp:23,
                   from /root/target_ws/src/ros2_canopen/canopen_core/src/master_node.cpp:1:
  /root/target_ws/src/ros2_canopen/canopen_core/include/canopen_core/configuration_manager.hpp:24:10: fatal error: yaml-cpp/yaml.h: No such file or directory
     24 | #include "yaml-cpp/yaml.h"
        |          ^~~~~~~~~~~~~~~~~
  compilation terminated.
  make[2]: *** [CMakeFiles/master_node.dir/build.make:63: CMakeFiles/master_node.dir/src/master_node.cpp.o] Error 1
  make[1]: *** [CMakeFiles/Makefile2:192: CMakeFiles/master_node.dir/all] Error 2
  make[1]: *** Waiting for unfinished jobs....
  /root/target_ws/src/ros2_canopen/canopen_core/src/lely_master_bridge.cpp: In member function ‘std::future<bool> ros2_canopen::LelyMasterBridge::async_write_nmt(uint8_t, uint8_t)’:
  /root/target_ws/src/ros2_canopen/canopen_core/src/lely_master_bridge.cpp:224:5: warning: no return statement in function returning non-void [-Wreturn-type]
    224 |     }
        |     ^
  make: *** [Makefile:141: all] Error 2

See ros-industrial/ros2_canopen#18 and related github actions ouput on foxy and galactic dockers for more details.
Interestingly, this behaviour does not occur on all systems. We have manually installed systems where it does not occur.

The workaround to the problem is manually adding yaml_cpp_vendor_INCLUDE_DIRS to include_dirs().

Expected behavior
yaml_cpp_vendor package behaves as every other package and can be added as dependency without additional efforts.

Actual behavior
When using find_package on yaml_cpp_vendor and adding it with ament_target_dependencies, yaml-vendor/yaml.h is not found.


Could this be realted to #16 maybe? As this is not consistent throughout every manually installed system we have.

@hellantos
Copy link
Author

Problem was within CMakeLists.txt not this package. Sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant