Skip to content

Commit

Permalink
Hardtock target and pkg names in FindXXX files, and ticktock set vars
Browse files Browse the repository at this point in the history
Signed-off-by: methylDragon <[email protected]>
  • Loading branch information
methylDragon committed Jul 9, 2022
1 parent 2b7b141 commit 2d3b2ee
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 78 deletions.
10 changes: 6 additions & 4 deletions cmake/FindGzBullet.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ endif()
# with Bullet, which uses relative paths and may break transitive dependencies.
find_package(Bullet MODULE ${gz_quiet_arg})

set(IgnBullet_FOUND false)
set(GzBullet_FOUND false)
set(IgnBullet_FOUND false) # TODO(CH3): Deprecated. Remove on tock.
# create Bullet target
if(BULLET_FOUND)
set(IgnBullet_FOUND true)
set(GzBullet_FOUND true)
set(IgnBullet_FOUND true) # TODO(CH3): Deprecated. Remove on tock.

gz_import_target(IgnBullet
TARGET_NAME IgnBullet::IgnBullet
gz_import_target(GzBullet
TARGET_NAME GzBullet::GzBullet
LIB_VAR BULLET_LIBRARIES
INCLUDE_VAR BULLET_INCLUDE_DIRS
)
Expand Down
26 changes: 16 additions & 10 deletions cmake/FindGzCURL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,34 @@
#
# Usage of this module as follows:
#
# find_package(IgnCURL)
# find_package(GzCURL)
#
# Variables defined by this module:
#
# curl::curl Imported target for libcurl
#
# IgnCURL_FOUND System has CURL libs/headers
# IgnCURL_INCLUDE_DIRS The location of CURL headers
# IgnCURL_LIBRARIES The CURL libraries
# IgnCURL_VERSION The version of CURL found
# GzCURL_FOUND System has CURL libs/headers
# GzCURL_INCLUDE_DIRS The location of CURL headers
# GzCURL_LIBRARIES The CURL libraries
# GzCURL_VERSION The version of CURL found

set(gz_quiet_arg)
if(IgnCURL_FIND_QUIETLY)
if(GzCURL_FIND_QUIETLY)
set(gz_quiet_arg QUIET)
endif()

find_package(CURL ${IgnCURL_FIND_VERSION} ${gz_quiet_arg})
find_package(CURL ${GzCURL_FIND_VERSION} ${gz_quiet_arg})

set(IgnCURL_FOUND ${CURL_FOUND})
set(GzCURL_FOUND ${CURL_FOUND})
set(IgnCURL_FOUND ${CURL_FOUND}) # TODO(CH3): Deprecated. Remove on tock.

if(${IgnCURL_FOUND})
if(${GzCURL_FOUND})

set(GzCURL_INCLUDE_DIRS ${CURL_INCLUDE_DIRS})
set(GzCURL_LIBRARIES ${CURL_LIBRARIES})
set(GzCURL_VERSION ${CURL_VERSION_STRING})

# TODO(CH3): Deprecated. Remove on tock.
set(IgnCURL_INCLUDE_DIRS ${CURL_INCLUDE_DIRS})
set(IgnCURL_LIBRARIES ${CURL_LIBRARIES})
set(IgnCURL_VERSION ${CURL_VERSION_STRING})
Expand All @@ -61,6 +67,6 @@ if(${IgnCURL_FOUND})
endif()

include(IgnPkgConfig)
gz_pkg_config_entry(IgnCURL "libcurl >= ${IgnCURL_FIND_VERSION}")
gz_pkg_config_entry(GzCURL "libcurl >= ${GzCURL_FIND_VERSION}")

endif()
36 changes: 19 additions & 17 deletions cmake/FindGzOGRE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#
# Usage of this module as follows:
#
# gz_find_package(IgnOGRE)
# gz_find_package(GzOGRE)
#
# Variables defined by this module:
#
Expand All @@ -32,7 +32,7 @@
# OGRE_VERSION_MINOR OGRE minor version
# OGRE_VERSION_PATCH OGRE patch version
# OGRE_RESOURCE_PATH Path to ogre plugins directory
# IgnOGRE::IgnOGRE Imported target for OGRE
# GzOGRE::GzOGRE Imported target for OGRE
#
# On Windows, we assume that all the OGRE* defines are passed in manually
# to CMake.
Expand All @@ -41,13 +41,13 @@
#
# Example usage:
#
# gz_find_package(IgnOGRE
# gz_find_package(GzOGRE
# VERSION 1.8.0
# COMPONENTS RTShaderSystem Terrain Overlay)

# Grab the version numbers requested by the call to find_package(~)
set(major_version ${IgnOGRE_FIND_VERSION_MAJOR})
set(minor_version ${IgnOGRE_FIND_VERSION_MINOR})
set(major_version ${GzOGRE_FIND_VERSION_MAJOR})
set(minor_version ${GzOGRE_FIND_VERSION_MINOR})

# Set the full version number
set(full_version ${major_version}.${minor_version})
Expand Down Expand Up @@ -139,11 +139,11 @@ if (NOT WIN32)
OGRE_VERSION_PATCH ${OGRE_VERSION})

# find ogre components
foreach(component ${IgnOGRE_FIND_COMPONENTS})
gz_pkg_check_modules_quiet(IgnOGRE-${component} "OGRE-${component} >= ${full_version}" NO_CMAKE_ENVIRONMENT_PATH)
if(IgnOGRE-${component}_FOUND)
list(APPEND OGRE_LIBRARIES IgnOGRE-${component}::IgnOGRE-${component})
elseif(IgnOGRE_FIND_REQUIRED_${component})
foreach(component ${GzOGRE_FIND_COMPONENTS})
gz_pkg_check_modules_quiet(GzOGRE-${component} "OGRE-${component} >= ${full_version}" NO_CMAKE_ENVIRONMENT_PATH)
if(GzOGRE-${component}_FOUND)
list(APPEND OGRE_LIBRARIES GzOGRE-${component}::GzOGRE-${component})
elseif(GzOGRE_FIND_REQUIRED_${component})
set(OGRE_FOUND false)
endif()
endforeach()
Expand All @@ -158,7 +158,7 @@ if (NOT WIN32)
set(OGRE_PLUGINDIR ${_pkgconfig_invoke_result})
endif()

gz_pkg_config_library_entry(IgnOGRE OgreMain)
gz_pkg_config_library_entry(GzOGRE OgreMain)

set(OGRE_RESOURCE_PATH ${OGRE_PLUGINDIR})
# Seems that OGRE_PLUGINDIR can end in a newline, which will cause problems
Expand All @@ -171,12 +171,12 @@ if (NOT WIN32)

else()
find_package(OGRE ${full_version}
COMPONENTS ${IgnOGRE_FIND_COMPONENTS})
COMPONENTS ${GzOGRE_FIND_COMPONENTS})
if(OGRE_FOUND)
# OGREConfig.cmake from vcpkg disable the link against plugin libs
# when compiling the shared version of it. Here we copied the code
# to use it.
foreach(ogre_component ${IgnOGRE_FIND_COMPONENTS})
foreach(ogre_component ${GzOGRE_FIND_COMPONENTS})
if(ogre_component MATCHES "Plugin_" OR ogre_component MATCHES "RenderSystem_")
string(LENGTH "${ogre_component}" len)
string(FIND "${ogre_component}" "_" split_pos)
Expand Down Expand Up @@ -239,9 +239,11 @@ else()
endif()
endif()

set(IgnOGRE_FOUND false)
set(GzOGRE_FOUND false)
set(IgnOGRE_FOUND false) # TODO(CH3): Deprecated. Remove on tock.
if(OGRE_FOUND)
set(IgnOGRE_FOUND true)
set(GzOGRE_FOUND true)
set(IgnOGRE_FOUND true) # TODO(CH3): Deprecated. Remove on tock.

# manually search and append the the RenderSystem/GL path to
# OGRE_INCLUDE_DIRS so OGRE GL headers can be found
Expand All @@ -260,8 +262,8 @@ if(OGRE_FOUND)
endforeach()

include(IgnImportTarget)
gz_import_target(IgnOGRE
TARGET_NAME IgnOGRE::IgnOGRE
gz_import_target(GzOGRE
TARGET_NAME GzOGRE::GzOGRE
LIB_VAR OGRE_LIBRARIES
INCLUDE_VAR OGRE_INCLUDE_DIRS)
endif()
42 changes: 22 additions & 20 deletions cmake/FindGzOGRE2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#
# Usage of this module as follows:
#
# gz_find_package(IgnOGRE2)
# gz_find_package(GzOGRE2)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
Expand All @@ -41,7 +41,7 @@
# OGRE2_VERSION_MINOR OGRE minor version
# OGRE2_VERSION_PATCH OGRE patch version
# OGRE2_RESOURCE_PATH Path to ogre plugins directory
# IgnOGRE2::IgnOGRE2 Imported target for OGRE2
# GzOGRE2::GzOGRE2 Imported target for OGRE2
#
# On Windows, we assume that all the OGRE* defines are passed in manually
# to CMake.
Expand All @@ -51,18 +51,18 @@
#
# Example usage:
#
# gz_find_package(IgnOGRE2
# VERSION 2.2.0
# COMPONENTS HlmsPbs HlmsUnlit Overlay)
# gz_find_package(GzOGRE2
# VERSION 2.2.0
# COMPONENTS HlmsPbs HlmsUnlit Overlay)


# 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 (${IgnOGRE2_FIND_VERSION_MAJOR})
if (${IgnOGRE2_FIND_VERSION_MAJOR} VERSION_LESS "2" OR
${IgnOGRE2_FIND_VERSION_MAJOR} VERSION_GREATER_EQUAL "3")
if (${GzOGRE2_FIND_VERSION_MAJOR})
if (${GzOGRE2_FIND_VERSION_MAJOR} VERSION_LESS "2" OR
${GzOGRE2_FIND_VERSION_MAJOR} VERSION_GREATER_EQUAL "3")
set (OGRE2_FOUND false)
return()
endif()
Expand Down Expand Up @@ -144,7 +144,7 @@ if (NOT WIN32)
foreach (IGN_OGRE2_PROJECT_NAME "OGRE2" "OGRE-Next")
message(STATUS "Looking for OGRE using the name: ${IGN_OGRE2_PROJECT_NAME}")
if (IGN_OGRE2_PROJECT_NAME STREQUAL "OGRE2")
set(OGRE2_INSTALL_PATH "OGRE-2.${IgnOGRE2_FIND_VERSION_MINOR}")
set(OGRE2_INSTALL_PATH "OGRE-2.${GzOGRE2_FIND_VERSION_MINOR}")
set(OGRE2LIBNAME "Ogre")
else()
set(OGRE2_INSTALL_PATH "OGRE-Next")
Expand Down Expand Up @@ -262,7 +262,7 @@ if (NOT WIN32)

# find ogre components
include(IgnImportTarget)
foreach(component ${IgnOGRE2_FIND_COMPONENTS})
foreach(component ${GzOGRE2_FIND_COMPONENTS})
find_library(OGRE2-${component}
NAMES
"${OGRE2LIBNAME}${component}_d.${OGRE2_VERSION}"
Expand All @@ -273,7 +273,7 @@ if (NOT WIN32)
if (NOT "${OGRE2-${component}}" STREQUAL "OGRE2-${component}-NOTFOUND")
message(STATUS " + component ${component}: found")
# create a new target for each component
set(component_TARGET_NAME "IgnOGRE2-${component}::IgnOGRE2-${component}")
set(component_TARGET_NAME "GzOGRE2-${component}::GzOGRE2-${component}")
set(component_INCLUDE_DIRS ${OGRE2_INCLUDE_DIRS})

foreach (dir ${OGRE2_INCLUDE_DIRS})
Expand Down Expand Up @@ -303,7 +303,7 @@ if (NOT WIN32)
# add it to the list of ogre libraries
list(APPEND OGRE2_LIBRARIES ${component_TARGET_NAME})

elseif(IgnOGRE2_FIND_REQUIRED_${component})
elseif(GzOGRE2_FIND_REQUIRED_${component})
message(STATUS " ! component ${component}: not found!")
set(OGRE2_FOUND false)
endif()
Expand Down Expand Up @@ -340,7 +340,7 @@ if (NOT WIN32)
# We need to manually specify the pkgconfig entry (and type of entry),
# because gz_pkg_check_modules does not work for it.
include(IgnPkgConfig)
gz_pkg_config_library_entry(IgnOGRE2 OgreMain)
gz_pkg_config_library_entry(GzOGRE2 OgreMain)
else() #WIN32

set(OGRE2_FOUND TRUE)
Expand All @@ -350,7 +350,7 @@ else() #WIN32
set(OGRE2_VERSION_MINOR "")
set(OGRE2_RESOURCE_PATH "")

set(OGRE2_SEARCH_VER "OGRE-${IgnOGRE2_FIND_VERSION_MAJOR}.${IgnOGRE2_FIND_VERSION_MINOR}")
set(OGRE2_SEARCH_VER "OGRE-${GzOGRE2_FIND_VERSION_MAJOR}.${GzOGRE2_FIND_VERSION_MINOR}")
set(OGRE2_PATHS "")
set(OGRE2_INC_PATHS "")
foreach(_rootPath ${VCPKG_CMAKE_FIND_ROOT_PATH})
Expand Down Expand Up @@ -461,10 +461,10 @@ else() #WIN32
ogre_find_plugin(RenderSystem_GL3Plus OgreGL3PlusRenderSystem.h RenderSystems/GL3Plus/include)
ogre_find_plugin(RenderSystem_Direct3D11 OgreD3D11RenderSystem.h RenderSystems/Direct3D11/include)

foreach(component ${IgnOGRE2_FIND_COMPONENTS})
foreach(component ${GzOGRE2_FIND_COMPONENTS})
set(PREFIX OGRE2_${component})
if(${PREFIX}_FOUND)
set(component_TARGET_NAME "IgnOGRE2-${component}::IgnOGRE2-${component}")
set(component_TARGET_NAME "GzOGRE2-${component}::GzOGRE2-${component}")
set(component_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIRS})
# append the Hlms/Common include dir if it exists.
string(FIND ${component} "Hlms" HLMS_POS)
Expand Down Expand Up @@ -500,13 +500,15 @@ else() #WIN32
endif()
endif()

set(IgnOGRE2_FOUND false)
set(GzOGRE2_FOUND false)
set(IgnOGRE2_FOUND false) # TODO(CH3): Deprecated. Remove on tock.
# create OGRE2 target
if (OGRE2_FOUND)
set(IgnOGRE2_FOUND true)
set(GzOGRE2_FOUND true)
set(IgnOGRE2_FOUND false) # TODO(CH3): Deprecated. Remove on tock.

gz_import_target(IgnOGRE2
TARGET_NAME IgnOGRE2::IgnOGRE2
gz_import_target(GzOGRE2
TARGET_NAME GzOGRE2::GzOGRE2
LIB_VAR OGRE2_LIBRARIES
INCLUDE_VAR OGRE2_INCLUDE_DIRS)
endif()
27 changes: 14 additions & 13 deletions cmake/FindGzProtobuf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,60 +24,61 @@
# support shared library versions of Protobuf.

include(IgnPkgConfig)
gz_pkg_config_entry(IgnProtobuf "protobuf >= ${IgnProtobuf_FIND_VERSION}")
gz_pkg_config_entry(GzProtobuf "protobuf >= ${GzProtobuf_FIND_VERSION}")

find_package(Protobuf ${IgnProtobuf_FIND_VERSION} QUIET CONFIG)
find_package(Protobuf ${GzProtobuf_FIND_VERSION} QUIET CONFIG)

if(NOT ${Protobuf_FOUND})
# If a config-file was not found, then fall back on the system-installed
# find-module that comes with CMake.
find_package(Protobuf ${IgnProtobuf_FIND_VERSION})
find_package(Protobuf ${GzProtobuf_FIND_VERSION})
endif()

set(IgnProtobuf_missing_components "")
foreach(component ${IgnProtobuf_FIND_COMPONENTS})
set(GzProtobuf_missing_components "")
foreach(component ${GzProtobuf_FIND_COMPONENTS})

# If specific components are requested, check that each one is accounted for.
# If any component is missing, then we should not consider this package to be
# found.

# If a requested component is not required, then we can just skip this
# iteration. We don't do anything special for optional components.
if(NOT IgnProtobuf_FIND_REQUIRED_${component})
if(NOT GzProtobuf_FIND_REQUIRED_${component})
continue()
endif()

if((${component} STREQUAL "libprotobuf") OR (${component} STREQUAL "all"))
if((NOT PROTOBUF_LIBRARY) AND (NOT TARGET protobuf::libprotobuf))
set(Protobuf_FOUND false)
gz_string_append(IgnProtobuf_missing_components "libprotobuf" DELIM " ")
gz_string_append(GzProtobuf_missing_components "libprotobuf" DELIM " ")
endif()
endif()

if((${component} STREQUAL "libprotoc") OR (${component} STREQUAL "all"))
if((NOT PROTOBUF_PROTOC_LIBRARY) AND (NOT TARGET protobuf::libprotoc))
set(Protobuf_FOUND false)
gz_string_append(IgnProtobuf_missing_components "libprotoc" DELIM " ")
gz_string_append(GzProtobuf_missing_components "libprotoc" DELIM " ")
endif()
endif()

if((${component} STREQUAL "protoc") OR (${component} STREQUAL "all"))
if((NOT PROTOBUF_PROTOC_EXECUTABLE) AND (NOT TARGET protobuf::protoc))
set(Protobuf_FOUND false)
gz_string_append(IgnProtobuf_missing_components "protoc" DELIM " ")
gz_string_append(GzProtobuf_missing_components "protoc" DELIM " ")
endif()
endif()

endforeach()

if(IgnProtobuf_missing_components AND NOT IgnProtobuf_FIND_QUIETLY)
message(STATUS "Missing required protobuf components: ${IgnProtobuf_missing_components}")
if(GzProtobuf_missing_components AND NOT GzProtobuf_FIND_QUIETLY)
message(STATUS "Missing required protobuf components: ${GzProtobuf_missing_components}")
endif()

if(${Protobuf_FOUND})
# If we have found Protobuf, then set the IgnProtobuf_FOUND flag to true so
# If we have found Protobuf, then set the GzProtobuf_FOUND flag to true so
# that gz_find_package(~) knows that we were successful.
set(IgnProtobuf_FOUND true)
set(GzProtobuf_FOUND true)
set(IgnProtobuf_FOUND true) # TODO(CH3): Deprecated. Remove on tock.

# Older versions of protobuf don't create imported targets, so we will create
# them here if they have not been provided.
Expand Down
Loading

0 comments on commit 2d3b2ee

Please sign in to comment.