Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Ogre-Next 3.x.x built from source #468

Draft
wants to merge 4 commits into
base: gz-cmake4
Choose a base branch
from

Conversation

sumir0
Copy link

@sumir0 sumir0 commented Feb 9, 2025

🎉 New feature

Related to Integrating Ogre-Next 3.0's atmosphere component

Summary

This PR allows Ogre-Next version 3.x.x to be found by using gz_find_package (for example: gz_find_package(GzOGRE3 VERSION 3). Only 3.x.x versions built from source are supported. The code is heavily based on the cmake/FindGzOGRE2.cmake file and represents a reduced and slightly modified version of that file.

Test it

  • Install pkg-config. To do that I typed pacman -S pkg-config in a terminal. For Ubuntu a similar package probably is available.
  • Install Ogre-Next version 3.0.0 (or any other 3.x.x version) from source following the instructions from the official documentation. To run examples HlmsPbs, HlmsUnlit, Overlay, Atmosphere components are needed. To do that cmake needs to be run with several special parameters, for example:
cmake \
  -D OGRE_BUILD_COMPONENT_ATMOSPHERE=ON \
  -D OGRE_BUILD_COMPONENT_HLMS_PBS=ON \
  -D OGRE_BUILD_COMPONENT_HLMS_UNLIT=ON \
  -D OGRE_BUILD_COMPONENT_OVERLAY=ON \
  <your_parameters> <path_to_source>
  • Follow the instructions in the examples/find_ogre3/README.md file.

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

@sumir0
Copy link
Author

sumir0 commented Feb 10, 2025

As it is related to #457, should I try to merge cmake/FindGzOGRE2.cmake and cmake/FindGzOgre3.cmake into something like cmake/FindGzOgreNext.cmake?

PS. Sorry for the commits related to a typo and obsolete documetation. For some strange reason I didn't notice it when I was reviewing my code.

examples/find_ogre3/README.md Outdated Show resolved Hide resolved
examples/find_ogre3/README.md Outdated Show resolved Hide resolved
examples/find_ogre3/ogre-3.0/CMakeLists.txt Outdated Show resolved Hide resolved

message(STATUS "GzOGRE3_VERSION_EXACT: " ${GzOGRE3_VERSION_EXACT})
message(STATUS "GzOGRE3_VERSION_COMPATIBLE: " ${GzOGRE3_VERSION_COMPATIBLE})
endif()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add else just in case Ogre 3 is not installed or something happened

Copy link
Author

@sumir0 sumir0 Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a comment on line 11. do we really need an else block?

examples/find_ogre3/ogre-3/CMakeLists.txt Outdated Show resolved Hide resolved

message(STATUS "Finding OGRE 3")

gz_find_package(GzOGRE3 VERSION 3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we are adding a cmake for 3.0 and 3. are there any differences ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in fact, i don't precisely know the reasons behind it. i looked at the examples/find_ogre2 directory, found the examples for multiple versions (2, 2.1, 2.2, 2.3) and tried to make a similar thing for ogre3. probably, it makes (manual) testing more complete in the sense not only a major version parameter is tested but also a minor version parameter is tested with several values. but it is duplicate code and i will reduce examples only to 3 then. we can add more examples later if needed.


message(STATUS "GzOGRE3_VERSION_EXACT: " ${GzOGRE3_VERSION_EXACT})
message(STATUS "GzOGRE3_VERSION_COMPATIBLE: " ${GzOGRE3_VERSION_COMPATIBLE})
endif()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same idea with the else here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question here

gz_find_package(GzOGRE3 VERSION 3.0
COMPONENTS HlmsPbs HlmsUnlit Overlay Atmosphere)

message(STATUS "OGRE3_FOUND: " ${OGRE3_FOUND})
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case Ogre-Next 3 is not installed OGRE3_FOUND will be FALSE and the corresponding message will be displayed:

-- OGRE3_FOUND: FALSE

@sumir0 sumir0 requested a review from ahcorde February 10, 2025 14:28
@traversaro
Copy link
Contributor

As mentioned in #457 (comment) since OgreNext 3.0 it should be sufficient to just call find_package(OgreNext CONFIG) and all the required variables and imported target should be defined without any additional complexity, just in case did you checked if that works?

@j-rivero
Copy link
Contributor

Thanks @sumir0 for the PR ! The support for OGRE-3.x and gazebosim/gz-sim#2753 is really cool.

As it is related to #457, should I try to merge cmake/FindGzOGRE2.cmake and cmake/FindGzOgre3.cmake into something like cmake/FindGzOgreNext.cmake?

This is indeed a good idea. Even better would be that we can use the the CMake Module shipped directly by upstream as @traversaro mentioned. If you could give it a try, would be great.

PS. Sorry for the commits related to a typo and obsolete documetation. For some strange reason I didn't notice it when I was reviewing my code.

No worries!

@sumir0
Copy link
Author

sumir0 commented Feb 10, 2025

I checked find_package(OGRE) on my setup (OGRE-Next v3.0.0 built from source) with -D CMAKE_MODULE_PATH=/usr/local/lib/OGRE/cmake. It finds OGRE (classic) when it is installed alongside. It does find OGRE-Next when OGRE (classic) is not installed. But it doesn't find the Atmosphere component which we will, probably, need in future.

Output with OGRE (classic) installed alongside:

-- Looking for OGRE...
-- OGRE_PREFIX_WATCH changed.
-- Found PkgConfig: /usr/bin/pkg-config (found version "2.3.0")
-- Checking for module 'OGRE-Next'
--   Package 'OGRE-Next' not found
-- Checking for module 'OGRE'
--   Found OGRE, version 14.3.2
-- Found Ogre  (..)
-- Found OGRE: optimized;/usr/lib/libOgreMain.so;debug;/usr/local/lib/libOgreMain_d.so
-- Looking for OGRE_Paging...
-- Found OGRE_Paging: optimized;/usr/lib/libOgrePaging.so;debug;/usr/lib/libOgrePaging.so
-- Looking for OGRE_Terrain...
-- Found OGRE_Terrain: optimized;/usr/lib/libOgreTerrain.so;debug;/usr/lib/libOgreTerrain.so
-- Looking for OGRE_Property...
-- Found OGRE_Property: optimized;/usr/lib/libOgreProperty.so;debug;/usr/lib/libOgreProperty.so
-- Looking for OGRE_Volume...
-- Found OGRE_Volume: optimized;/usr/lib/libOgreVolume.so;debug;/usr/lib/libOgreVolume.so
-- Looking for OGRE_Overlay...
-- Found OGRE_Overlay: optimized;/usr/lib/libOgreOverlay.so;debug;/usr/local/lib/libOgreOverlay_d.so
-- Looking for OGRE_HlmsPbs...
-- Could not locate OGRE_HlmsPbs
-- Looking for OGRE_HlmsUnlit...
-- Could not locate OGRE_HlmsUnlit

Output with only OGRE-Next installed (with the Atmosphere component) from source:

-- Looking for OGRE...
-- OGRE_PREFIX_WATCH changed.
-- Found PkgConfig: /usr/bin/pkg-config (found version "2.3.0")
-- Checking for module 'OGRE-Next'
--   Package 'OGRE-Next' not found
-- Checking for module 'OGRE'
--   Package 'OGRE' not found
-- Found Ogre Eris (3.0.0)
-- Found OGRE: /usr/local/lib/libOgreMain_d.so
-- Looking for OGRE_Paging...
-- Could not locate OGRE_Paging
-- Looking for OGRE_Terrain...
-- Could not locate OGRE_Terrain
-- Looking for OGRE_Property...
-- Could not locate OGRE_Property
-- Looking for OGRE_Volume...
-- Could not locate OGRE_Volume
-- Looking for OGRE_Overlay...
-- Found OGRE_Overlay: /usr/local/lib/libOgreOverlay_d.so
-- Looking for OGRE_HlmsPbs...
-- Found OGRE_HlmsPbs: /usr/local/lib/libOgreHlmsPbs_d.so
-- Looking for OGRE_HlmsUnlit...
-- Found OGRE_HlmsUnlit: /usr/local/lib/libOgreHlmsUnlit_d.so

Thank you to all of you! I will convert this PR to draft for now. I will think about possibility of contributing to OGRE-Next, because I need the Atmosphere component for gazebosim/gz-sim#2753. Feel free to comment, any (good) advice would be appreciated.

@sumir0 sumir0 marked this pull request as draft February 10, 2025 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏛️ ionic Gazebo Ionic 🪵 jetty Gazebo Jetty
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

4 participants