From fb4734e07812ec6aa9019723675b7756a8f803c5 Mon Sep 17 00:00:00 2001 From: Rhys Mainwaring Date: Mon, 18 Dec 2023 15:03:18 +0000 Subject: [PATCH] Tools: support Gazebo Harmonic and Garden Signed-off-by: Rhys Mainwaring --- ardupilot_gz_gazebo/CMakeLists.txt | 21 +++++++++++++++++++-- ardupilot_gz_gazebo/package.xml | 11 +++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/ardupilot_gz_gazebo/CMakeLists.txt b/ardupilot_gz_gazebo/CMakeLists.txt index 7b420dd..a11bde0 100644 --- a/ardupilot_gz_gazebo/CMakeLists.txt +++ b/ardupilot_gz_gazebo/CMakeLists.txt @@ -5,7 +5,11 @@ project(ardupilot_gz_gazebo) # Find dependencies. find_package(ament_cmake REQUIRED) +# --------------------------------------------------------------------------- # +# Find gz-sim and dependencies. + find_package(gz-cmake3 REQUIRED) +set(GZ_CMAKE_VER ${gz-cmake3_VERSION_MAJOR}) find_package(gz-plugin2 REQUIRED COMPONENTS register) set(GZ_PLUGIN_VER ${gz-plugin2_VERSION_MAJOR}) @@ -13,8 +17,21 @@ set(GZ_PLUGIN_VER ${gz-plugin2_VERSION_MAJOR}) find_package(gz-common5 REQUIRED COMPONENTS profiler) set(GZ_COMMON_VER ${gz-common5_VERSION_MAJOR}) -find_package(gz-sim7 REQUIRED) -set(GZ_SIM_VER ${gz-sim7_VERSION_MAJOR}) +# Garden (default) +if("$ENV{GZ_VERSION}" STREQUAL "garden" OR NOT DEFINED "ENV{GZ_VERSION}") + gz_find_package(gz-sim7 REQUIRED) + set(GZ_SIM_VER ${gz-sim7_VERSION_MAJOR}) + + message(STATUS "Compiling against Gazebo Garden") +# Harmonic +elseif("$ENV{GZ_VERSION}" STREQUAL "harmonic") + gz_find_package(gz-sim8 REQUIRED) + set(GZ_SIM_VER ${gz-sim8_VERSION_MAJOR}) + + message(STATUS "Compiling against Gazebo Harmonic") +else() + message(FATAL_ERROR "Unsupported GZ_VERSION: $ENV{GZ_VERSION}") +endif() # --------------------------------------------------------------------------- # # Build. diff --git a/ardupilot_gz_gazebo/package.xml b/ardupilot_gz_gazebo/package.xml index 0905b95..d2eacb3 100644 --- a/ardupilot_gz_gazebo/package.xml +++ b/ardupilot_gz_gazebo/package.xml @@ -7,6 +7,17 @@ Rhys Mainwaring GPL-3.0 ament_cmake + + gz-common5 + gz-cmake3 + gz-plugin2 + + + gz-sim7 + gz-sim7 + + gz-sim8 + ament_lint_auto