gazebosim / gz-cmake

A set of CMake modules that are used by the C++-based Gazebo projects.
https://gazebosim.org/libs/cmake
Apache License 2.0
27 stars 30 forks source link

[FindGzOgreNext] Support Ogre 3.x and beyond #457

Open oysstu opened 3 weeks ago

oysstu commented 3 weeks ago

The ogre-next project has released the next major version (v3.0.0 Eris). It seems that from now on, the project will follow a more conventional semver strategy, where new development is focused on the next major version.

Currently the FindGzOgre2 is hard-coded to find ogre-next releases with major version 2.x.x. It would probably be a good idea to generalize this to FindGzOgreNext. The "USE_NEW_PROJECT_NAME" feature was merged in v2.3.3, so support for v2.3.2 and earlier should probably be left to the existing FindGzOgre2 or dropped completely.

j-rivero commented 3 weeks ago

Wow these are good news! The FindGzOgreNext needs a good cleanup and we should try to use plain CMake modules from upstream. I can happily review code changes for this. Thanks @oysstu !

oysstu commented 3 weeks ago

I had a quick look at the ogre-next cmake setup, and it looks like they're not using modern cmake packaging conventions yet. Ideally, they would export the targets and components in a package config in ../share/cmake/. Instead, there's pkg-config files tied together by a big FindOGRE.cmake module in ../lib/../OGRE-Next/cmake.

The way I see it there's two possibilities

The upstream FindOGRE module has been around for a long time though, so I'm sure there's a reason the latter hasn't been done before.

iche033 commented 3 weeks ago

when I wrote the original version using pkg-config many years ago I remember it's because the upstream find ogre module would not always find the correct ogre version or the right ogre plugin libraries. With the new ogre-next name change, things may be different. I think it's a good idea to use the upstream module instead of custom pkg-config code.

oysstu commented 1 week ago

I've created an issue in ogre-next (https://github.com/OGRECave/ogre-next/issues/470). Their FindOGRE file still doesn't work well when both ogre-next and ogre is installed. Pkgconfig on the other hand behaves the same even if ogre is installed alongside ogre-next.

I.e., the following prints the same variable definitions even if ogre is installed.

cmake_minimum_required(VERSION 3.22)
project(ogre-test)

find_package(PkgConfig REQUIRED)
pkg_check_modules(OGRE_NEXT OGRE-Next REQUIRED)
pkg_check_modules(OGRE_NEXT_HLMS OGRE-Next-Hlms REQUIRED)
pkg_check_modules(OGRE_NEXT_OVERLAY OGRE-Next-Overlay REQUIRED)

get_cmake_property(_variableNames VARIABLES)
list (SORT _variableNames)
foreach (_variableName ${_variableNames})
    message(STATUS "${_variableName}=${${_variableName}}")
endforeach()

Also, the pkgconfig files are installed in a standard location, whereas the FindOGRE.cmake install location is non-standard.