From aa819ff8d31852e46c09a864bd56ead19e4249fa Mon Sep 17 00:00:00 2001 From: Rhys Mainwaring Date: Sun, 17 Dec 2023 09:30:24 +0000 Subject: [PATCH] Gazebo: improve handling of default GZ_VERSION - Remove duplicate code and report error for invalid GZ_VERSION. Signed-off-by: Rhys Mainwaring --- CMakeLists.txt | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d8ff8dde..11f6181c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,8 +26,8 @@ if("$ENV{GZ_VERSION}" STREQUAL "harmonic") set(GZ_SIM_VER ${gz-sim8_VERSION_MAJOR}) message(STATUS "Compiling against Gazebo Harmonic") -# Garden -elseif("$ENV{GZ_VERSION}" STREQUAL "garden") +# Garden (default) +elseif("$ENV{GZ_VERSION}" STREQUAL "garden" OR NOT DEFINED "ENV{GZ_VERSION}") find_package(gz-cmake3 REQUIRED) set(GZ_CMAKE_VER ${gz-cmake3_VERSION_MAJOR}) @@ -35,15 +35,8 @@ elseif("$ENV{GZ_VERSION}" STREQUAL "garden") set(GZ_SIM_VER ${gz-sim7_VERSION_MAJOR}) message(STATUS "Compiling against Gazebo Garden") -# Default to Garden -else() - find_package(gz-cmake3 REQUIRED) - set(GZ_CMAKE_VER ${gz-cmake3_VERSION_MAJOR}) - - gz_find_package(gz-sim7 REQUIRED) - set(GZ_SIM_VER ${gz-sim7_VERSION_MAJOR}) - - message(STATUS "Compiling against Gazebo Garden") +else() + message(FATAL_ERROR "Unsupported GZ_VERSION: $ENV{GZ_VERSION}") endif() # --------------------------------------------------------------------------- #