diff --git a/CMakeLists.txt b/CMakeLists.txt index 5925d5fe9..cc6818bc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 2.6 FATAL_ERROR) project(glm) +set(GLM_VERSION "0.9.6") + enable_testing() list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") @@ -141,6 +143,57 @@ include_directories("${PROJECT_SOURCE_DIR}/test/external") add_subdirectory(glm) add_subdirectory(test) -add_subdirectory(util) -install(DIRECTORY glm DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}) +set(GLM_INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/glm") +install(DIRECTORY glm DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/glmVersion.cmake" + VERSION ${GLM_VERSION} + COMPATIBILITY AnyNewerVersion +) + +# build tree package config +configure_file( + cmake/glmBuildConfig.cmake.in + glmConfig.cmake + COPYONLY +) + +# install tree package config +configure_package_config_file( + cmake/glmConfig.cmake.in + ${GLM_INSTALL_CONFIGDIR}/glmConfig.cmake + INSTALL_DESTINATION ${GLM_INSTALL_CONFIGDIR} + PATH_VARS CMAKE_INSTALL_INCLUDEDIR + NO_CHECK_REQUIRED_COMPONENTS_MACRO +) + +install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/glmConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/glmVersion.cmake" + DESTINATION ${GLM_INSTALL_CONFIGDIR} +) + +if (NOT CMAKE_VERSION VERSION_LESS "2.8.12") + add_library(glm INTERFACE) + target_include_directories(glm INTERFACE + $ + $ + ) + install(TARGETS glm EXPORT glmTargets) + + export( + EXPORT glmTargets + FILE "${CMAKE_CURRENT_BINARY_DIR}/glmTargets.cmake" + ) + + install( + EXPORT glmTargets FILE glmTargets.cmake + DESTINATION ${GLM_INSTALL_CONFIGDIR} + ) +endif() + +export(PACKAGE glm) diff --git a/cmake/glmBuildConfig.cmake.in b/cmake/glmBuildConfig.cmake.in new file mode 100644 index 000000000..ea324ab6e --- /dev/null +++ b/cmake/glmBuildConfig.cmake.in @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/glmTargets.cmake") diff --git a/cmake/glmConfig.cmake.in b/cmake/glmConfig.cmake.in new file mode 100644 index 000000000..3f8a1fe5c --- /dev/null +++ b/cmake/glmConfig.cmake.in @@ -0,0 +1,9 @@ +set(GLM_VERSION "@GLM_VERSION@") + +@PACKAGE_INIT@ + +set_and_check(GLM_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") + +if (NOT CMAKE_VERSION VERSION_LESS "2.8.12") + include("${CMAKE_CURRENT_LIST_DIR}/glmTargets.cmake") +endif() diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt deleted file mode 100644 index 3deeb15b0..000000000 --- a/util/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/FindGLM.cmake - DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/cmake) - diff --git a/util/FindGLM.cmake b/util/FindGLM.cmake deleted file mode 100644 index 73fdc0bde..000000000 --- a/util/FindGLM.cmake +++ /dev/null @@ -1,65 +0,0 @@ -# FindGLM - attempts to locate the glm matrix/vector library. -# -# This module defines the following variables (on success): -# GLM_INCLUDE_DIRS - where to find glm/glm.hpp -# GLM_FOUND - if the library was successfully located -# -# It is trying a few standard installation locations, but can be customized -# with the following variables: -# GLM_ROOT_DIR - root directory of a glm installation -# Headers are expected to be found in either: -# /glm/glm.hpp OR -# /include/glm/glm.hpp -# This variable can either be a cmake or environment -# variable. Note however that changing the value -# of the environment varible will NOT result in -# re-running the header search and therefore NOT -# adjust the variables set by this module. - -#============================================================================= -# Copyright 2012 Carsten Neumann -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -# default search dirs -SET(_glm_HEADER_SEARCH_DIRS - "/usr/include" - "/usr/local/include") - -# check environment variable -SET(_glm_ENV_ROOT_DIR "$ENV{GLM_ROOT_DIR}") - -IF(NOT GLM_ROOT_DIR AND _glm_ENV_ROOT_DIR) - SET(GLM_ROOT_DIR "${_glm_ENV_ROOT_DIR}") -ENDIF(NOT GLM_ROOT_DIR AND _glm_ENV_ROOT_DIR) - -# put user specified location at beginning of search -IF(GLM_ROOT_DIR) - SET(_glm_HEADER_SEARCH_DIRS "${GLM_ROOT_DIR}" - "${GLM_ROOT_DIR}/include" - ${_glm_HEADER_SEARCH_DIRS}) -ENDIF(GLM_ROOT_DIR) - -# locate header -FIND_PATH(GLM_INCLUDE_DIR "glm/glm.hpp" - PATHS ${_glm_HEADER_SEARCH_DIRS}) - -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLM DEFAULT_MSG - GLM_INCLUDE_DIR) - -IF(GLM_FOUND) - SET(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}") - - IF(NOT GLM_FIND_QUIETLY) - MESSAGE(STATUS "GLM_INCLUDE_DIR = ${GLM_INCLUDE_DIR}") - ENDIF(NOT GLM_FIND_QUIETLY) -ENDIF(GLM_FOUND)