The open source OpenXR runtime

build: Add FindEigen3.cmake from upstream, to support pointing at the include dir.

+133 -1
+3 -1
CMakeLists.txt
··· 24 24 check_ipo_supported(RESULT HAS_IPO) 25 25 endif() 26 26 27 - find_package(Eigen3 REQUIRED) 27 + # Redundant mention of version is required because module defaults to looking for 2.91-compatible, 28 + # which the config file for a 3.x says it's not compatible with. 29 + find_package(Eigen3 3 REQUIRED) 28 30 find_package(Vulkan) 29 31 find_package(EGL) 30 32 find_package(HIDAPI)
+22
LICENSES/BSD-2-Clause.txt
··· 1 + Copyright (c) <year> <owner>. All rights reserved. 2 + 3 + Redistribution and use in source and binary forms, with or without modification, 4 + are permitted provided that the following conditions are met: 5 + 6 + 1. Redistributions of source code must retain the above copyright notice, 7 + this list of conditions and the following disclaimer. 8 + 9 + 2. Redistributions in binary form must reproduce the above copyright notice, 10 + this list of conditions and the following disclaimer in the documentation 11 + and/or other materials provided with the distribution. 12 + 13 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 14 + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 17 + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 21 + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 22 + USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+108
cmake/FindEigen3.cmake
··· 1 + # - Try to find Eigen3 lib 2 + # 3 + # This module supports requiring a minimum version, e.g. you can do 4 + # find_package(Eigen3 3.1.2) 5 + # to require version 3.1.2 or newer of Eigen3. 6 + # 7 + # Once done this will define 8 + # 9 + # EIGEN3_FOUND - system has eigen lib with correct version 10 + # EIGEN3_INCLUDE_DIR - the eigen include directory 11 + # EIGEN3_VERSION - eigen version 12 + # 13 + # and the following imported target: 14 + # 15 + # Eigen3::Eigen - The header-only Eigen library 16 + # 17 + # This module reads hints about search locations from 18 + # the following environment variables: 19 + # 20 + # EIGEN3_ROOT 21 + # EIGEN3_ROOT_DIR 22 + 23 + # Copyright (c) 2006, 2007 Montel Laurent, <montel@kde.org> 24 + # Copyright (c) 2008, 2009 Gael Guennebaud, <g.gael@free.fr> 25 + # Copyright (c) 2009 Benoit Jacob <jacob.benoit.1@gmail.com> 26 + # Redistribution and use is allowed according to the terms of the 2-clause BSD license. 27 + # SPDX-License-Identifier: BSD-2-Clause 28 + 29 + if(NOT Eigen3_FIND_VERSION) 30 + if(NOT Eigen3_FIND_VERSION_MAJOR) 31 + set(Eigen3_FIND_VERSION_MAJOR 2) 32 + endif() 33 + if(NOT Eigen3_FIND_VERSION_MINOR) 34 + set(Eigen3_FIND_VERSION_MINOR 91) 35 + endif() 36 + if(NOT Eigen3_FIND_VERSION_PATCH) 37 + set(Eigen3_FIND_VERSION_PATCH 0) 38 + endif() 39 + 40 + set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}") 41 + endif() 42 + 43 + macro(_eigen3_check_version) 44 + file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header) 45 + 46 + string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}") 47 + set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}") 48 + string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}") 49 + set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}") 50 + string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}") 51 + set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}") 52 + 53 + set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION}) 54 + if(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION}) 55 + set(EIGEN3_VERSION_OK FALSE) 56 + else() 57 + set(EIGEN3_VERSION_OK TRUE) 58 + endif() 59 + 60 + if(NOT EIGEN3_VERSION_OK) 61 + 62 + message(STATUS "Eigen3 version ${EIGEN3_VERSION} found in ${EIGEN3_INCLUDE_DIR}, " 63 + "but at least version ${Eigen3_FIND_VERSION} is required") 64 + endif() 65 + endmacro() 66 + 67 + if (EIGEN3_INCLUDE_DIR) 68 + 69 + # in cache already 70 + _eigen3_check_version() 71 + set(EIGEN3_FOUND ${EIGEN3_VERSION_OK}) 72 + set(Eigen3_FOUND ${EIGEN3_VERSION_OK}) 73 + 74 + else () 75 + 76 + # search first if an Eigen3Config.cmake is available in the system, 77 + # if successful this would set EIGEN3_INCLUDE_DIR and the rest of 78 + # the script will work as usual 79 + find_package(Eigen3 ${Eigen3_FIND_VERSION} NO_MODULE QUIET) 80 + 81 + if(NOT EIGEN3_INCLUDE_DIR) 82 + find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library 83 + HINTS 84 + ENV EIGEN3_ROOT 85 + ENV EIGEN3_ROOT_DIR 86 + PATHS 87 + ${CMAKE_INSTALL_PREFIX}/include 88 + ${KDE4_INCLUDE_DIR} 89 + PATH_SUFFIXES eigen3 eigen 90 + ) 91 + endif() 92 + 93 + if(EIGEN3_INCLUDE_DIR) 94 + _eigen3_check_version() 95 + endif() 96 + 97 + include(FindPackageHandleStandardArgs) 98 + find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK) 99 + 100 + mark_as_advanced(EIGEN3_INCLUDE_DIR) 101 + 102 + endif() 103 + 104 + if(EIGEN3_FOUND AND NOT TARGET Eigen3::Eigen) 105 + add_library(Eigen3::Eigen INTERFACE IMPORTED) 106 + set_target_properties(Eigen3::Eigen PROPERTIES 107 + INTERFACE_INCLUDE_DIRECTORIES "${EIGEN3_INCLUDE_DIR}") 108 + endif()