From 855eebca0b754a0be65cbdc52d47a7995d01d0d4 Mon Sep 17 00:00:00 2001
From: Lukas Bulwahn <lukas.bulwahn@oss.bmw-carit.de>
Date: Fri, 30 Sep 2016 16:02:02 +0200
Subject: [PATCH] image-pipeline: patch twice to compile with gcc6 (#392)

---
 .../files/0001-address-gcc6-build-error.patch | 138 ++++++++++++++++++
 ...to-std-vector-double-to-make-gcc6-ha.patch |  57 ++++++++
 recipes-ros/image-pipeline/image-pipeline.inc |   3 +
 3 files changed, 198 insertions(+)
 create mode 100644 recipes-ros/image-pipeline/files/0001-address-gcc6-build-error.patch
 create mode 100644 recipes-ros/image-pipeline/files/0002-explicitly-cast-to-std-vector-double-to-make-gcc6-ha.patch

diff --git a/recipes-ros/image-pipeline/files/0001-address-gcc6-build-error.patch b/recipes-ros/image-pipeline/files/0001-address-gcc6-build-error.patch
new file mode 100644
index 0000000..05e6812
--- /dev/null
+++ b/recipes-ros/image-pipeline/files/0001-address-gcc6-build-error.patch
@@ -0,0 +1,138 @@
+From 6c2d65452bd5fe62723988a1a570789921900d59 Mon Sep 17 00:00:00 2001
+From: Lukas Bulwahn <lukas.bulwahn@oss.bmw-carit.de>
+Date: Fri, 30 Sep 2016 15:39:47 +0200
+Subject: [PATCH 1/2] address gcc6 build error
+
+With gcc6, compiling fails with `stdlib.h: No such file or directory`,
+as including '-isystem /usr/include' breaks with gcc6, cf.,
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70129.
+
+This commit addresses this issue for this package in the same way
+it was addressed in various other ROS packages. A list of related
+commits and pull requests is at:
+
+  https://github.com/ros/rosdistro/issues/12783
+
+Signed-off-by: Lukas Bulwahn <lukas.bulwahn@oss.bmw-carit.de>
+
+Upstream-Status: Accepted [https://github.com/ros-perception/image_pipeline/commit/6c2d65452bd5fe62723988a1a570789921900d59]
+
+This patch has been generated with:
+  `git format-patch -2 562332df73781c1e56ce9123542334cc1d91b143`
+in the image_pipeline repository.
+
+Signed-off-by: Lukas Bulwahn <lukas.bulwahn@oss.bmw-carit.de>
+---
+ depth_image_proc/CMakeLists.txt  | 6 +-----
+ image_proc/CMakeLists.txt        | 3 +--
+ image_publisher/CMakeLists.txt   | 3 +--
+ image_rotate/CMakeLists.txt      | 5 +----
+ image_view/CMakeLists.txt        | 8 ++++----
+ stereo_image_proc/CMakeLists.txt | 4 +---
+ 6 files changed, 9 insertions(+), 20 deletions(-)
+
+diff --git a/depth_image_proc/CMakeLists.txt b/depth_image_proc/CMakeLists.txt
+index 0a7c7e2..6ceebfe 100644
+--- a/depth_image_proc/CMakeLists.txt
++++ b/depth_image_proc/CMakeLists.txt
+@@ -10,11 +10,7 @@ catkin_package(
+ find_package(Boost REQUIRED)
+ find_package(Eigen REQUIRED)
+ find_package(OpenCV REQUIRED)
+-include_directories(include
+-        SYSTEM ${BOOST_INCLUDE_DIRS}
+-               ${catkin_INCLUDE_DIRS}
+-               ${EIGEN_INCLUDE_DIRS}
+-)
++include_directories(include ${BOOST_INCLUDE_DIRS} ${catkin_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS})
+ 
+ add_library(${PROJECT_NAME} src/nodelets/convert_metric.cpp
+                              src/nodelets/crop_foremost.cpp
+diff --git a/image_proc/CMakeLists.txt b/image_proc/CMakeLists.txt
+index a13371f..34905f0 100755
+--- a/image_proc/CMakeLists.txt
++++ b/image_proc/CMakeLists.txt
+@@ -17,8 +17,7 @@ catkin_package(
+   LIBRARIES ${PROJECT_NAME}
+ )
+ 
+-include_directories(SYSTEM ${catkin_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})
+-include_directories(include)
++include_directories(include ${catkin_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})
+ 
+ # Nodelet library
+ add_library(${PROJECT_NAME} src/libimage_proc/processor.cpp
+diff --git a/image_publisher/CMakeLists.txt b/image_publisher/CMakeLists.txt
+index 8015a45..431109c 100644
+--- a/image_publisher/CMakeLists.txt
++++ b/image_publisher/CMakeLists.txt
+@@ -8,8 +8,7 @@ generate_dynamic_reconfigure_options(cfg/ImagePublisher.cfg)
+ 
+ catkin_package()
+ 
+-# add the executable
+-include_directories(SYSTEM ${catkin_INCLUDE_DIRS})
++include_directories(${catkin_INCLUDE_DIRS})
+ 
+ add_library(${PROJECT_NAME} SHARED src/nodelet/image_publisher_nodelet.cpp)
+ target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES})
+diff --git a/image_rotate/CMakeLists.txt b/image_rotate/CMakeLists.txt
+index 04ba03b..75d8e77 100644
+--- a/image_rotate/CMakeLists.txt
++++ b/image_rotate/CMakeLists.txt
+@@ -12,10 +12,7 @@ find_package(OpenCV REQUIRED core imgproc)
+ find_package(Eigen REQUIRED)
+ 
+ # add the executable
+-include_directories(SYSTEM ${catkin_INCLUDE_DIRS}
+-                           ${EIGEN_INCLUDE_DIRS}
+-                           ${OpenCV_INCLUDE_DIRS}
+-)
++include_directories(${catkin_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})
+ 
+ add_library(${PROJECT_NAME} SHARED src/nodelet/image_rotate_nodelet.cpp)
+ target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})
+diff --git a/image_view/CMakeLists.txt b/image_view/CMakeLists.txt
+index 78b9eaa..93fabe7 100644
+--- a/image_view/CMakeLists.txt
++++ b/image_view/CMakeLists.txt
+@@ -8,9 +8,9 @@ catkin_package(CATKIN_DEPENDS dynamic_reconfigure)
+ find_package(Boost REQUIRED COMPONENTS signals thread)
+ find_package(OpenCV REQUIRED)
+ 
+-include_directories(SYSTEM ${Boost_INCLUDE_DIRS}
+-                           ${catkin_INCLUDE_DIRS}
+-                           ${OpenCV_INCLUDE_DIRS}
++include_directories(${Boost_INCLUDE_DIRS}
++                    ${catkin_INCLUDE_DIRS}
++                    ${OpenCV_INCLUDE_DIRS}
+ )
+ 
+ # Extra tools
+@@ -40,7 +40,7 @@ endif()
+ 
+ find_package(GTK2)
+ add_definitions(-DHAVE_GTK)
+-include_directories(SYSTEM ${GTK2_INCLUDE_DIRS})
++include_directories(${GTK2_INCLUDE_DIRS})
+ 
+ # Nodelet library
+ add_library(image_view src/nodelets/image_nodelet.cpp src/nodelets/disparity_nodelet.cpp src/nodelets/window_thread.cpp)
+diff --git a/stereo_image_proc/CMakeLists.txt b/stereo_image_proc/CMakeLists.txt
+index b7127d2..e201436 100644
+--- a/stereo_image_proc/CMakeLists.txt
++++ b/stereo_image_proc/CMakeLists.txt
+@@ -16,9 +16,7 @@ catkin_package(
+ include_directories(include)
+ 
+ find_package(OpenCV REQUIRED)
+-include_directories(SYSTEM ${catkin_INCLUDE_DIRS}
+-                           ${OpenCV_INCLUDE_DIRS}
+-)
++include_directories(${catkin_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})
+ 
+ # Nodelet library
+ add_library(${PROJECT_NAME} src/libstereo_image_proc/processor.cpp src/nodelets/disparity.cpp src/nodelets/point_cloud2.cpp)
+-- 
+2.5.5
+
diff --git a/recipes-ros/image-pipeline/files/0002-explicitly-cast-to-std-vector-double-to-make-gcc6-ha.patch b/recipes-ros/image-pipeline/files/0002-explicitly-cast-to-std-vector-double-to-make-gcc6-ha.patch
new file mode 100644
index 0000000..e897cb9
--- /dev/null
+++ b/recipes-ros/image-pipeline/files/0002-explicitly-cast-to-std-vector-double-to-make-gcc6-ha.patch
@@ -0,0 +1,57 @@
+From 562332df73781c1e56ce9123542334cc1d91b143 Mon Sep 17 00:00:00 2001
+From: Lukas Bulwahn <lukas.bulwahn@oss.bmw-carit.de>
+Date: Thu, 6 Oct 2016 08:55:27 +0200
+Subject: [PATCH 2/2] explicitly cast to std::vector<double> to make gcc6 happy
+
+With gcc6, compiling image_publisher fails with this error:
+```
+/[...]/image_publisher/src/nodelet/image_publisher_nodelet.cpp: In member function 'virtual void image_publisher::ImagePublisherNodelet::onInit()':
+/[...]/image_publisher/src/nodelet/image_publisher_nodelet.cpp:180:43: error: ambiguous overload for 'operator=' (operand types are 'sensor_msgs::CameraInfo_<std::allocator<void> >::_D_type {aka std::vector<double>}' and 'boost::assign_detail::generic_list<int>')
+     camera_info_.D = list_of(0)(0)(0)(0)(0);
+```
+
+After adding an initial explicit type cast for the assignment,
+compiling fails further with:
+```
+| /[...]/image_publisher/src/nodelet/image_publisher_nodelet.cpp: In member function 'virtual void image_publisher::ImagePublisherNodelet::onInit()':
+| /[...]/image_publisher/src/nodelet/image_publisher_nodelet.cpp:180:65: error: call of overloaded 'vector(boost::assign_detail::generic_list<int>&)' is ambiguous
+|      camera_info_.D = std::vector<double> (list_of(0)(0)(0)(0)(0));
+```
+
+Various sources on the internet [1, 2, 3] point to use the
+`convert_to_container` method; hence, this commit follows those
+suggestions and with that image_publisher compiles with gcc6.
+
+[1] http://stackoverflow.com/questions/16211410/ambiguity-when-using-boostassignlist-of-to-construct-a-stdvector
+[2] http://stackoverflow.com/questions/12352692/ambiguous-call-with-list-of-in-vs2010/12362548#12362548
+[3] http://stackoverflow.com/questions/13285272/using-boostassignlist-of?rq=1
+
+Signed-off-by: Lukas Bulwahn <lukas.bulwahn@oss.bmw-carit.de>
+
+Upstream-Status: Accepted [https://github.com/ros-perception/image_pipeline/commit/562332df73781c1e56ce9123542334cc1d91b143]
+
+This patch has been generated with:
+  `git format-patch -2 562332df73781c1e56ce9123542334cc1d91b143`
+in the image_pipeline repository.
+
+Signed-off-by: Lukas Bulwahn <lukas.bulwahn@oss.bmw-carit.de>
+---
+ image_publisher/src/nodelet/image_publisher_nodelet.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/image_publisher/src/nodelet/image_publisher_nodelet.cpp b/image_publisher/src/nodelet/image_publisher_nodelet.cpp
+index 4102d0d..26e1352 100644
+--- a/image_publisher/src/nodelet/image_publisher_nodelet.cpp
++++ b/image_publisher/src/nodelet/image_publisher_nodelet.cpp
+@@ -177,7 +177,7 @@ public:
+     camera_info_.width = image_.cols;
+     camera_info_.height = image_.rows;
+     camera_info_.distortion_model = "plumb_bob";
+-    camera_info_.D = list_of(0)(0)(0)(0)(0);
++    camera_info_.D = list_of(0)(0)(0)(0)(0).convert_to_container<std::vector<double> >();
+     camera_info_.K = list_of(1)(0)(camera_info_.width/2)(0)(1)(camera_info_.height/2)(0)(0)(1);
+     camera_info_.R = list_of(1)(0)(0)(0)(1)(0)(0)(0)(1);
+     camera_info_.P = list_of(1)(0)(camera_info_.width/2)(0)(0)(1)(camera_info_.height/2)(0)(0)(0)(1)(0);
+-- 
+2.5.5
+
diff --git a/recipes-ros/image-pipeline/image-pipeline.inc b/recipes-ros/image-pipeline/image-pipeline.inc
index 36a418b..e3466db 100644
--- a/recipes-ros/image-pipeline/image-pipeline.inc
+++ b/recipes-ros/image-pipeline/image-pipeline.inc
@@ -2,6 +2,9 @@ SRC_URI = "https://github.com/ros-perception/${ROS_SPN}/archive/${PV}.tar.gz;dow
 SRC_URI[md5sum] = "d727bc9da9f7772649ab7c5c7c9f652e"
 SRC_URI[sha256sum] = "fc3073428fc930523efd6ed4a86d838ab0f0ff04a312eb4188c72a854d300e97"
 
+SRC_URI += "file://0001-address-gcc6-build-error.patch;patchdir=.."
+SRC_URI += "file://0002-explicitly-cast-to-std-vector-double-to-make-gcc6-ha.patch;patchdir=.."
+
 S = "${WORKDIR}/${ROS_SP}/${ROS_BPN}"
 
 inherit catkin
-- 
GitLab