ros-perception / laser_geometry

Provides the LaserProjection class for turning laser scan data into point clouds.
BSD 3-Clause "New" or "Revised" License
156 stars 113 forks source link

[ros2] use target_include_directories #53

Open Karsten1987 opened 4 years ago

Karsten1987 commented 4 years ago

when building ros2 eloquent as a merge on OSX, I ran into conflicts with gtest. The main problem comes from using a global include_directories in the CMakeLists.txt. This should be addressed with target_include_directories as well as ament_target_dependencies.

I'll open a PR for it soonish.

 ➭ colcon_build --merge --packages-select laser_geometry
Starting >>> laser_geometry
--- stderr: laser_geometry
In file included from /Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/src/gtest-all.cc:41:
In file included from /Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/./src/gtest.cc:135:
/Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/./src/gtest-internal-inl.h:171:19: error: use of undeclared identifier 'FLAGS_gtest_print_utf8'; did you mean 'FLAGS_gtest_print_time'?
    print_utf8_ = GTEST_FLAG(print_utf8);
                  ^~~~~~~~~~~~~~~~~~~~~~
                  FLAGS_gtest_print_time
/usr/local/include/gtest/internal/gtest-port.h:2504:27: note: expanded from macro 'GTEST_FLAG'
# define GTEST_FLAG(name) FLAGS_gtest_##name
                          ^
<scratch space>:181:1: note: expanded from here
FLAGS_gtest_print_utf8
^
/usr/local/include/gtest/gtest.h:116:1: note: 'FLAGS_gtest_print_time' declared here
GTEST_DECLARE_bool_(print_time);
^
/usr/local/include/gtest/internal/gtest-port.h:2515:59: note: expanded from macro 'GTEST_DECLARE_bool_'
# define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name)
                                                          ^
/usr/local/include/gtest/internal/gtest-port.h:2504:27: note: expanded from macro 'GTEST_FLAG'
# define GTEST_FLAG(name) FLAGS_gtest_##name
                          ^
<scratch space>:251:1: note: expanded from here
FLAGS_gtest_print_time
^
In file included from /Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/src/gtest-all.cc:41:
In file included from /Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/./src/gtest.cc:135:
/Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/./src/gtest-internal-inl.h:193:5: error: use of undeclared identifier 'FLAGS_gtest_print_utf8'; did you mean 'FLAGS_gtest_print_time'?
    GTEST_FLAG(print_utf8) = print_utf8_;
    ^~~~~~~~~~~~~~~~~~~~~~
    FLAGS_gtest_print_time
/usr/local/include/gtest/internal/gtest-port.h:2504:27: note: expanded from macro 'GTEST_FLAG'
# define GTEST_FLAG(name) FLAGS_gtest_##name
                          ^
<scratch space>:199:1: note: expanded from here
FLAGS_gtest_print_utf8
^
/usr/local/include/gtest/gtest.h:116:1: note: 'FLAGS_gtest_print_time' declared here
GTEST_DECLARE_bool_(print_time);
^
/usr/local/include/gtest/internal/gtest-port.h:2515:59: note: expanded from macro 'GTEST_DECLARE_bool_'
# define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name)
                                                          ^
/usr/local/include/gtest/internal/gtest-port.h:2504:27: note: expanded from macro 'GTEST_FLAG'
# define GTEST_FLAG(name) FLAGS_gtest_##name
                          ^
<scratch space>:251:1: note: expanded from here
FLAGS_gtest_print_time
^
In file included from /Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/src/gtest-all.cc:41:
/Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/./src/gtest.cc:276:17: error: no member named 'OutputFlagAlsoCheckEnvVar' in namespace 'testing::internal'
      internal::OutputFlagAlsoCheckEnvVar().c_str()),
      ~~~~~~~~~~^
/usr/local/include/gtest/internal/gtest-port.h:2527:50: note: expanded from macro 'GTEST_DEFINE_string_'
    GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val)
                                                 ^~~~~~~~~~~
In file included from /Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/src/gtest-all.cc:41:
/Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/./src/gtest.cc:429:28: error: functions that differ only in their return type cannot be overloaded
::std::vector<std::string> GetArgvs() {
~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
/usr/local/include/gtest/internal/gtest-port.h:1431:60: note: previous declaration is here
GTEST_API_ const ::std::vector<testing::internal::string>& GetArgvs();
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
In file included from /Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/src/gtest-all.cc:41:
/Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/./src/gtest.cc:798:54: error: no member named 'skipped_test_count' in 'testing::TestCase'
  return SumOverTestCaseList(test_cases_, &TestCase::skipped_test_count);
                                           ~~~~~~~~~~^
/Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/./src/gtest.cc:2206:17: error: no member named 'skipped' in 'testing::TestPartResult'
  return result.skipped();
         ~~~~~~ ^
/Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/./src/gtest.cc:2210:18: error: out-of-line definition of 'Skipped' does not match any declaration in 'testing::TestResult'
bool TestResult::Skipped() const {
                 ^~~~~~~
/Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/./src/gtest.cc:2484:20: error: unknown type name 'AssertionException'
    } catch (const AssertionException&) {  // NOLINT
                   ^
/Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/./src/gtest.cc:2520:30: error: use of undeclared identifier 'IsSkipped'
  if (!HasFatalFailure() && !IsSkipped()) {
                             ^
/Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/./src/gtest.cc:2546:12: error: out-of-line definition of 'IsSkipped' does not match any declaration in 'testing::Test'
bool Test::IsSkipped() {
           ^~~~~~~~~
/Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/./src/gtest.cc:2700:42: error: call to non-static member function without an object argument
  if (!Test::HasFatalFailure() && !Test::IsSkipped()) {
                                   ~~~~~~^~~~~~~~~
/Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/./src/gtest.cc:2729:15: error: out-of-line definition of 'skipped_test_count' does not match any declaration in 'testing::TestCase'; did you mean 'failed_test_count'?
int TestCase::skipped_test_count() const {
              ^~~~~~~~~~~~~~~~~~
              failed_test_count
/usr/local/include/gtest/gtest.h:817:7: note: 'failed_test_count' declared here
  int failed_test_count() const;
      ^
In file included from /Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/src/gtest-all.cc:41:
/Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/./src/gtest.cc:2730:35: error: use of undeclared identifier 'TestSkipped'; did you mean 'TestFailed'?
  return CountIf(test_info_list_, TestSkipped);
                                  ^~~~~~~~~~~
                                  TestFailed
/usr/local/include/gtest/gtest.h:899:15: note: 'TestFailed' declared here
  static bool TestFailed(const TestInfo* test_info) {
              ^
In file included from /Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/src/gtest-all.cc:41:
/Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/./src/gtest.cc:2883:26: error: no member named 'kSkip' in 'testing::TestPartResult'
    case TestPartResult::kSkip:
         ~~~~~~~~~~~~~~~~^
/Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/./src/gtest.cc:2980:37: error: unknown type name 'GTestColor'
static const char* GetAnsiColorCode(GTestColor color) {
                                    ^
/Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/./src/gtest.cc:3033:20: error: unknown type name 'GTestColor'
void ColoredPrintf(GTestColor color, const char* fmt, ...) {
                   ^
/Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/./src/gtest.cc:3043:53: error: use of undeclared identifier 'COLOR_DEFAULT'
  const bool use_color = in_color_mode && (color != COLOR_DEFAULT);
                                                    ^
/Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/./src/gtest.cc:3144:19: error: use of undeclared identifier 'COLOR_YELLOW'
    ColoredPrintf(COLOR_YELLOW,
                  ^
/Users/karsten/workspace/ros2/ros2_eloquent/install/src/gtest_vendor/./src/gtest.cc:3150:19: error: use of undeclared identifier 'COLOR_YELLOW'
    ColoredPrintf(COLOR_YELLOW,
                  ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [gtest/CMakeFiles/gtest.dir/src/gtest-all.cc.o] Error 1
make[1]: *** [gtest/CMakeFiles/gtest.dir/all] Error 2
make: *** [all] Error 2
---
Failed   <<< laser_geometry [ Exited with code 2 ]

Summary: 0 packages finished [3.57s]
  1 package failed: laser_geometry
  1 package had stderr output: laser_geometry
✘  11:38:55 ~/workspace/ros2/ros2_eloquent
 ➭ colcon_build --merge --packages-select laser_geometry
Starting >>> laser_geometry
--- stderr: laser_geometry
/Users/karsten/workspace/ros2/ros2_eloquent/src/ros-perception/laser_geometry/src/laser_geometry.cpp:31:10: fatal error: 'laser_geometry/laser_geometry.hpp' file not found
#include "laser_geometry/laser_geometry.hpp"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/laser_geometry.dir/src/laser_geometry.cpp.o] Error 1
make[1]: *** [CMakeFiles/laser_geometry.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [all] Error 2
---
Failed   <<< laser_geometry [ Exited with code 2 ]

Summary: 0 packages finished [5.66s]
  1 package failed: laser_geometry
  1 package had stderr output: laser_geometry