From 87ac01bd72c7b35217ab9ebf69cba69dc7780b39 Mon Sep 17 00:00:00 2001
From: Steve Peters <scpeters@openrobotics.org>
Date: Fri, 15 Sep 2023 10:11:58 -0700
Subject: [PATCH] Fix build with graphviz 9 (#3345)
Signed-off-by: Steve Peters <scpeters@openrobotics.org>
---
cmake/SearchForStuff.cmake | 3 +++
gazebo/gui/CMakeLists.txt | 5 +++++
gazebo/gui/qgv/private/QGVCore.h | 3 +++
3 files changed, 11 insertions(+)
diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake
index 4f5859781d..732cbb4e2d 100644
--- a/cmake/SearchForStuff.cmake
+++ b/cmake/SearchForStuff.cmake
@@ -781,6 +781,9 @@ if (NOT GRAPHVIZ_FOUND)
else ()
message (STATUS "Looking for libgraphviz-dev - found")
set (HAVE_GRAPHVIZ ON CACHE BOOL "HAVE GRAPHVIZ" FORCE)
+ if (${GRAPHVIZ_CGRAPH_PKG_VERSION} VERSION_LESS 9.0)
+ set(GRAPHVIZ_VERSION_LT_9 TRUE)
+ endif ()
endif ()
########################################
diff --git a/gazebo/gui/CMakeLists.txt b/gazebo/gui/CMakeLists.txt
index d9a3326455..313595726b 100644
--- a/gazebo/gui/CMakeLists.txt
+++ b/gazebo/gui/CMakeLists.txt
@@ -206,6 +206,11 @@ add_dependencies(gzclient gazebo_gui)
target_compile_definitions(gazebo_gui
PRIVATE BUILDING_DLL_GZ_GUI
)
+if (GRAPHVIZ_VERSION_LT_9)
+ target_compile_definitions(gazebo_gui
+ PRIVATE GRAPHVIZ_VERSION_LT_9
+ )
+endif()
target_link_libraries(gazebo_gui
libgazebo_client
diff --git a/gazebo/gui/qgv/private/QGVCore.h b/gazebo/gui/qgv/private/QGVCore.h
index 48ec1a10df..1bf3a8e846 100644
--- a/gazebo/gui/qgv/private/QGVCore.h
+++ b/gazebo/gui/qgv/private/QGVCore.h
@@ -102,7 +102,10 @@ class QGVCore
rdr.len = strlen(cp);
rdr.cur = 0;
+#ifdef GRAPHVIZ_VERSION_LT_9
+ // This variable only exists for versions before Graphviz 9.0
disc.mem = &AgMemDisc;
+#endif
disc.id = &AgIdDisc;
disc.io = &memIoDisc;
g = agread(&rdr, &disc);