The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cmake: fix eigen cmake packages for v5.0 (3.5)

Eigen changed from 3.x versioning to semver (3.5 became 5.0) and
dropped FindEigen3.cmake module support (deprecated in prior versions)
for config discovery.

Switch from find_package version constraints to manual version checking
to maintain compatibility with both versioning schemes (>= 3.3 old or
>= 5.0 new).

See: https://gitlab.com/libeigen/eigen/-/merge_requests/485
Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2583>

+27 -145
+2 -2
.gitlab-ci.yml
··· 433 433 script: 434 434 435 435 - .gitlab-ci/prebuild.sh 436 - - .gitlab-ci/ci-cmake-build.sh -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=26 -DCMAKE_TOOLCHAIN_FILE=/opt/android-ndk/build/cmake/android.toolchain.cmake -DEigen3_DIR=/usr/lib/cmake/eigen3/ -DEIGEN3_INCLUDE_DIR=/usr/include/eigen3 436 + - .gitlab-ci/ci-cmake-build.sh -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=26 -DCMAKE_TOOLCHAIN_FILE=/opt/android-ndk/build/cmake/android.toolchain.cmake -DEigen3_DIR=/usr/share/eigen3/cmake/ 437 437 438 438 ndk:arm64-v8a: 439 439 stage: build ··· 443 443 script: 444 444 445 445 - .gitlab-ci/prebuild.sh 446 - - .gitlab-ci/ci-cmake-build.sh -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=26 -DCMAKE_TOOLCHAIN_FILE=/opt/android-ndk/build/cmake/android.toolchain.cmake -DEigen3_DIR=/usr/lib/cmake/eigen3/ -DEIGEN3_INCLUDE_DIR=/usr/include/eigen3 446 + - .gitlab-ci/ci-cmake-build.sh -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=26 -DCMAKE_TOOLCHAIN_FILE=/opt/android-ndk/build/cmake/android.toolchain.cmake -DEigen3_DIR=/usr/share/eigen3/cmake/ 447 447 448 448 android:spotlessCheck: 449 449 stage: build
+2 -2
.gitlab-ci/config.yml
··· 60 60 .android_cmake_defines: &android_cmake_defines 61 61 ANDROID_PLATFORM: 26 62 62 CMAKE_TOOLCHAIN_FILE: /opt/android-ndk/build/cmake/android.toolchain.cmake 63 - Eigen3_DIR: /usr/lib/cmake/eigen3/ 64 - EIGEN3_INCLUDE_DIR: /usr/include/eigen3 63 + Eigen3_DIR: /usr/share/eigen3/cmake/ 64 + 65 65 66 66 # Which build job do we use to build the documentation. 67 67 documentation_build: "debian:cmake"
+11 -3
CMakeLists.txt
··· 83 83 endif() 84 84 endif() 85 85 86 - # Redundant mention of version is required because module defaults to looking for 2.91-compatible, 87 - # which the config file for a 3.x says it's not compatible with. 88 - find_package(Eigen3 3 REQUIRED) 86 + # 87 + # For backwards compatibility with both version schemes, 88 + # we find any Eigen3 package (in config mode) and check 89 + # the version manually rather than using find_package 90 + # version constraints. 91 + # 92 + find_package(Eigen3 REQUIRED NO_MODULE) 93 + if(Eigen3_VERSION VERSION_LESS "3.3") 94 + message(FATAL_ERROR "Eigen3 version ${Eigen3_VERSION} is too old, need at least 3.3") 95 + endif() 96 + 89 97 find_package(Vulkan MODULE) 90 98 find_package(HIDAPI MODULE) 91 99 find_package(bluetooth MODULE)
+2 -2
build.gradle
··· 80 80 sharedTargetSdk = 31 81 81 sharedMinSdk = 26 82 82 83 - // If you are building on Windows, you will need to explicitly set eigenIncludeDir in your 83 + // If you are building on Windows, you will need to explicitly set eigenCMakeDir in your 84 84 // local.properties file since the default value provided below only makes sense on *nix 85 - eigenIncludeDir = project.findProperty('eigenIncludeDir') ?: '/usr/include/eigen3' 85 + eigenCMakeDir = project.findProperty('eigenCMakeDir') ?: '/usr/share/eigen3/cmake' 86 86 87 87 // If you're having trouble with a "can't find python" CMake error, you can specify the path to 88 88 // Python 3 explicitly in local.properties with a property named "pythonBinary"
-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()
+1 -2
src/xrt/auxiliary/math/CMakeLists.txt
··· 46 46 ) 47 47 target_link_libraries( 48 48 aux_math 49 - PUBLIC aux-includes aux_util 49 + PUBLIC aux-includes aux_util Eigen3::Eigen 50 50 PRIVATE xrt-optimized-math 51 51 ) 52 - target_include_directories(aux_math SYSTEM PRIVATE ${EIGEN3_INCLUDE_DIR}) 53 52 54 53 if(MSVC) 55 54 get_target_property(options aux_math COMPILE_OPTIONS)
-1
src/xrt/auxiliary/tracking/CMakeLists.txt
··· 23 23 xrt-external-hungarian 24 24 xrt-optimized-math 25 25 ) 26 - target_include_directories(aux_tracking SYSTEM PRIVATE ${EIGEN3_INCLUDE_DIR}) 27 26 28 27 if(XRT_HAVE_OPENCV) 29 28 target_sources(
-3
src/xrt/auxiliary/util/CMakeLists.txt
··· 166 166 target_link_libraries(aux_util PUBLIC ${ANDROID_LOG_LIBRARY}) 167 167 endif() 168 168 169 - # Internal dependency and doesn't bring in any DSO. 170 - target_include_directories(aux_util PRIVATE ${EIGEN3_INCLUDE_DIR}) 171 - 172 169 #### 173 170 # Debug UI library 174 171 #
+1 -2
src/xrt/drivers/CMakeLists.txt
··· 279 279 rift_s/rift_s.c 280 280 rift_s/rift_s.h 281 281 ) 282 - target_include_directories(drv_rift_s SYSTEM PRIVATE ${EIGEN3_INCLUDE_DIR}) 283 282 target_link_libraries( 284 283 drv_rift_s 285 284 PRIVATE ··· 354 353 hand_async 355 354 ) 356 355 357 - target_include_directories(drv_ht PRIVATE ${OpenCV_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR}) 356 + target_include_directories(drv_ht PRIVATE ${OpenCV_INCLUDE_DIRS}) 358 357 list(APPEND ENABLED_DRIVERS ht) 359 358 endif() 360 359
+5 -5
src/xrt/targets/openxr_android/build.gradle
··· 81 81 into eigenUnpackDir 82 82 } 83 83 84 - if (!(new File(project.file(project.eigenIncludeDir), "Eigen/Core")).exists()) { 85 - println "project.eigenIncludeDir not set or not valid, so downloading Eigen at build time" 86 - project.ext.eigenIncludeDir = "${eigenUnpackDir}/eigen-${project.eigenFetchVersion}" 84 + if (!(new File(project.file(project.eigenCMakeDir), "Eigen3Config.cmake")).exists()) { 85 + println "project.eigenCMakeDir not set or not valid, so downloading Eigen at build time" 86 + project.ext.eigenCMakeDir = "${eigenUnpackDir}/eigen-${project.eigenFetchVersion}/cmake" 87 87 } else { 88 - println "Using Eigen as specified/detected in project.eigenIncludeDir: ${project.eigenIncludeDir}" 88 + println "Using Eigen as specified/detected in project.eigenCMakeDir: ${project.eigenCMakeDir}" 89 89 downloadEigen.enabled = false 90 90 unpackEigen.enabled = false 91 91 } ··· 176 176 177 177 externalNativeBuild { 178 178 cmake { 179 - arguments "-DEIGEN3_INCLUDE_DIR=${project.eigenIncludeDir}", 179 + arguments "-DEigen3_DIR=${project.eigenCMakeDir}", 180 180 "-DANDROID_PLATFORM=${project.sharedMinSdk}", 181 181 "-DANDROID_STL=${project.stl}", 182 182 "-DANDROID_ARM_NEON=TRUE"
+3 -10
src/xrt/tracking/hand/mercury/CMakeLists.txt
··· 12 12 13 13 target_link_libraries(t_ht_mercury_model PRIVATE aux_math aux_tracking aux_os aux_util) 14 14 15 - target_include_directories( 16 - t_ht_mercury_model SYSTEM PRIVATE ${OpenCV_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR} 17 - ) 18 - 15 + target_include_directories(t_ht_mercury_model SYSTEM PRIVATE ${OpenCV_INCLUDE_DIRS}) 19 16 target_link_libraries( 20 17 t_ht_mercury_model 21 18 PRIVATE ··· 33 30 34 31 target_link_libraries(t_ht_mercury_distorter PRIVATE aux_math aux_tracking aux_os aux_util) 35 32 36 - target_include_directories( 37 - t_ht_mercury_distorter SYSTEM PRIVATE ${OpenCV_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR} 38 - ) 33 + target_include_directories(t_ht_mercury_distorter SYSTEM PRIVATE ${OpenCV_INCLUDE_DIRS}) 39 34 40 35 target_link_libraries( 41 36 t_ht_mercury_distorter ··· 71 66 target_include_directories(t_ht_mercury INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) 72 67 73 68 if(XRT_HAVE_OPENCV) 74 - target_include_directories( 75 - t_ht_mercury SYSTEM PRIVATE ${OpenCV_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR} 76 - ) 69 + target_include_directories(t_ht_mercury SYSTEM PRIVATE ${OpenCV_INCLUDE_DIRS}) 77 70 target_link_libraries(t_ht_mercury PUBLIC ${OpenCV_LIBRARIES}) 78 71 endif() 79 72
-2
src/xrt/tracking/hand/mercury/kine_lm/CMakeLists.txt
··· 19 19 xrt-optimized-math 20 20 ) 21 21 22 - target_include_directories(t_ht_mercury_kine_lm SYSTEM PRIVATE ${EIGEN3_INCLUDE_DIR}) 23 - 24 22 if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") 25 23 target_compile_options(t_ht_mercury_kine_lm PRIVATE -ftemplate-backtrace-limit=20) 26 24 endif()
-3
tests/CMakeLists.txt
··· 68 68 target_link_libraries(tests_quat_swing_twist PRIVATE aux_math) 69 69 target_link_libraries(tests_vec3_angle PRIVATE aux_math) 70 70 71 - target_include_directories(tests_quat_change_of_basis SYSTEM PRIVATE ${EIGEN3_INCLUDE_DIR}) 72 - target_include_directories(tests_quat_swing_twist SYSTEM PRIVATE ${EIGEN3_INCLUDE_DIR}) 73 - 74 71 if(XRT_BUILD_DRIVER_HANDTRACKING) 75 72 target_link_libraries( 76 73 tests_levenbergmarquardt