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

FindGLM: define both glm and glm::glm imported targets #430

Merged
merged 2 commits into from
May 4, 2023
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased Patch]

## [0.15.2] - 2023-05-04

### Fixed

* Make sure that FindGLM defines both `glm` and `glm::glm` imported targets (https://github.com/ami-iit/yarp-device-openxrheadset/issues/35, https://github.com/robotology/ycm/pull/430).

## [0.15.1] - 2023-01-10

### Added
Expand Down
36 changes: 32 additions & 4 deletions find-modules/FindGLM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ The following variables may be set to influence this module’s behavior:
Imported Targets
^^^^^^^^^^^^^^^^

This module defines the :prop_tgt:`IMPORTED` target ``glm`` for the
library glm.
This module defines the :prop_tgt:`IMPORTED` target ``glm::glm`` for the
library glm. For backward compatibility, it also defines ``glm`` imported target.


Result Variables
^^^^^^^^^^^^^^^^
Expand All @@ -43,9 +44,23 @@ This module defines the following variables:

include(FindPackageHandleStandardArgs)

find_package(GLM CONFIG QUIET)
find_package(glm CONFIG QUIET)

if(glm_FOUND)
# glm::glm exists, glm not
if(TARGET glm::glm AND NOT TARGET glm)
add_library(glm INTERFACE IMPORTED)
# Equivalent to target_link_libraries INTERFACE, but compatible with CMake 3.10
set_target_properties(glm PROPERTIES INTERFACE_LINK_LIBRARIES glm::glm)
endif()

# glm exists, glm::glm not
if(TARGET glm AND NOT TARGET glm::glm)
add_library(glm::glm INTERFACE IMPORTED)
# Equivalent to target_link_libraries INTERFACE, but compatible with CMake 3.10
set_target_properties(glm::glm PROPERTIES INTERFACE_LINK_LIBRARIES glm)
endif()

if(GLM_FOUND)
find_package_handle_standard_args(GLM DEFAULT_MSG GLM_CONFIG)
return()
endif()
Expand Down Expand Up @@ -106,6 +121,19 @@ if(NOT TARGET glm)

endif()

if(NOT TARGET glm::glm)
if(GLM_VERBOSE)
message(STATUS "Findglm: Creating glm::glm imported target.")
endif()

add_library(glm::glm INTERFACE IMPORTED)

set_target_properties(glm::glm
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${GLM_INCLUDE_DIRS}")

endif()


# Set package properties if FeatureSummary was included
if(COMMAND set_package_properties)
set_package_properties(assimp PROPERTIES DESCRIPTION "OpenGL Mathematics (GLM)"
Expand Down