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

Add more explicit version compatibility for OGRE2 #297

Merged
merged 3 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion cmake/FindGzOGRE2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,20 @@
# COMPONENTS HlmsPbs HlmsUnlit Overlay)


if(NOT (GzOGRE2_FIND_VERSION_MAJOR AND GzOGRE2_FIND_VERSION_MINOR))
message(WARNING
"find_package(GzOGRE2) must be called with a VERSION argument with a minimum of major and minor version")
set(OGRE2_FOUND false)
return()
endif()

# Sanity check: exclude OGRE1 project releasing versions in two ways:
# - Legacy in from using 1.x.y until 1.12.y series
# - Modern versions using X.Y.Z starting with 13.y.z
# Reduce valid versions to 2.x series
if (${GzOGRE2_FIND_VERSION_MAJOR})
if (${GzOGRE2_FIND_VERSION_MAJOR} VERSION_LESS "2" OR
${GzOGRE2_FIND_VERSION_MAJOR} VERSION_GREATER_EQUAL "3")
${GzOGRE2_FIND_VERSION_MAJOR} VERSION_GREATER_EQUAL "3")
set (OGRE2_FOUND false)
return()
endif()
Expand Down Expand Up @@ -268,6 +275,29 @@ if (NOT WIN32)
get_preprocessor_entry(OGRE_TEMP_VERSION_CONTENT OGRE_VERSION_NAME OGRE2_VERSION_NAME)
set(OGRE2_VERSION "${OGRE2_VERSION_MAJOR}.${OGRE2_VERSION_MINOR}.${OGRE2_VERSION_PATCH}")

set(GzOGRE2_VERSION_EXACT FALSE)
set(GzOGRE2_VERSION_COMPATIBLE FALSE)

if (NOT ("${OGRE2_VERSION_MAJOR}" EQUAL "${GzOGRE2_FIND_VERSION_MAJOR}"))
set(OGRE2_FOUND FALSE)
continue()
endif()

if (NOT ("${OGRE2_VERSION_MINOR}" EQUAL "${GzOGRE2_FIND_VERSION_MINOR}"))
message(STATUS " ! ${GZ_OGRE2_PROJECT_NAME} found with incompatible version ${OGRE2_VERSION}")
set(OGRE2_FOUND FALSE)
continue()
endif()

if ("${OGRE2_VERSION}" VERSION_EQUAL "${GzOGRE2_FIND_VERSION}")
set(GzOGRE2_VERSION_EXACT TRUE)
set(GzOGRE2_VERSION_COMPATIBLE TRUE)
endif()

if ("${OGRE2_VERSION}" VERSION_GREATER "${GzOGRE2_FIND_VERSION}")
set(GzOGRE2_VERSION_COMPATIBLE TRUE)
endif()

# find ogre components
include(GzImportTarget)
foreach(component ${GzOGRE2_FIND_COMPONENTS})
Expand Down Expand Up @@ -530,6 +560,14 @@ if (OGRE2_FOUND)
PROPERTY INTERFACE_LINK_DIRECTORIES
${OGRE2_LIBRARY_DIRS}
)
else()
# Unset variables so that we don't leak incorrect versions
set(OGRE2_VERSION "")
set(OGRE2_VERSION_MAJOR "")
set(OGRE2_VERSION_MINOR "")
set(OGRE2_VERSION_PATCH "")
set(OGRE2_LIBRARIES "")
set(OGRE2_INCLUDE_DIRS "")
endif()

set(IgnOGRE2_FOUND ${GzOGRE2_FOUND}) # TODO(CH3): Deprecated. Remove on tock.
Expand Down
21 changes: 13 additions & 8 deletions examples/find_ogre2/ogre-2.1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ find_package(gz-cmake3 REQUIRED)

message(STATUS "Finding OGRE 2.1")

gz_find_package(GzOGRE2 VERSION 2.1.0
gz_find_package(GzOGRE2 VERSION 2.1
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})
if(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})

message(STATUS "GzOGRE2_VERSION_EXACT: " ${GzOGRE2_VERSION_EXACT})
message(STATUS "GzOGRE2_VERSION_COMPATIBLE: " ${GzOGRE2_VERSION_COMPATIBLE})
endif()
22 changes: 13 additions & 9 deletions examples/find_ogre2/ogre-2.2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@ project(gz-ogre-2.2 VERSION 0.1.0)

find_package(gz-cmake3 REQUIRED)

message(STATUS "Finding OGRE 2.2")

message(STATUS "Finding OGRE 2.2.0")
gz_find_package(GzOGRE2 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})
if(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})

message(STATUS "GzOGRE2_VERSION_EXACT: " ${GzOGRE2_VERSION_EXACT})
message(STATUS "GzOGRE2_VERSION_COMPATIBLE: " ${GzOGRE2_VERSION_COMPATIBLE})
endif()
25 changes: 15 additions & 10 deletions examples/find_ogre2/ogre-2.3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@ project(gz-ogre-2.3 VERSION 0.1.0)

find_package(gz-cmake3 REQUIRED)

message(STATUS "Finding OGRE 2.3")

gz_find_package(IgnOGRE2 VERSION 2.3.0)
message(STATUS "Finding OGRE 2.3.0")
gz_find_package(GzOGRE2 VERSION 2.3.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})
if(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})

message(STATUS "GzOGRE2_VERSION_EXACT: " ${GzOGRE2_VERSION_EXACT})
message(STATUS "GzOGRE2_VERSION_COMPATIBLE: " ${GzOGRE2_VERSION_COMPATIBLE})
endif()
22 changes: 22 additions & 0 deletions examples/find_ogre2/ogre-2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
project(gz-ogre-2 VERSION 0.1.0)

find_package(gz-cmake3 REQUIRED)

message(STATUS "Finding OGRE 2")
gz_find_package(GzOGRE2 VERSION 2
COMPONENTS HlmsPbs HlmsUnlit Overlay)

message(STATUS "OGRE2_FOUND: " ${OGRE2_FOUND})
if(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})

message(STATUS "GzOGRE2_VERSION_EXACT: " ${GzOGRE2_VERSION_EXACT})
message(STATUS "GzOGRE2_VERSION_COMPATIBLE: " ${GzOGRE2_VERSION_COMPATIBLE})
endif()
22 changes: 22 additions & 0 deletions examples/find_ogre2/ogre/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
project(gz-ogre VERSION 0.1.0)

find_package(gz-cmake3 REQUIRED)

message(STATUS "Finding OGRE 2")
gz_find_package(GzOGRE2
COMPONENTS HlmsPbs HlmsUnlit Overlay)

message(STATUS "OGRE2_FOUND: " ${OGRE2_FOUND})
if(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})

message(STATUS "GzOGRE2_VERSION_EXACT: " ${GzOGRE2_VERSION_EXACT})
message(STATUS "GzOGRE2_VERSION_COMPATIBLE: " ${GzOGRE2_VERSION_COMPATIBLE})
endif()