Skip to content

Commit

Permalink
Support to find Ogre 2-2 (#157)
Browse files Browse the repository at this point in the history
* Find Ogre 2-2

Signed-off-by: ahcorde <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
ahcorde authored Mar 24, 2021
1 parent 01039be commit d71927a
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 5 deletions.
14 changes: 9 additions & 5 deletions cmake/FindIgnOGRE2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
# Example usage:
#
# ign_find_package(IgnOGRE2
# VERSION 2.1.0
# VERSION 2.2.0
# COMPONENTS HlmsPbs HlmsUnlit Overlay)

# sanity check
Expand All @@ -53,6 +53,9 @@ if (${IgnOGRE2_FIND_VERSION_MAJOR})
endif()
endif()

message(STATUS "-- Finding OGRE 2.${IgnOGRE2_FIND_VERSION_MINOR}")
set(OGRE2_INSTALL_PATH "OGRE-2.${IgnOGRE2_FIND_VERSION_MINOR}")

macro(append_library VAR LIB)
if(EXISTS "${LIB}")
list(APPEND ${VAR} ${LIB})
Expand Down Expand Up @@ -92,12 +95,13 @@ endmacro()
if (NOT WIN32)
set(PKG_CONFIG_PATH_ORIGINAL $ENV{PKG_CONFIG_PATH})

# Note: OGRE2 installed from debs is named OGRE-2.1 while the version
# installed from source does not have the 2.1 suffix
# Note: OGRE2 installed from debs is named OGRE-2.2 while the version
# installed from source does not have the 2.2 suffix
# look for OGRE2 installed from debs
ign_pkg_check_modules_quiet(OGRE2 "OGRE-2.1" NO_CMAKE_ENVIRONMENT_PATH QUIET)
ign_pkg_check_modules_quiet(OGRE2 ${OGRE2_INSTALL_PATH} NO_CMAKE_ENVIRONMENT_PATH QUIET)

if (OGRE2_FOUND)
set(IGN_PKG_NAME "OGRE-2.1")
set(IGN_PKG_NAME ${OGRE2_INSTALL_PATH})
else()
# look for OGRE2 installed from source
set(PKG_CONFIG_PATH_TMP ${PKG_CONFIG_PATH_ORIGINAL})
Expand Down
53 changes: 53 additions & 0 deletions examples/find_ogre2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
A quick demonstration of searching for Ogre 2.1 vs 2.2 via ign-cmake.

To test with both versions installed:

## Ogre 2.1

```
cd ogre-2.1
mkdir build
cd build
cmake ..
```

### Expected output

```
-- Looking for IgnOGRE2 - found
-- OGRE2_FOUND: TRUE
-- OGRE2_LIBRARIES: /usr/lib/x86_64-linux-gnu/OGRE-2.1/libOgreMain.soIgnOGRE2-HlmsPbs::IgnOGRE2-HlmsPbsIgnOGRE2-HlmsUnlit::IgnOGRE2-HlmsUnlitIgnOGRE2-Overlay::IgnOGRE2-Overlay
-- OGRE2_INCLUDE_DIRS: /usr/include/OGRE-2.1/usr/include/OGRE-2.1/RenderSystems/GL3Plus
-- OGRE2_VERSION: 2.1.0
-- OGRE2_VERSION_MAJOR: 2
-- OGRE2_VERSION_MINOR: 1
-- OGRE2_VERSION_PATCH: 0
-- OGRE2_RESOURCE_PATH: /usr/lib/x86_64-linux-gnu/OGRE-2.1/OGRE
```

## Ogre 2.2

```
cd ogre-2.2
mkdir build
cd build
cmake ..
```

### Expected output


```
-- Looking for IgnOGRE2 - found
-- OGRE2_FOUND: TRUE
-- OGRE2_LIBRARIES: /usr/lib/x86_64-linux-gnu/OGRE-2.2/libOgreMain.soIgnOGRE2-HlmsPbs::IgnOGRE2-HlmsPbsIgnOGRE2-HlmsUnlit::IgnOGRE2-HlmsUnlitIgnOGRE2-Overlay::IgnOGRE2-Overlay
-- OGRE2_INCLUDE_DIRS: /usr/include/OGRE-2.2/usr/include/OGRE-2.2/RenderSystems/GL3Plus
-- OGRE2_VERSION: 2.2.6
-- OGRE2_VERSION_MAJOR: 2
-- OGRE2_VERSION_MINOR: 2
-- OGRE2_VERSION_PATCH: 6
-- OGRE2_RESOURCE_PATH: /usr/lib/x86_64-linux-gnu/OGRE-2.2/OGRE
```

18 changes: 18 additions & 0 deletions examples/find_ogre2/ogre-2.1/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
project(ignition-ogre-2.1 VERSION 0.1.0)

find_package(ignition-cmake2 REQUIRED)

message(STATUS "Finding OGRE 2.1")

ign_find_package(IgnOGRE2 VERSION 2.1.0
COMPONENTS HlmsPbs HlmsUnlit Overlay)

message(STATUS "OGRE2_FOUND: " ${OGRE2_FOUND})
message(STATUS "OGRE2_LIBRARIES: " ${OGRE2_LIBRARIES})
message(STATUS "OGRE2_INCLUDE_DIRS: " ${OGRE2_INCLUDE_DIRS})
message(STATUS "OGRE2_VERSION: " ${OGRE2_VERSION})
message(STATUS "OGRE2_VERSION_MAJOR: " ${OGRE2_VERSION_MAJOR})
message(STATUS "OGRE2_VERSION_MINOR: " ${OGRE2_VERSION_MINOR})
message(STATUS "OGRE2_VERSION_PATCH: " ${OGRE2_VERSION_PATCH})
message(STATUS "OGRE2_RESOURCE_PATH: " ${OGRE2_RESOURCE_PATH})
18 changes: 18 additions & 0 deletions examples/find_ogre2/ogre-2.2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
project(ignition-ogre-2.2 VERSION 0.1.0)

find_package(ignition-cmake2 REQUIRED)

message(STATUS "Finding OGRE 2.2")

ign_find_package(IgnOGRE2 VERSION 2.2.0
COMPONENTS HlmsPbs HlmsUnlit Overlay)

message(STATUS "OGRE2_FOUND: " ${OGRE2_FOUND})
message(STATUS "OGRE2_LIBRARIES: " ${OGRE2_LIBRARIES})
message(STATUS "OGRE2_INCLUDE_DIRS: " ${OGRE2_INCLUDE_DIRS})
message(STATUS "OGRE2_VERSION: " ${OGRE2_VERSION})
message(STATUS "OGRE2_VERSION_MAJOR: " ${OGRE2_VERSION_MAJOR})
message(STATUS "OGRE2_VERSION_MINOR: " ${OGRE2_VERSION_MINOR})
message(STATUS "OGRE2_VERSION_PATCH: " ${OGRE2_VERSION_PATCH})
message(STATUS "OGRE2_RESOURCE_PATH: " ${OGRE2_RESOURCE_PATH})

0 comments on commit d71927a

Please sign in to comment.