1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-22 02:12:45 +01:00

cmake: detect glm version

This commit is contained in:
Anonymous Maarten 2018-09-16 00:28:17 +02:00
parent d06d4fc264
commit d1cb0f143c

View File

@ -52,14 +52,24 @@ endif()
find_path(GLM_INCLUDE_DIR "glm/glm.hpp" find_path(GLM_INCLUDE_DIR "glm/glm.hpp"
PATHS ${_glm_HEADER_SEARCH_DIRS}) PATHS ${_glm_HEADER_SEARCH_DIRS})
if(GLM_INCLUDE_DIR)
file(READ "${GLM_INCLUDE_DIR}/glm/detail/setup.hpp" _GLM_SETUP_HPP)
string(REGEX MATCH "GLM: version ([0-9a-zA-Z\.\-]+)" _GLM_VERSION "${_GLM_SETUP_HPP}")
if(NOT _GLM_VERSION)
message(AUTHOR_WARNING "Cannot detect GLM version: regex does not match")
endif()
set(GLM_VERSION "${CMAKE_MATCH_1}")
endif()
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLM DEFAULT_MSG find_package_handle_standard_args(GLM
GLM_INCLUDE_DIR) FOUND_VAR GLM_FOUND
REQUIRED_VARS GLM_INCLUDE_DIR
VERSION_VAR GLM_VERSION
)
if(GLM_FOUND) if(GLM_FOUND)
set(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}") add_library(glm::glm INTERFACE IMPORTED)
add_library(glm INTERFACE) set_property(TARGET glm::glm
target_include_directories(glm SYSTEM PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${GLM_INCLUDE_DIR})
INTERFACE "${GLM_INCLUDE_DIR}")
add_library(glm::glm ALIAS glm)
endif() endif()