gazebosim / gazebo-classic

Gazebo classic. For the latest version, see https://github.com/gazebosim/gz-sim
http://classic.gazebosim.org/
Other
1.15k stars 477 forks source link

find_package(gazebo QUIET) make CMake fail if Gazebo dependency is not found #3237

Open traversaro opened 1 year ago

traversaro commented 1 year ago

A call to find_package(gazebo QUIET) should quitly fail without making the calling CMake script fail. Instead, if Gazebo is installed but a dependency it is not found, the calling CMake fails, for example with error:

CMake Warning (dev) at C:/Users/STraversaro/AppData/Local/mambaforge/envs/robsub/Library/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (PkgConfig)
  does not match the name of the calling package (gazebo).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  C:/Users/STraversaro/AppData/Local/mambaforge/envs/robsub/Library/share/cmake-3.23/Modules/FindPkgConfig.cmake:99 (find_package_handle_standard_args)
  C:/Users/STraversaro/AppData/Local/mambaforge/envs/robsub/Library/lib/cmake/gazebo/gazebo-config.cmake:62 (include)
  cmake/BuildGazeboYARPPlugins.cmake:31 (find_package)
  build2022/_deps/ycm-src/modules/FindOrBuildPackage.cmake:205 (include)
  cmake/RobotologySuperbuildLogic.cmake:19 (find_or_build_package)
  CMakeLists.txt:66 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Looking for ignition-math6 -- found version 6.11.0
-- Searching for dependencies of ignition-math6
-- Found OGRE
--   static     : OFF
--   components : Bites;HLMS;MeshLodGenerator;Overlay;Paging;Property;RTShaderSystem;Terrain;Volume
--   plugins    : Plugin_BSPSceneManager;Plugin_OctreeSceneManager;Plugin_PCZSceneManager;Plugin_ParticleFX;RenderSystem_GL;RenderSystem_GL3Plus;RenderSystem_Direct3D11
--   media      : C:/Users/STraversaro/AppData/Local/mambaforge/envs/robsub/Library/Media
-- Looking for ignition-math6 -- found version 6.11.0
-- Looking for ignition-transport8 -- found version 8.1.0
-- Searching for dependencies of ignition-transport8
-- Looking for ignition-msgs5 -- found version 5.9.0
-- Searching for dependencies of ignition-msgs5
-- Looking for ignition-math6 -- found version 6.11.0
-- Checking for module 'tinyxml2'
--   Found tinyxml2, version 9.0.0
-- Looking for ignition-msgs5 -- found version 5.9.0
-- Looking for ignition-common3 -- found version 3.4.0
-- Searching for dependencies of ignition-common3
-- Searching for <ignition-common3> component [graphics]
-- Looking for ignition-common3-graphics -- found version 3.4.0
-- Searching for dependencies of ignition-common3-graphics
-- Looking for ignition-math6 -- found version 6.11.0
-- Looking for ignition-fuel_tools4 -- found version 4.0.0
-- Searching for dependencies of ignition-fuel_tools4
-- Checking for module 'jsoncpp'
--   Found jsoncpp, version 1.8.4
-- Checking for module 'yaml-0.1'
--   No package 'yaml-0.1' found
-- Attempting manual search for yaml
-- Looking for yaml headers - not found
-- Looking for yaml library - not found
CMake Error at C:/Users/STraversaro/AppData/Local/mambaforge/envs/robsub/Library/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find YAML (missing: YAML_FOUND)
Call Stack (most recent call first):
  C:/Users/STraversaro/AppData/Local/mambaforge/envs/robsub/Library/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  C:/Users/STraversaro/AppData/Local/mambaforge/envs/robsub/Library/share/cmake/ignition-cmake2/cmake2/FindYAML.cmake:93 (find_package_handle_standard_args)
  C:/Users/STraversaro/AppData/Local/mambaforge/envs/robsub/Library/lib/cmake/ignition-fuel_tools4/ignition-fuel_tools4-config.cmake:95 (find_package)
  C:/Users/STraversaro/AppData/Local/mambaforge/envs/robsub/Library/lib/cmake/gazebo/gazebo-config.cmake:241 (find_package)
  cmake/BuildGazeboYARPPlugins.cmake:31 (find_package)

This is due to the use of find_package(<deps> REQUIRED) in gazebo-config.cmake , see https://github.com/osrf/gazebo/blob/3e3e019f72e471fbb93d43ca024f3032ed6d8299/cmake/gazebo-config.cmake.in#L195 . Ideally, now that only CMake 3.10+ is supported, we should switch to find_dependency (see https://cmake.org/cmake/help/v3.10/module/CMakeFindDependencyMacro.html).

traversaro commented 1 year ago

Note that given that Gazebo is going to be eventually out of support in 2025 this issue is not particularly problematic or blocking, but I prefered to have a place were this was tracked.